How to conditional deploy in a for loop #16669
-
I know we can do conditional deployment like this example below based on this documentation: param deployZone bool
resource dnsZone 'Microsoft.Network/dnsZones@2023-07-01-preview' = if (deployZone) {
name: 'myZone'
location: 'global'
} But how can I do the same when we have For Loop in a resource? Such as: @description('Datastore for ADLSv2 Data Lake with Entra Id as authentication method')
resource dataStoresDataLake_EntraId 'Microsoft.MachineLearningServices/workspaces/datastores@2024-10-01' = [
for container in lakeContainerNames: {
parent: machineLearningWorkspace
name: '${adlsv2Name}_${container}'
properties: {
credentials: {
credentialsType: 'None'
}
subscriptionId: adlsv2SubscriptionId
resourceGroup: adlsv2ResourceGroup
datastoreType: 'AzureDataLakeGen2'
accountName: adlsv2Name
filesystem: container
endpoint: environment().suffixes.storage
protocol: 'https'
serviceDataAccessAuthIdentity: 'WorkspaceSystemAssignedIdentity'
}
}
] If I do this |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The condition needs to be inside the loop. Conditions apply to each iteration of the loop, not the loop as a whole. There are some examples you can follow on https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/loops#loop-with-condition |
Beta Was this translation helpful? Give feedback.
The condition needs to be inside the loop. Conditions apply to each iteration of the loop, not the loop as a whole. There are some examples you can follow on https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/loops#loop-with-condition