From df232ed9be3007db7d64614f0479fcc25b3efef4 Mon Sep 17 00:00:00 2001 From: Are Almaas Date: Fri, 5 Apr 2024 16:18:11 +0100 Subject: [PATCH 1/3] add service bus yea --- .azure/modules/serviceBus/main.bicep | 36 ++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .azure/modules/serviceBus/main.bicep diff --git a/.azure/modules/serviceBus/main.bicep b/.azure/modules/serviceBus/main.bicep new file mode 100644 index 000000000..1406e66da --- /dev/null +++ b/.azure/modules/serviceBus/main.bicep @@ -0,0 +1,36 @@ +param namePrefix string +param location string + +@export() +type Sku = { + name: 'Basic' | 'Standard' | 'Premium' +} +param sku Sku + +// todo: add a service bus here pls +resource serviceBusNamespace 'Microsoft.ServiceBus/namespaces@2023-03-01' = { + name: 'myServiceBusNamespace' + location: resourceGroup().location + sku: sku + properties: { + maximumThroughputUnits: 0 // Set according to your needs + } +} + +resource serviceBusQueue 'Microsoft.ServiceBus/namespaces/queues@2023-03-01' = { + name: 'myQueue' + parent: serviceBusNamespace + properties: { + lockDuration: 'PT5M' + maxSizeInMegabytes: 1024 + requiresDuplicateDetection: true + requiresSession: false + defaultMessageTimeToLive: 'P14D' + deadLetteringOnMessageExpiration: true + duplicateDetectionHistoryTimeWindow: 'PT10M' + maxDeliveryCount: 10 + enableBatchedOperations: true + autoDeleteOnIdle: 'P10675199DT2H48M5.4775807S' // Set to never auto-delete + } +} + From 4d523f590d89e1f1c1d9abc22a727f36bc754071 Mon Sep 17 00:00:00 2001 From: Are Almaas Date: Mon, 8 Apr 2024 18:17:07 +0100 Subject: [PATCH 2/3] cleanup --- .azure/infrastructure/main.bicep | 36 ++++++++++++++------ .azure/infrastructure/production.bicepparam | 6 ++++ .azure/infrastructure/soak.bicepparam | 6 ++++ .azure/infrastructure/staging.bicepparam | 6 ++++ .azure/infrastructure/test.bicepparam | 6 ++++ .azure/modules/serviceBus/main.bicep | 37 +++++++++++---------- 6 files changed, 70 insertions(+), 27 deletions(-) diff --git a/.azure/infrastructure/main.bicep b/.azure/infrastructure/main.bicep index 4db077777..6cefba29d 100644 --- a/.azure/infrastructure/main.bicep +++ b/.azure/infrastructure/main.bicep @@ -19,22 +19,25 @@ param sourceKeyVaultResourceGroup string @minLength(3) param sourceKeyVaultName string -import {Sku as KeyVaultSku} from '../modules/keyvault/create.bicep' +import { Sku as KeyVaultSku } from '../modules/keyvault/create.bicep' param keyVaultSku KeyVaultSku -import {Sku as AppConfigurationSku} from '../modules/appConfiguration/create.bicep' +import { Sku as AppConfigurationSku } from '../modules/appConfiguration/create.bicep' param appConfigurationSku AppConfigurationSku -import {Sku as AppInsightsSku} from '../modules/applicationInsights/create.bicep' +import { Sku as AppInsightsSku } from '../modules/applicationInsights/create.bicep' param appInsightsSku AppInsightsSku -import {Sku as SlackNotifierSku} from '../modules/functionApp/slackNotifier.bicep' +import { Sku as SlackNotifierSku } from '../modules/functionApp/slackNotifier.bicep' param slackNotifierSku SlackNotifierSku -import {Sku as PostgresSku} from '../modules/postgreSql/create.bicep' +import { Sku as PostgresSku } from '../modules/postgreSql/create.bicep' param postgresSku PostgresSku -import {Sku as RedisSku} from '../modules/redis/main.bicep' +import { Sku as ServiceBusSku } from '../modules/serviceBus/main.bicep' +param serviceBusSku ServiceBusSku + +import { Sku as RedisSku } from '../modules/redis/main.bicep' param redisSku RedisSku @minLength(1) param redisVersion string @@ -84,6 +87,16 @@ module appInsights '../modules/applicationInsights/create.bicep' = { } } +module serviceBus '../modules/serviceBus/main.bicep' = { + scope: resourceGroup + name: 'serviceBus' + params: { + namePrefix: namePrefix + location: location + sku: serviceBusSku + } +} + // ####################################### // Create references to existing resources // ####################################### @@ -112,7 +125,9 @@ module postgresql '../modules/postgreSql/create.bicep' = { environmentKeyVaultName: environmentKeyVault.outputs.name srcKeyVault: srcKeyVault srcSecretName: 'dialogportenPgAdminPassword${environment}' - administratorLoginPassword: contains(keyVaultSourceKeys, 'dialogportenPgAdminPassword${environment}') ? srcKeyVaultResource.getSecret('dialogportenPgAdminPassword${environment}') : secrets.dialogportenPgAdminPassword + administratorLoginPassword: contains(keyVaultSourceKeys, 'dialogportenPgAdminPassword${environment}') + ? srcKeyVaultResource.getSecret('dialogportenPgAdminPassword${environment}') + : secrets.dialogportenPgAdminPassword sku: postgresSku } } @@ -145,7 +160,8 @@ module copyEnvironmentSecrets '../modules/keyvault/copySecrets.bicep' = { module copyCrossEnvironmentSecrets '../modules/keyvault/copySecrets.bicep' = { scope: resourceGroup name: 'copyCrossEnvironmentSecrets' - params: { srcKeyVaultKeys: keyVaultSourceKeys + params: { + srcKeyVaultKeys: keyVaultSourceKeys srcKeyVaultName: secrets.sourceKeyVaultName srcKeyVaultRGNName: secrets.sourceKeyVaultResourceGroup srcKeyVaultSubId: secrets.sourceKeyVaultSubscriptionId @@ -181,7 +197,7 @@ module appInsightsReaderAccessPolicy '../modules/applicationInsights/addReaderRo name: 'appInsightsReaderAccessPolicy' params: { appInsightsName: appInsights.outputs.appInsightsName - principalIds: [ slackNotifier.outputs.functionAppPrincipalId ] + principalIds: [slackNotifier.outputs.functionAppPrincipalId] } } @@ -212,7 +228,7 @@ module keyVaultReaderAccessPolicy '../modules/keyvault/addReaderRoles.bicep' = { name: 'keyVaultReaderAccessPolicyFunctions' params: { keyvaultName: environmentKeyVault.outputs.name - principalIds: [ slackNotifier.outputs.functionAppPrincipalId ] + principalIds: [slackNotifier.outputs.functionAppPrincipalId] } } diff --git a/.azure/infrastructure/production.bicepparam b/.azure/infrastructure/production.bicepparam index 320a69244..288bd3d98 100644 --- a/.azure/infrastructure/production.bicepparam +++ b/.azure/infrastructure/production.bicepparam @@ -38,3 +38,9 @@ param redisSku = { family: 'C' capacity: 1 } + +param serviceBusSku = { + name: 'Standard' + tier: 'Standard' + capacity: 1 +} diff --git a/.azure/infrastructure/soak.bicepparam b/.azure/infrastructure/soak.bicepparam index dd737f9c1..3328cdac7 100644 --- a/.azure/infrastructure/soak.bicepparam +++ b/.azure/infrastructure/soak.bicepparam @@ -38,3 +38,9 @@ param redisSku = { family: 'C' capacity: 1 } + +param serviceBusSku = { + name: 'Standard' + tier: 'Standard' + capacity: 1 +} diff --git a/.azure/infrastructure/staging.bicepparam b/.azure/infrastructure/staging.bicepparam index 2f8855a55..946a8cd19 100644 --- a/.azure/infrastructure/staging.bicepparam +++ b/.azure/infrastructure/staging.bicepparam @@ -38,3 +38,9 @@ param redisSku = { family: 'C' capacity: 1 } + +param serviceBusSku = { + name: 'Standard' + tier: 'Standard' + capacity: 1 +} diff --git a/.azure/infrastructure/test.bicepparam b/.azure/infrastructure/test.bicepparam index fa52bb031..f727305d5 100644 --- a/.azure/infrastructure/test.bicepparam +++ b/.azure/infrastructure/test.bicepparam @@ -38,3 +38,9 @@ param redisSku = { family: 'C' capacity: 1 } + +param serviceBusSku = { + name: 'Standard' + tier: 'Standard' + capacity: 1 +} diff --git a/.azure/modules/serviceBus/main.bicep b/.azure/modules/serviceBus/main.bicep index 1406e66da..2150534c3 100644 --- a/.azure/modules/serviceBus/main.bicep +++ b/.azure/modules/serviceBus/main.bicep @@ -4,33 +4,36 @@ param location string @export() type Sku = { name: 'Basic' | 'Standard' | 'Premium' + tier: 'Basic' | 'Standard' | 'Premium' + @minValue(1) + capacity: int } param sku Sku // todo: add a service bus here pls -resource serviceBusNamespace 'Microsoft.ServiceBus/namespaces@2023-03-01' = { - name: 'myServiceBusNamespace' - location: resourceGroup().location +resource serviceBusNamespace 'Microsoft.ServiceBus/namespaces@2022-10-01-preview' = { + name: '${namePrefix}-service-bus' + location: location sku: sku - properties: { - maximumThroughputUnits: 0 // Set according to your needs + identity: { + type: 'SystemAssigned' } + properties: {} } -resource serviceBusQueue 'Microsoft.ServiceBus/namespaces/queues@2023-03-01' = { - name: 'myQueue' +resource serviceBusTopic 'Microsoft.ServiceBus/namespaces/topics@2022-10-01-preview' = { parent: serviceBusNamespace + // todo: resolve what topics to create + name: '${namePrefix}-service-bus-topic' properties: { - lockDuration: 'PT5M' - maxSizeInMegabytes: 1024 - requiresDuplicateDetection: true - requiresSession: false - defaultMessageTimeToLive: 'P14D' - deadLetteringOnMessageExpiration: true - duplicateDetectionHistoryTimeWindow: 'PT10M' - maxDeliveryCount: 10 - enableBatchedOperations: true - autoDeleteOnIdle: 'P10675199DT2H48M5.4775807S' // Set to never auto-delete + enablePartitioning: false + enableExpress: false } } +resource serviceBusSubscription 'Microsoft.ServiceBus/namespaces/topics/subscriptions@2022-10-01-preview' = { + parent: serviceBusTopic + // todo: resolve what subscriptions to create + name: '${namePrefix}-service-bus-subscription' + properties: {} +} From 457ba8b3a70843eaa4100a9c17507783dc76e1d6 Mon Sep 17 00:00:00 2001 From: Are Almaas Date: Tue, 9 Apr 2024 12:41:46 +0200 Subject: [PATCH 3/3] cleanup --- .azure/modules/serviceBus/main.bicep | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/.azure/modules/serviceBus/main.bicep b/.azure/modules/serviceBus/main.bicep index 2150534c3..286699926 100644 --- a/.azure/modules/serviceBus/main.bicep +++ b/.azure/modules/serviceBus/main.bicep @@ -10,7 +10,6 @@ type Sku = { } param sku Sku -// todo: add a service bus here pls resource serviceBusNamespace 'Microsoft.ServiceBus/namespaces@2022-10-01-preview' = { name: '${namePrefix}-service-bus' location: location @@ -20,20 +19,3 @@ resource serviceBusNamespace 'Microsoft.ServiceBus/namespaces@2022-10-01-preview } properties: {} } - -resource serviceBusTopic 'Microsoft.ServiceBus/namespaces/topics@2022-10-01-preview' = { - parent: serviceBusNamespace - // todo: resolve what topics to create - name: '${namePrefix}-service-bus-topic' - properties: { - enablePartitioning: false - enableExpress: false - } -} - -resource serviceBusSubscription 'Microsoft.ServiceBus/namespaces/topics/subscriptions@2022-10-01-preview' = { - parent: serviceBusTopic - // todo: resolve what subscriptions to create - name: '${namePrefix}-service-bus-subscription' - properties: {} -}