Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
param serviceBusNamespaceName string
param connectionStringSecretName string
param keyVaultName string

resource serviceBusNamespace 'Microsoft.ServiceBus/namespaces@2022-10-01-preview' existing = {
name: serviceBusNamespaceName
}

resource keyVault 'Microsoft.KeyVault/vaults@2022-07-01' existing = {
name: keyVaultName
}

resource serviceBusConnectionStringSecret 'Microsoft.KeyVault/vaults/secrets@2022-07-01' = {
name: connectionStringSecretName
parent: keyVault
properties: {
value: listKeys(concat(resourceId('Microsoft.ServiceBus/namespaces', serviceBusNamespaceName), '/AuthorizationRules/RootManageSharedAccessKey'), serviceBusNamespace.apiVersion).primaryConnectionString
}
}

60 changes: 0 additions & 60 deletions cli/azd/resources/scaffold/templates/azure-service-bus.bicept

This file was deleted.

96 changes: 94 additions & 2 deletions cli/azd/resources/scaffold/templates/resources.bicept
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,57 @@ module storageAccount 'br/public:avm/res/storage/storage-account:0.14.3' = {
]
networkAcls: {
defaultAction: 'Allow'
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The white space should not be deleted here. I'll revert this change in my feature branch.

tags: tags
}
}
{{end}}

{{- if .AzureServiceBus }}

module serviceBusNamespace 'br/public:avm/res/service-bus/namespace:0.10.0' = {
name: 'serviceBusNamespace'
params: {
// Required parameters
name: '${abbrs.serviceBusNamespaces}${resourceToken}'
// Non-required parameters
location: location
roleAssignments: [
{{- if (and .AzureServiceBus .AzureServiceBus.AuthUsingManagedIdentity) }}
{{- range .Services}}
{
principalId: {{bicepName .Name}}Identity.outputs.principalId
principalType: 'ServicePrincipal'
roleDefinitionIdOrName: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '090c5cfd-751d-490a-894a-3ce6f1109419')
}
{{- end}}
{{- end}}
]
{{- if (and .AzureServiceBus .AzureServiceBus.AuthUsingConnectionString) }}
disableLocalAuth: false
{{- end}}
queues: [
{{- range $queue := .AzureServiceBus.Queues}}
{
name: '{{ $queue }}'
}
{{- end}}
]
}
}

{{- if (and .AzureServiceBus .AzureServiceBus.AuthUsingConnectionString) }}
module serviceBusConnectionString './modules/set-servicebus-namespace-connection-string.bicep' = {
name: 'serviceBusConnectionString'
params: {
serviceBusNamespaceName: serviceBusNamespace.outputs.name
connectionStringSecretName: 'SERVICEBUS-CONNECTION-STRING'
keyVaultName: keyVault.outputs.name
}
}
{{end}}
{{end}}

{{- range .Services}}

module {{bicepName .Name}}Identity 'br/public:avm/res/managed-identity/user-assigned-identity:0.2.1' = {
Expand Down Expand Up @@ -234,7 +280,7 @@ var {{bicepName .Name}}Env = map(filter({{bicepName .Name}}AppSettingsArray, i =
module {{bicepName .Name}} 'br/public:avm/res/app/container-app:0.8.0' = {
name: '{{bicepName .Name}}'
params: {
name: '{{.Name}}'
name: '{{containerAppName .Name}}'
{{- if ne .Port 0}}
ingressTargetPort: {{.Port}}
{{- end}}
Expand Down Expand Up @@ -287,6 +333,13 @@ module {{bicepName .Name}} 'br/public:avm/res/app/container-app:0.8.0' = {
keyVaultUrl: '${keyVault.outputs.uri}secrets/EVENT-HUBS-CONNECTION-STRING'
}
{{- end}}
{{- if (and .AzureServiceBus .AzureServiceBus.AuthUsingConnectionString) }}
{
name: 'servicebus-connection-string'
identity:{{bicepName .Name}}Identity.outputs.resourceId
keyVaultUrl: '${keyVault.outputs.uri}secrets/SERVICEBUS-CONNECTION-STRING'
}
{{- end}}
],
map({{bicepName .Name}}Secrets, secret => {
name: secret.secretRef
Expand Down Expand Up @@ -414,6 +467,42 @@ module {{bicepName .Name}} 'br/public:avm/res/app/container-app:0.8.0' = {
value: {{bicepName .Name}}Identity.outputs.clientId
}
{{- end}}

{{- if .AzureServiceBus }}
{
name: 'SPRING_CLOUD_AZURE_SERVICEBUS_NAMESPACE'
value: serviceBusNamespace.outputs.name
}
{{- end}}
{{- if (and .AzureServiceBus .AzureServiceBus.AuthUsingManagedIdentity) }}
{
name: 'SPRING_CLOUD_AZURE_SERVICEBUS_CONNECTION_STRING'
value: ''
}
{
name: 'SPRING_CLOUD_AZURE_SERVICEBUS_CREDENTIAL_MANAGEDIDENTITYENABLED'
value: 'true'
}
{
name: 'SPRING_CLOUD_AZURE_SERVICEBUS_CREDENTIAL_CLIENTID'
value: {{bicepName .Name}}Identity.outputs.clientId
}
{{- end}}
{{- if (and .AzureServiceBus .AzureServiceBus.AuthUsingConnectionString) }}
{
name: 'SPRING_CLOUD_AZURE_SERVICEBUS_CONNECTION_STRING'
secretRef: 'servicebus-connection-string'
}
{
name: 'SPRING_CLOUD_AZURE_SERVICEBUS_CREDENTIAL_MANAGEDIDENTITYENABLED'
value: 'false'
}
{
name: 'SPRING_CLOUD_AZURE_EVENTHUBS_CREDENTIAL_CLIENTID'
value: ''
}
{{- end}}

{{- if .Frontend}}
{{- range $i, $e := .Frontend.Backends}}
{
Expand Down Expand Up @@ -527,4 +616,7 @@ output AZURE_POSTGRES_FLEXIBLE_SERVER_ID string = postgreServer.outputs.resource
{{- if .AzureEventHubs }}
output AZURE_EVENT_HUBS_ID string = eventHubNamespace.outputs.resourceId
{{- end}}
{{- if .AzureServiceBus }}
output AZURE_SERVICE_BUS_ID string = serviceBusNamespace.outputs.resourceId
{{- end}}
{{ end}}