bicep extending the template earlier to support azure service bus
In the previous post we creating azure storage account using bicep. Now we are going to create a service bus module and calling it.
So we will place our service bus under the path modules/servicebus/main.bicep and its contents are given here. This will create a service bus namespace and a queue
@description('Name of the Service Bus namespace')
param serviceBusNamespaceName string
@description('Name of the Queue')
param serviceBusQueueName string
@description('Location for all resources.')
param location string = resourceGroup().location
resource serviceBusNamespace 'Microsoft.ServiceBus/namespaces@2022-01-01-preview' = {
name: serviceBusNamespaceName
location: location
sku: {
name: 'Standard'
}
properties: {}
}
resource serviceBusQueue 'Microsoft.ServiceBus/namespaces/queues@2022-01-01-preview' = {
parent: serviceBusNamespace
name: serviceBusQueueName
properties: {
lockDuration: 'PT5M'
maxSizeInMegabytes: 1024
requiresDuplicateDetection: false
requiresSession: false
defaultMessageTimeToLive: 'P10675199DT2H48M5.4775807S'
deadLetteringOnMessageExpiration: false
duplicateDetectionHistoryTimeWindow: 'PT10M'
maxDeliveryCount: 10
autoDeleteOnIdle: 'P10675199DT2H48M5.4775807S'
enablePartitioning: false
enableExpress: false
}
}
And we will call it using main.bicep
// main.bicep
module storageModule './modules/storage/main.bicep' = {
name: 'storageDeploy-${uniqueString(resourceGroup().id)}'
params: {
storageSku: 'Standard_LRS'
}
}
module serviceBusModule './modules/servicebus/main.bicep' = {
name: 'servicebus-${uniqueString(resourceGroup().id)}'
params: {
serviceBusNamespaceName: 'approotns'
serviceBusQueueName: 'testqueue'
}
}
// Accessing an output from the module
output storageId string = storageModule.outputs.saName
And to create it using our cli, we run
Comments