From ca2b1a0b8c928f3666665c7fc04e32795a8a38ed Mon Sep 17 00:00:00 2001 From: Are Almaas Date: Mon, 21 Oct 2024 16:10:29 +0200 Subject: [PATCH] feat(azure): add availability test for apim --- .azure/infrastructure/main.bicep | 15 ++++++ .azure/infrastructure/prod.bicepparam | 2 + .azure/infrastructure/staging.bicepparam | 2 + .azure/infrastructure/test.bicepparam | 2 + .azure/infrastructure/yt01.bicepparam | 2 + .../availabilityTest.bicep | 49 +++++++++++++++++++ .../modules/applicationInsights/create.bicep | 1 + 7 files changed, 73 insertions(+) create mode 100644 .azure/modules/applicationInsights/availabilityTest.bicep diff --git a/.azure/infrastructure/main.bicep b/.azure/infrastructure/main.bicep index d46f53a18..576a1861b 100644 --- a/.azure/infrastructure/main.bicep +++ b/.azure/infrastructure/main.bicep @@ -39,6 +39,9 @@ param sourceKeyVaultSshJumperSshPublicKey string @description('The object ID of the group to assign the Admin Login role for SSH Jumper') param sshJumperAdminLoginGroupObjectId string +@description('The URL of the APIM instance') +param apimUrl string + import { Sku as KeyVaultSku } from '../modules/keyvault/create.bicep' param keyVaultSku KeyVaultSku @@ -117,6 +120,18 @@ module appInsights '../modules/applicationInsights/create.bicep' = { } } +module apimAvailabilityTest '../modules/applicationInsights/availabilityTest.bicep' = { + scope: resourceGroup + name: 'apimAvailabilityTest' + params: { + name: '${namePrefix}-dialogporten-health-test' + location: location + tags: tags + appInsightsId: appInsights.outputs.appInsightsId + url: '${apimUrl}/health/deep' + } +} + module serviceBus '../modules/serviceBus/main.bicep' = { scope: resourceGroup name: 'serviceBus' diff --git a/.azure/infrastructure/prod.bicepparam b/.azure/infrastructure/prod.bicepparam index 15ea338be..2eb2d4c17 100644 --- a/.azure/infrastructure/prod.bicepparam +++ b/.azure/infrastructure/prod.bicepparam @@ -48,3 +48,5 @@ param serviceBusSku = { // Altinn Product Dialogporten: Developers Prod param sshJumperAdminLoginGroupObjectId = 'a94de4bf-0a83-4d30-baba-0c6a7365571c' + +param apimUrl = 'https://platform.altinn.no/dialogporten' diff --git a/.azure/infrastructure/staging.bicepparam b/.azure/infrastructure/staging.bicepparam index 4f9f91688..40ebabf97 100644 --- a/.azure/infrastructure/staging.bicepparam +++ b/.azure/infrastructure/staging.bicepparam @@ -47,3 +47,5 @@ param serviceBusSku = { } // Altinn Product Dialogporten: Developers Prod param sshJumperAdminLoginGroupObjectId = 'a94de4bf-0a83-4d30-baba-0c6a7365571c' + +param apimUrl = 'https://platform.tt02.altinn.no/dialogporten' diff --git a/.azure/infrastructure/test.bicepparam b/.azure/infrastructure/test.bicepparam index 4efab5825..ce73b3286 100644 --- a/.azure/infrastructure/test.bicepparam +++ b/.azure/infrastructure/test.bicepparam @@ -48,3 +48,5 @@ param serviceBusSku = { // Altinn Product Dialogporten: Developers Dev param sshJumperAdminLoginGroupObjectId = 'c12e51e3-5cbd-4229-8a31-5394c423fb5f' + +param apimUrl = 'https://altinn-dev-api.azure-api.net/dialogporten' diff --git a/.azure/infrastructure/yt01.bicepparam b/.azure/infrastructure/yt01.bicepparam index 26c80d77b..0e40d97a0 100644 --- a/.azure/infrastructure/yt01.bicepparam +++ b/.azure/infrastructure/yt01.bicepparam @@ -47,3 +47,5 @@ param serviceBusSku = { } // Altinn Product Dialogporten: Developers Dev param sshJumperAdminLoginGroupObjectId = 'c12e51e3-5cbd-4229-8a31-5394c423fb5f' + +param apimUrl = 'https://platform.yt01.altinn.cloud/dialogporten' diff --git a/.azure/modules/applicationInsights/availabilityTest.bicep b/.azure/modules/applicationInsights/availabilityTest.bicep new file mode 100644 index 000000000..d254c8090 --- /dev/null +++ b/.azure/modules/applicationInsights/availabilityTest.bicep @@ -0,0 +1,49 @@ +@description('The name of the availability test') +param name string + +@description('The location where the resources will be deployed') +param location string + +@description('Tags to apply to resources') +param tags object + +@description('The ID of the Application Insights resource') +param appInsightsId string + + +@description('The URL of the availability test') +param url string + +resource availabilityTest 'Microsoft.Insights/webtests@2022-06-15' = { + name: name + location: location + tags: union(tags, { + 'hidden-link:${appInsightsId}': 'Resource' + }) + kind: 'standard' + properties: { + Enabled: true + SyntheticMonitorId: name + Name: name + Description: 'Availability test for ${name}' + Frequency: 120 // Run test every 2 minutes + Timeout: 60 // 1 minute timeout + Kind: 'standard' + RetryEnabled: true + Locations: [ + { Id: 'emea-nl-ams-azr' } // Amsterdam + { Id: 'emea-se-sto-edge' } // Stockholm + { Id: 'emea-gb-db3-azr' } // Dublin + ] + Request: { + RequestUrl: url + HttpVerb: 'GET' + ParseDependentRequests: false + } + ValidationRules: { + ExpectedHttpStatusCode: 200 + SSLCheck: true + SSLCertRemainingLifetimeCheck: 7 + } + } +} diff --git a/.azure/modules/applicationInsights/create.bicep b/.azure/modules/applicationInsights/create.bicep index dcac7fb1c..fdc24e54b 100644 --- a/.azure/modules/applicationInsights/create.bicep +++ b/.azure/modules/applicationInsights/create.bicep @@ -53,3 +53,4 @@ resource appInsights 'Microsoft.Insights/components@2020-02-02' = { output connectionString string = appInsights.properties.ConnectionString output appInsightsWorkspaceName string = appInsightsWorkspace.name output appInsightsName string = appInsights.name +output appInsightsId string = appInsights.id