I am trying to create a service bus and topic (many topics and their subscriptions) with the azure bicep.
I have main bicep like below
param topics array; resource serviceBusNamespace 'Microsoft.ServiceBus/namespaces@2018-01-01-preview' = { name: serviceBusNamespaceName location: location sku: { name: skuName } } module topicSubscription './sb_topic.bicep' = [for topic in topics: { name: 'topicSubscription${topic}' params: { topic: topic } }]
module file looks like
resource sbTopics 'Microsoft.ServiceBus/namespaces/topics@2022-01-01-preview' = {
name: topic.name
parent: ??
properties: topic.properties
resource symbolicname 'subscriptions@2022-01-01-preview' = [for subscription in topic.subscriptions: {
name: 'string'
properties: {}
}]
}
How can pass the parent serviceBusNamespace resource as parent to the child resource inside the module?
Kindly suggest..
CodePudding user response:
In the module reference the namespace with an 'existing' declaration. Something like this
param namespaceName string
resource serviceBusNamespace 'Microsoft.ServiceBus/namespaces@2018-01-01-preview' existing = {
name: namespaceName
}
resource sbTopics 'Microsoft.ServiceBus/namespaces/topics@2022-01-01-preview' = {
name: topic.name
parent: serviceBusNamespace
properties: topic.properties
resource symbolicname 'subscriptions@2022-01-01-preview' = [for subscription in topic.subscriptions: {
name: 'string'
properties: {}
}]
}