Calling module output generates a deployment resource. #12810
-
Seeing some odd behavior in my deployment. Deploying a new subnet and UDR, the deployment succeeds, but the deployment details are odd. The deployment creates the UDR in a module and outputs the UDR ID. I then call the subnet module and pass the ID output. Everything completes successfully, but I get a duplicate deployment for the UDR. Is this expected behavior? This was mainly discovered when a deployment step was failing when a vnet module was configured to use the output of an NSG. The main deployment template has vnet, subnet, UDR, NSG. However, the NSG and Vnet are configured to be conditionally skipped. The vnet params are passing the nsg object to the vnet create task. But there is no NSG or Vnet as they are not a part of the deployment. Still, the deployment throws an error that the nsg is not found. I know it is not found, the module was skipped. The vnet module where the output would be used is also supposed to be ignored.
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi @Kolbasz12, I have had this issue before. On my blog I have written down why this occurs and how to fix it: https://johnlokerse.dev/2023/01/23/deploymentnotfound-error-using-azure-bicep-modules/ In short, the dependency during transpilation (converting Bicep to ARM) is still evaluated in the reference() function. This dependency is pointed to a module that is not deployed and the Azure Resource Manager cannot find this deployment. This is how the "DeploymentNotFound" error occurs. To fix the problem you can use a condition at the location where the dependency is written. Hope this works for you! If not, let me know so I can help you further 👍 |
Beta Was this translation helpful? Give feedback.
-
thank you for this, it got me on the right path. Had to rework some template logic, but it is working now as expected. |
Beta Was this translation helpful? Give feedback.
Hi @Kolbasz12, I have had this issue before. On my blog I have written down why this occurs and how to fix it: https://johnlokerse.dev/2023/01/23/deploymentnotfound-error-using-azure-bicep-modules/
In short, the dependency during transpilation (converting Bicep to ARM) is still evaluated in the reference() function. This dependency is pointed to a module that is not deployed and the Azure Resource Manager cannot find this deployment. This is how the "DeploymentNotFound" error occurs. To fix the problem you can use a condition at the location where the dependency is written.
Hope this works for you! If not, let me know so I can help you further 👍