You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As a Bicep Developer I want to be able dynamically build dependsOn objects natively in Bicep based on conditions So that I am able to fully support modulised deployments so I don't have to deploy the whole solution/main.bicep every time
Describe the solution you'd like
My example main.bicep has modules for:
appConfigurationStore
containerAppManagedEnvironment
keyVault
postgresqlFlexibleServer
storageAccount
virtualNetwork
Each of these modules will deploy if a corresponding bool parameter is true e.g. deployAppConfigurationStore.
Some of these conditions are simple and are supported in bicep today.
In the case of containerAppManagedEnvironment I can do this as there are no other dependencies.
In the cases of appConfigurationStore and postgresqlFlexibleServer I have dependencies on virtualNetwork and keyVault. However, that dependency is only valid for a "full deployment". There is a use case where I only want to deploy specific components in the solution such and which components I pick changes each time.
I have asked ChatGPT this question and it suggested this solution:
var appConfigurationStoreConditionalDependsOn = [
deployVirtualNetwork ? virtualNetwork : null
deployKeyVault ? keyVault : null
]
var appConfigurationStoreConditionalDependsOnFiltered = [for dependency in appConfigurationStoreConditionalDependsOn: dependency != null ? dependency : []]
module appConfigurationStore 'appConfigurationStore.bicep' = if (deployAppConfigurationStore) {
dependsOn: appConfigurationStoreConditionalDependsOnFiltered
This does not seem to be supported: [for dependency in appConfigurationStoreConditionalDependsOn - This expression is being used in the for-expression, which requires a value that can be calculated at the start of the deployment. You are referencing a variable which cannot be calculated at the start ("appConfigurationStoreConditionalDependsOn" -> "virtualNetwork"). Properties of virtualNetwork which can be calculated at the start include "name".
dependency != null ? dependency : []] - The property "dependsOn" expected a value of type "module[] | (resource | module) | resource[]" but the provided value is of type " | module | module | null".
It would be awesome to solve this, there are other pipelines I have that have even more dependencies
The text was updated successfully, but these errors were encountered:
That approach doesn't work for me because I'm using unique deployment names e.g. keyVault-2025-03-11-10-00 and it will search for a deployment that doesn't exist in that scenario
That shouldn't be a problem. The following template deploys without issue, even though the anotherOne module has a dependency on the empty module, which won't be deployed:
The deployments engine will look at what's in dependsOn, verify that everything in the list corresponds to a resource in the template, and then ignore any dependency on a resource with a false condition. There's a bit more detail on the docs page on the expected behavior.
As a Bicep Developer
I want to be able dynamically build dependsOn objects natively in Bicep based on conditions
So that I am able to fully support modulised deployments so I don't have to deploy the whole solution/main.bicep every time
Describe the solution you'd like
My example main.bicep has modules for:
Each of these modules will deploy if a corresponding bool parameter is true e.g. deployAppConfigurationStore.
Some of these conditions are simple and are supported in bicep today.
In the case of containerAppManagedEnvironment I can do this as there are no other dependencies.
In the cases of appConfigurationStore and postgresqlFlexibleServer I have dependencies on virtualNetwork and keyVault. However, that dependency is only valid for a "full deployment". There is a use case where I only want to deploy specific components in the solution such and which components I pick changes each time.
I have asked ChatGPT this question and it suggested this solution:
This does not seem to be supported:
[for dependency in appConfigurationStoreConditionalDependsOn
- This expression is being used in the for-expression, which requires a value that can be calculated at the start of the deployment. You are referencing a variable which cannot be calculated at the start ("appConfigurationStoreConditionalDependsOn" -> "virtualNetwork"). Properties of virtualNetwork which can be calculated at the start include "name".dependency != null ? dependency : []]
- The property "dependsOn" expected a value of type "module[] | (resource | module) | resource[]" but the provided value is of type " | module | module | null".It would be awesome to solve this, there are other pipelines I have that have even more dependencies
The text was updated successfully, but these errors were encountered: