Skip to content

Instantly share code, notes, and snippets.

@cloudchristoph
Last active Nov 5, 2021
Embed
What would you like to do?
Bicep - nested loop with module
param sbNamespaceName string = 'sbnamespace'
param topics array = [
{
name: 'topic1'
subscriptions: [
'sub1.1'
'sub1.2'
]
}
{
name: 'topic2'
subscriptions: [
'sub2.1'
]
}
]
module servicebusTopic 'sbtopic.bicep' = [for topic in topics: {
name: topic.name
params: {
topic: topic
sbNamespaceName: sbNamespaceName
}
}]
param sbNamespaceName string
param topic object
resource serviceBusNamespace 'Microsoft.ServiceBus/namespaces@2021-06-01-preview' existing = {
name: sbNamespaceName
}
resource serviceBusTopic 'Microsoft.ServiceBus/namespaces/topics@2021-06-01-preview' = {
name: topic.name
parent: serviceBusNamespace
resource serviceBusSubscription 'subscriptions@2021-06-01-preview' = [for sub in topic.subscriptions: {
name: sub
}]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment