From 63ad050f860948a8760b5535761947fe15775636 Mon Sep 17 00:00:00 2001 From: Benjamin Chiverton Date: Wed, 26 Jun 2024 14:39:44 +0100 Subject: [PATCH 01/24] Add container app for monitoring --- .../Properties/launchSettings.json | 3 +- .../Properties/launchSettings.json | 3 +- terraform/instance/container_apps.tf | 65 +++++++++++++++++++ 3 files changed, 69 insertions(+), 2 deletions(-) diff --git a/src/Api/Company.Api/Properties/launchSettings.json b/src/Api/Company.Api/Properties/launchSettings.json index e41efe45..a6538bde 100644 --- a/src/Api/Company.Api/Properties/launchSettings.json +++ b/src/Api/Company.Api/Properties/launchSettings.json @@ -6,7 +6,8 @@ "launchBrowser": true, "launchUrl": "swagger", "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" + "ASPNETCORE_ENVIRONMENT": "Development", + "DOTNET_ROLL_FORWARD": "LatestMinor" }, "applicationUrl": "https://localhost:5001" } diff --git a/src/Website/Company.Website/Properties/launchSettings.json b/src/Website/Company.Website/Properties/launchSettings.json index 9ed9304b..a0bff924 100644 --- a/src/Website/Company.Website/Properties/launchSettings.json +++ b/src/Website/Company.Website/Properties/launchSettings.json @@ -6,7 +6,8 @@ "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", "applicationUrl": "https://localhost:6001;http://localhost:6000", "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" + "ASPNETCORE_ENVIRONMENT": "Development", + "DOTNET_ROLL_FORWARD": "LatestMinor" } } } diff --git a/terraform/instance/container_apps.tf b/terraform/instance/container_apps.tf index 952e1883..454f7ea6 100644 --- a/terraform/instance/container_apps.tf +++ b/terraform/instance/container_apps.tf @@ -73,3 +73,68 @@ resource "azurerm_container_app" "website" { ] } } + +resource "azurerm_container_app" "monitoring" { + name = "${var.name}-website" + container_app_environment_id = azurerm_container_app_environment.apps.id + resource_group_name = azurerm_resource_group.instance.name + revision_mode = "Single" + + template { + container { + name = "aspire-dashboard" + image = "onlinestorecontainerregistry.azurecr.io/dotnet/aspire-dashboard:8.0.0" + cpu = 0.25 + memory = "0.5Gi" + } + max_replicas = 1 + } + + ingress { + external_enabled = true + transport = "http" + target_port = 18888 + traffic_weight { + latest_revision = true + percentage = 100 + } + } + + registry { + server = "onlinestorecontainerregistry.azurecr.io" + username = var.acr_username + password_secret_name = var.acr_password + } + + lifecycle { + ignore_changes = [ + template[0].container[0], + registry, + secret, + ] + } +} + +# update the container app with extra additionalPortMappings, as this is not supported by the existing TF provider +resource "azapi_update_resource" "container_app_api" { + type = "Microsoft.App/containerApps@2023-11-02-preview" + resource_id = azurerm_container_app.monitoring.id + + body = jsonencode({ + properties = { + configuration = { + ingress = { + additionalPortMappings = [18889] + } + } + } + }) + + depends_on = [ + azurerm_container_app.monitoring, + ] + + lifecycle { + replace_triggered_by = [azurerm_container_app.monitoring] + } +} From cc64bb8bb5b429e1a1e9b1cb2960e31dc6c24c79 Mon Sep 17 00:00:00 2001 From: Benjamin Chiverton Date: Wed, 26 Jun 2024 14:51:55 +0100 Subject: [PATCH 02/24] Add azapi --- terraform/instance/.terraform.lock.hcl | 20 ++++++++++++++++++++ terraform/instance/main.tf | 4 ++++ 2 files changed, 24 insertions(+) diff --git a/terraform/instance/.terraform.lock.hcl b/terraform/instance/.terraform.lock.hcl index ba46f512..6bc9c8e3 100644 --- a/terraform/instance/.terraform.lock.hcl +++ b/terraform/instance/.terraform.lock.hcl @@ -1,6 +1,26 @@ # This file is maintained automatically by "terraform init". # Manual edits may be lost in future updates. +provider "registry.terraform.io/azure/azapi" { + version = "1.13.1" + constraints = "1.13.1" + hashes = [ + "h1:gb4dIyLtbw3ctTjZGcb2L/weFP1tzUalf0MKLAh/Bbc=", + "zh:1f2aceddd67ceeb82a75c2f15dc01e54781e9aed5968507dbc29590c165b2e2b", + "zh:397f0bfbac899d48e23cecf38d362c27562150aa20b19157b5bd370b8e6801ee", + "zh:652263b7d00623684e29ef7b8ff285a17c5bd7cc8ba7d22967c66d0b3a3c568a", + "zh:652c53320a41434942877515780296a1509be03f32d54e60178f39200f960a67", + "zh:666426faf686401e54ec09fe06e9d7c06a6455ec398764f70558440c73aeb7f9", + "zh:6aa91ae8ba78f2494f99b4c99e66d15ed0b14d735cd1f77adc12ff9dfa075807", + "zh:a529e5a13c37d1805c469227f08cdbe7527d04dd64d18709d26627c6a0b588b1", + "zh:a589c049205e8e5bf94a13d56b28f400d908ad27e13e16df64408ee82eb8a0ff", + "zh:a9a50defdee230f315f74be6c77ff104fe2610a1b3ad6b87326f555e80d13b18", + "zh:ba49ef70d96e13795e2dbffd6cb2ff976dfe84e0373a5971ebe3b4c9c9b7af60", + "zh:d3ed50efe5f8c80d3d7d464ab9a13ccf82440d871c9ce3032ce476845364c6b9", + "zh:e3eb48ee8c36ee4f81850d8a21fc59b81886c729d7c3b7adece4a25f355bed2f", + ] +} + provider "registry.terraform.io/hashicorp/azurerm" { version = "3.109.0" constraints = "3.109.0" diff --git a/terraform/instance/main.tf b/terraform/instance/main.tf index d8257b68..ca899c09 100644 --- a/terraform/instance/main.tf +++ b/terraform/instance/main.tf @@ -4,6 +4,10 @@ terraform { source = "hashicorp/azurerm" version = "=3.109.0" } + azapi = { + source = "azure/azapi" + version = "=1.13.1" + } } backend "azurerm" { resource_group_name = "onlinestoretfstate" From f21a9ef4da744b244e3e1a58f2e7454bbe625e80 Mon Sep 17 00:00:00 2001 From: Benjamin Chiverton Date: Wed, 26 Jun 2024 14:57:30 +0100 Subject: [PATCH 03/24] Update container_apps.tf --- terraform/instance/container_apps.tf | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/terraform/instance/container_apps.tf b/terraform/instance/container_apps.tf index 454f7ea6..4d9b48b0 100644 --- a/terraform/instance/container_apps.tf +++ b/terraform/instance/container_apps.tf @@ -103,7 +103,12 @@ resource "azurerm_container_app" "monitoring" { registry { server = "onlinestorecontainerregistry.azurecr.io" username = var.acr_username - password_secret_name = var.acr_password + password_secret_name = "acr_password" + } + + secret { + name = "acr_password" + value = var.acr_password } lifecycle { From 615b3603c1b4e0197a46ff67309a4f27d47ae30c Mon Sep 17 00:00:00 2001 From: Benjamin Chiverton Date: Wed, 26 Jun 2024 14:58:31 +0100 Subject: [PATCH 04/24] Update container_apps.tf --- terraform/instance/container_apps.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/terraform/instance/container_apps.tf b/terraform/instance/container_apps.tf index 4d9b48b0..b1243935 100644 --- a/terraform/instance/container_apps.tf +++ b/terraform/instance/container_apps.tf @@ -103,11 +103,11 @@ resource "azurerm_container_app" "monitoring" { registry { server = "onlinestorecontainerregistry.azurecr.io" username = var.acr_username - password_secret_name = "acr_password" + password_secret_name = "acr-password" } secret { - name = "acr_password" + name = "acr-password" value = var.acr_password } From 5e4fdc8a8cf33ff41b428d4ae7912158871f47bb Mon Sep 17 00:00:00 2001 From: Benjamin Chiverton Date: Wed, 26 Jun 2024 15:00:48 +0100 Subject: [PATCH 05/24] Update container_apps.tf --- terraform/instance/container_apps.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terraform/instance/container_apps.tf b/terraform/instance/container_apps.tf index b1243935..c938a498 100644 --- a/terraform/instance/container_apps.tf +++ b/terraform/instance/container_apps.tf @@ -75,7 +75,7 @@ resource "azurerm_container_app" "website" { } resource "azurerm_container_app" "monitoring" { - name = "${var.name}-website" + name = "${var.name}-monitoring" container_app_environment_id = azurerm_container_app_environment.apps.id resource_group_name = azurerm_resource_group.instance.name revision_mode = "Single" From 29242d15fffd947c198b3a55d59b861014c8ac37 Mon Sep 17 00:00:00 2001 From: Benjamin Chiverton Date: Wed, 26 Jun 2024 15:06:39 +0100 Subject: [PATCH 06/24] Update container_apps.tf --- terraform/instance/container_apps.tf | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/terraform/instance/container_apps.tf b/terraform/instance/container_apps.tf index c938a498..3bb9080e 100644 --- a/terraform/instance/container_apps.tf +++ b/terraform/instance/container_apps.tf @@ -129,7 +129,11 @@ resource "azapi_update_resource" "container_app_api" { properties = { configuration = { ingress = { - additionalPortMappings = [18889] + additionalPortMappings = { + exposedPort: 18889, + targetPort: 18889, + external: false + } } } } From d123a0226ff44ecfb5312f3949ba574a99d12947 Mon Sep 17 00:00:00 2001 From: Benjamin Chiverton Date: Wed, 26 Jun 2024 15:08:53 +0100 Subject: [PATCH 07/24] Update container_apps.tf --- terraform/instance/container_apps.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/terraform/instance/container_apps.tf b/terraform/instance/container_apps.tf index 3bb9080e..c3036aa4 100644 --- a/terraform/instance/container_apps.tf +++ b/terraform/instance/container_apps.tf @@ -129,11 +129,11 @@ resource "azapi_update_resource" "container_app_api" { properties = { configuration = { ingress = { - additionalPortMappings = { + additionalPortMappings = [{ exposedPort: 18889, targetPort: 18889, external: false - } + }] } } } From 6e821c7b710f8947ad3a4c1995aff89eaa4bc81e Mon Sep 17 00:00:00 2001 From: Benjamin Chiverton Date: Wed, 26 Jun 2024 16:05:55 +0100 Subject: [PATCH 08/24] Update container_apps.tf --- terraform/instance/container_apps.tf | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/terraform/instance/container_apps.tf b/terraform/instance/container_apps.tf index c3036aa4..9af874ad 100644 --- a/terraform/instance/container_apps.tf +++ b/terraform/instance/container_apps.tf @@ -86,6 +86,10 @@ resource "azurerm_container_app" "monitoring" { image = "onlinestorecontainerregistry.azurecr.io/dotnet/aspire-dashboard:8.0.0" cpu = 0.25 memory = "0.5Gi" + env { + name = "DOTNET_DASHBOARD_UNSECURED_ALLOW_ANONYMOUS" + value = "true" + } } max_replicas = 1 } @@ -130,9 +134,9 @@ resource "azapi_update_resource" "container_app_api" { configuration = { ingress = { additionalPortMappings = [{ - exposedPort: 18889, - targetPort: 18889, - external: false + exposedPort = 18889, + targetPort = 18889, + external = false }] } } From 4038c4976eeea20e44245260f43bfd6daff14a61 Mon Sep 17 00:00:00 2001 From: Benjamin Chiverton Date: Wed, 26 Jun 2024 16:08:53 +0100 Subject: [PATCH 09/24] Update container_apps.tf --- terraform/instance/container_apps.tf | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/terraform/instance/container_apps.tf b/terraform/instance/container_apps.tf index 9af874ad..c7dbfc1a 100644 --- a/terraform/instance/container_apps.tf +++ b/terraform/instance/container_apps.tf @@ -132,6 +132,10 @@ resource "azapi_update_resource" "container_app_api" { body = jsonencode({ properties = { configuration = { + secrets = [{ + name = "acr-password" + value = var.acr_password + }] ingress = { additionalPortMappings = [{ exposedPort = 18889, From 659862d5800656fa4a51c61eeff19a3713849b3f Mon Sep 17 00:00:00 2001 From: Benjamin Chiverton Date: Wed, 26 Jun 2024 16:12:57 +0100 Subject: [PATCH 10/24] Update apps to use container_app_monitoring_fqdn --- .github/workflows/instance-deploy-prod.yml | 6 +++--- .github/workflows/instance-deploy-test.yml | 10 +++++----- terraform/instance/main.tf | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/instance-deploy-prod.yml b/.github/workflows/instance-deploy-prod.yml index b47ef39b..38c2d62f 100644 --- a/.github/workflows/instance-deploy-prod.yml +++ b/.github/workflows/instance-deploy-prod.yml @@ -102,7 +102,7 @@ jobs: terraform -chdir=instance output -raw container_app_api_fqdn > terraform-outputs/container_app_api_fqdn.txt terraform -chdir=instance output -raw container_app_website_fqdn > terraform-outputs/container_app_website_fqdn.txt # -raw cannot handle null values - https://github.com/hashicorp/terraform/issues/32384 - terraform -chdir=instance show -json | jq -r '.values.outputs.container_instance_monitoring_fqdn.value // ""' > container_instance_monitoring_fqdn.txt + terraform -chdir=instance show -json | jq -r '.values.outputs.container_app_monitoring_fqdn.value // ""' > container_app_monitoring_fqdn.txt - name: Upload terraform outputs for deploy job uses: actions/upload-artifact@v3 with: @@ -127,7 +127,7 @@ jobs: echo "resource_group_name=$(cat resource_group_name.txt)" >> $GITHUB_ENV echo "container_app_api_fqdn=$(cat container_app_api_fqdn.txt)" >> $GITHUB_ENV echo "container_app_website_fqdn=$(cat container_app_website_fqdn.txt)" >> $GITHUB_ENV - echo "container_instance_monitoring_fqdn=$(cat container_instance_monitoring_fqdn.txt)" >> $GITHUB_ENV + echo "container_app_monitoring_fqdn=$(cat container_app_monitoring_fqdn.txt)" >> $GITHUB_ENV - name: Login via Azure CLI uses: azure/login@v1 with: @@ -143,7 +143,7 @@ jobs: location: 'East US' resourceGroup: ${{ env.resource_group_name }} targetPort: 8080 - environmentVariables: "OTEL_EXPORTER_OTLP_ENDPOINT=http://${{ env.container_instance_monitoring_fqdn }}:18889" + environmentVariables: "OTEL_EXPORTER_OTLP_ENDPOINT=http://${{ env.container_app_monitoring_fqdn }}:18889" - name: Deploy website uses: azure/container-apps-deploy-action@v1 with: diff --git a/.github/workflows/instance-deploy-test.yml b/.github/workflows/instance-deploy-test.yml index 8ae9f1aa..2f564b0c 100644 --- a/.github/workflows/instance-deploy-test.yml +++ b/.github/workflows/instance-deploy-test.yml @@ -77,9 +77,9 @@ jobs: terraform -chdir=instance output -raw resource_group_name > terraform-outputs/resource_group_name.txt terraform -chdir=instance output -raw container_app_api_fqdn > terraform-outputs/container_app_api_fqdn.txt terraform -chdir=instance output -raw container_app_website_fqdn > terraform-outputs/container_app_website_fqdn.txt - terraform -chdir=instance output -raw container_instance_monitoring_fqdn > terraform-outputs/container_instance_monitoring_fqdn.txt + terraform -chdir=instance output -raw container_app_monitoring_fqdn > terraform-outputs/container_app_monitoring_fqdn.txt # -raw cannot handle null values - https://github.com/hashicorp/terraform/issues/32384 - terraform -chdir=instance show -json | jq -r '.values.outputs.container_instance_monitoring_fqdn.value // ""' > container_instance_monitoring_fqdn.txt + terraform -chdir=instance show -json | jq -r '.values.outputs.container_app_monitoring_fqdn.value // ""' > container_app_monitoring_fqdn.txt - name: Upload terraform outputs for deploy job uses: actions/upload-artifact@v3 with: @@ -104,7 +104,7 @@ jobs: echo "resource_group_name=$(cat resource_group_name.txt)" >> $GITHUB_ENV echo "container_app_api_fqdn=$(cat container_app_api_fqdn.txt)" >> $GITHUB_ENV echo "container_app_website_fqdn=$(cat container_app_website_fqdn.txt)" >> $GITHUB_ENV - echo "container_instance_monitoring_fqdn=$(cat container_instance_monitoring_fqdn.txt)" >> $GITHUB_ENV + echo "container_app_monitoring_fqdn=$(cat container_app_monitoring_fqdn.txt)" >> $GITHUB_ENV - name: Login via Azure CLI uses: azure/login@v1 with: @@ -120,7 +120,7 @@ jobs: location: 'East US' resourceGroup: ${{ env.resource_group_name }} targetPort: 8080 - environmentVariables: "OTEL_EXPORTER_OTLP_ENDPOINT=http://${{ env.container_instance_monitoring_fqdn }}:18889" + environmentVariables: "OTEL_EXPORTER_OTLP_ENDPOINT=http://${{ env.container_app_monitoring_fqdn }}:18889" - name: Deploy website uses: azure/container-apps-deploy-action@v1 with: @@ -144,7 +144,7 @@ jobs: const output = `### Test environment information #### 🔗[Visit website](https://${{ env.container_app_website_fqdn }}/) #### 🔗[Visit API](https://${{ env.container_app_api_fqdn }}/swagger/) - #### 🔗[Visit monitoring UI](http://${{ env.container_instance_monitoring_fqdn }}:18888) + #### 🔗[Visit monitoring UI](http://${{ env.container_app_monitoring_fqdn }}:18888) *Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Working Directory: \`${{ env.tf_actions_working_dir }}\`, Workflow: \`${{ github.workflow }}\`*`; diff --git a/terraform/instance/main.tf b/terraform/instance/main.tf index ca899c09..f792457d 100644 --- a/terraform/instance/main.tf +++ b/terraform/instance/main.tf @@ -43,7 +43,7 @@ output "container_app_website_fqdn" { sensitive = false } -output "container_instance_monitoring_fqdn" { - value = one(azurerm_container_group.monitoring[*].fqdn) +output "container_app_monitoring_fqdn" { + value = azurerm_container_app.monitoring.ingress[0].fqdn sensitive = false } From bbbb6169f7ef9814770f26411a9b2023fc187d01 Mon Sep 17 00:00:00 2001 From: Benjamin Chiverton Date: Wed, 26 Jun 2024 16:23:30 +0100 Subject: [PATCH 11/24] do not ignore changes on monitoring app --- .github/workflows/instance-deploy-test.yml | 2 +- terraform/instance/container_apps.tf | 8 -------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/.github/workflows/instance-deploy-test.yml b/.github/workflows/instance-deploy-test.yml index 2f564b0c..94a456b6 100644 --- a/.github/workflows/instance-deploy-test.yml +++ b/.github/workflows/instance-deploy-test.yml @@ -144,7 +144,7 @@ jobs: const output = `### Test environment information #### 🔗[Visit website](https://${{ env.container_app_website_fqdn }}/) #### 🔗[Visit API](https://${{ env.container_app_api_fqdn }}/swagger/) - #### 🔗[Visit monitoring UI](http://${{ env.container_app_monitoring_fqdn }}:18888) + #### 🔗[Visit monitoring UI](http://${{ env.container_app_monitoring_fqdn }}) *Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Working Directory: \`${{ env.tf_actions_working_dir }}\`, Workflow: \`${{ github.workflow }}\`*`; diff --git a/terraform/instance/container_apps.tf b/terraform/instance/container_apps.tf index c7dbfc1a..886069f8 100644 --- a/terraform/instance/container_apps.tf +++ b/terraform/instance/container_apps.tf @@ -114,14 +114,6 @@ resource "azurerm_container_app" "monitoring" { name = "acr-password" value = var.acr_password } - - lifecycle { - ignore_changes = [ - template[0].container[0], - registry, - secret, - ] - } } # update the container app with extra additionalPortMappings, as this is not supported by the existing TF provider From 9eb93b817cb4f883c86e9cc84653129d4c955478 Mon Sep 17 00:00:00 2001 From: Benjamin Chiverton Date: Wed, 26 Jun 2024 16:29:34 +0100 Subject: [PATCH 12/24] Update container_apps.tf --- terraform/instance/container_apps.tf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/terraform/instance/container_apps.tf b/terraform/instance/container_apps.tf index 886069f8..b11eee66 100644 --- a/terraform/instance/container_apps.tf +++ b/terraform/instance/container_apps.tf @@ -132,7 +132,8 @@ resource "azapi_update_resource" "container_app_api" { additionalPortMappings = [{ exposedPort = 18889, targetPort = 18889, - external = false + external = false, + allowInsecure = true }] } } From 3a103b146f99fc994ff668c03f3ebdc3dd1b1949 Mon Sep 17 00:00:00 2001 From: Benjamin Chiverton Date: Wed, 26 Jun 2024 16:32:52 +0100 Subject: [PATCH 13/24] Update container_apps.tf --- terraform/instance/container_apps.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/terraform/instance/container_apps.tf b/terraform/instance/container_apps.tf index b11eee66..6778246a 100644 --- a/terraform/instance/container_apps.tf +++ b/terraform/instance/container_apps.tf @@ -98,6 +98,7 @@ resource "azurerm_container_app" "monitoring" { external_enabled = true transport = "http" target_port = 18888 + allow_insecure_connections = true traffic_weight { latest_revision = true percentage = 100 @@ -132,8 +133,7 @@ resource "azapi_update_resource" "container_app_api" { additionalPortMappings = [{ exposedPort = 18889, targetPort = 18889, - external = false, - allowInsecure = true + external = false }] } } From 38ca1fcd17f74516ce6a201a88f562521788382a Mon Sep 17 00:00:00 2001 From: Benjamin Chiverton Date: Wed, 26 Jun 2024 16:44:16 +0100 Subject: [PATCH 14/24] Use https --- .github/workflows/instance-deploy-prod.yml | 2 +- .github/workflows/instance-deploy-test.yml | 4 ++-- src/Api/Company.Api/appsettings.Development.json | 2 +- terraform/instance/container_apps.tf | 1 - 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/instance-deploy-prod.yml b/.github/workflows/instance-deploy-prod.yml index 38c2d62f..1cf3e5a8 100644 --- a/.github/workflows/instance-deploy-prod.yml +++ b/.github/workflows/instance-deploy-prod.yml @@ -143,7 +143,7 @@ jobs: location: 'East US' resourceGroup: ${{ env.resource_group_name }} targetPort: 8080 - environmentVariables: "OTEL_EXPORTER_OTLP_ENDPOINT=http://${{ env.container_app_monitoring_fqdn }}:18889" + environmentVariables: "OTEL_EXPORTER_OTLP_ENDPOINT=https://${{ env.container_app_monitoring_fqdn }}:18889" - name: Deploy website uses: azure/container-apps-deploy-action@v1 with: diff --git a/.github/workflows/instance-deploy-test.yml b/.github/workflows/instance-deploy-test.yml index 94a456b6..bc91c373 100644 --- a/.github/workflows/instance-deploy-test.yml +++ b/.github/workflows/instance-deploy-test.yml @@ -120,7 +120,7 @@ jobs: location: 'East US' resourceGroup: ${{ env.resource_group_name }} targetPort: 8080 - environmentVariables: "OTEL_EXPORTER_OTLP_ENDPOINT=http://${{ env.container_app_monitoring_fqdn }}:18889" + environmentVariables: "OTEL_EXPORTER_OTLP_ENDPOINT=https://${{ env.container_app_monitoring_fqdn }}:18889" - name: Deploy website uses: azure/container-apps-deploy-action@v1 with: @@ -144,7 +144,7 @@ jobs: const output = `### Test environment information #### 🔗[Visit website](https://${{ env.container_app_website_fqdn }}/) #### 🔗[Visit API](https://${{ env.container_app_api_fqdn }}/swagger/) - #### 🔗[Visit monitoring UI](http://${{ env.container_app_monitoring_fqdn }}) + #### 🔗[Visit monitoring UI](https://${{ env.container_app_monitoring_fqdn }}) *Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Working Directory: \`${{ env.tf_actions_working_dir }}\`, Workflow: \`${{ github.workflow }}\`*`; diff --git a/src/Api/Company.Api/appsettings.Development.json b/src/Api/Company.Api/appsettings.Development.json index 25b6a0f1..d345749a 100644 --- a/src/Api/Company.Api/appsettings.Development.json +++ b/src/Api/Company.Api/appsettings.Development.json @@ -5,6 +5,6 @@ "Microsoft.AspNetCore": "Warning" } }, - "OTEL_EXPORTER_OTLP_ENDPOINT": "http://onlinestore-update-monitoring-monitoring.eastus.azurecontainer.io:18889", + "OTEL_EXPORTER_OTLP_ENDPOINT": "set-me", "OTEL_SERVICE_NAME": "Company.Api" } diff --git a/terraform/instance/container_apps.tf b/terraform/instance/container_apps.tf index 6778246a..886069f8 100644 --- a/terraform/instance/container_apps.tf +++ b/terraform/instance/container_apps.tf @@ -98,7 +98,6 @@ resource "azurerm_container_app" "monitoring" { external_enabled = true transport = "http" target_port = 18888 - allow_insecure_connections = true traffic_weight { latest_revision = true percentage = 100 From 485fc73b092eb2ba345c2aa9c4c347e720581d1c Mon Sep 17 00:00:00 2001 From: Benjamin Chiverton Date: Wed, 26 Jun 2024 17:38:40 +0100 Subject: [PATCH 15/24] Update instance-deploy-test.yml --- .github/workflows/instance-deploy-test.yml | 41 +++++++++++++--------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/.github/workflows/instance-deploy-test.yml b/.github/workflows/instance-deploy-test.yml index bc91c373..b8d81491 100644 --- a/.github/workflows/instance-deploy-test.yml +++ b/.github/workflows/instance-deploy-test.yml @@ -120,7 +120,7 @@ jobs: location: 'East US' resourceGroup: ${{ env.resource_group_name }} targetPort: 8080 - environmentVariables: "OTEL_EXPORTER_OTLP_ENDPOINT=https://${{ env.container_app_monitoring_fqdn }}:18889" + environmentVariables: "OTEL_EXPORTER_OTLP_ENDPOINT=https://onlinestore-monitoring:18889" - name: Deploy website uses: azure/container-apps-deploy-action@v1 with: @@ -133,24 +133,31 @@ jobs: resourceGroup: ${{ env.resource_group_name }} targetPort: 80 environmentVariables: "API__BASEPATH=https://${{ env.container_app_api_fqdn }}" - - name: Post test environment information on PR - uses: actions/github-script@0.9.0 - if: github.event_name == 'pull_request' - env: - PLAN: "terraform\n${{ steps.plan.outputs.stdout }}" + - name: Find Comment + uses: peter-evans/find-comment@v1 + id: fc + with: + issue-number: ${{ github.event.pull_request.number }} + comment-author: 'github-actions[bot]' + body-includes: | + ### Test environment information + - name: Create comment + if: steps.fc.outputs.comment-id == '' + uses: peter-evans/create-or-update-comment@v1 with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - const output = `### Test environment information + issue-number: ${{ github.event.pull_request.number }} + body: | + ### Test environment information + reactions: rocket + - name: Update comment + if: steps.fc.outputs.comment-id != '' + uses: peter-evans/create-or-update-comment@v1 + with: + comment-id: ${{ steps.fc.outputs.comment-id }} + body: | + ### Test environment information #### 🔗[Visit website](https://${{ env.container_app_website_fqdn }}/) #### 🔗[Visit API](https://${{ env.container_app_api_fqdn }}/swagger/) #### 🔗[Visit monitoring UI](https://${{ env.container_app_monitoring_fqdn }}) - *Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Working Directory: \`${{ env.tf_actions_working_dir }}\`, Workflow: \`${{ github.workflow }}\`*`; - - github.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: output - }) + *Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Working Directory: \`${{ env.tf_actions_working_dir }}\`, Workflow: \`${{ github.workflow }}\`* From 239292137685c12f1c60fd730875716dfd3b74a2 Mon Sep 17 00:00:00 2001 From: Benjamin Chiverton Date: Wed, 26 Jun 2024 17:39:40 +0100 Subject: [PATCH 16/24] Update instance-deploy-test.yml --- .github/workflows/instance-deploy-test.yml | 54 +++++++++++----------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/.github/workflows/instance-deploy-test.yml b/.github/workflows/instance-deploy-test.yml index b8d81491..ac9b6b7c 100644 --- a/.github/workflows/instance-deploy-test.yml +++ b/.github/workflows/instance-deploy-test.yml @@ -133,31 +133,31 @@ jobs: resourceGroup: ${{ env.resource_group_name }} targetPort: 80 environmentVariables: "API__BASEPATH=https://${{ env.container_app_api_fqdn }}" - - name: Find Comment - uses: peter-evans/find-comment@v1 - id: fc - with: - issue-number: ${{ github.event.pull_request.number }} - comment-author: 'github-actions[bot]' - body-includes: | - ### Test environment information - - name: Create comment - if: steps.fc.outputs.comment-id == '' - uses: peter-evans/create-or-update-comment@v1 - with: - issue-number: ${{ github.event.pull_request.number }} - body: | - ### Test environment information - reactions: rocket - - name: Update comment - if: steps.fc.outputs.comment-id != '' - uses: peter-evans/create-or-update-comment@v1 - with: - comment-id: ${{ steps.fc.outputs.comment-id }} - body: | - ### Test environment information - #### 🔗[Visit website](https://${{ env.container_app_website_fqdn }}/) - #### 🔗[Visit API](https://${{ env.container_app_api_fqdn }}/swagger/) - #### 🔗[Visit monitoring UI](https://${{ env.container_app_monitoring_fqdn }}) + # - name: Find Comment + # uses: peter-evans/find-comment@v1 + # id: fc + # with: + # issue-number: ${{ github.event.pull_request.number }} + # comment-author: 'github-actions[bot]' + # body-includes: | + # ### Test environment information + # - name: Create comment + # if: steps.fc.outputs.comment-id == '' + # uses: peter-evans/create-or-update-comment@v1 + # with: + # issue-number: ${{ github.event.pull_request.number }} + # body: | + # ### Test environment information + # reactions: rocket + # - name: Update comment + # if: steps.fc.outputs.comment-id != '' + # uses: peter-evans/create-or-update-comment@v1 + # with: + # comment-id: ${{ steps.fc.outputs.comment-id }} + # body: | + # ### Test environment information + # #### 🔗[Visit website](https://${{ env.container_app_website_fqdn }}/) + # #### 🔗[Visit API](https://${{ env.container_app_api_fqdn }}/swagger/) + # #### 🔗[Visit monitoring UI](https://${{ env.container_app_monitoring_fqdn }}) - *Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Working Directory: \`${{ env.tf_actions_working_dir }}\`, Workflow: \`${{ github.workflow }}\`* + # *Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Working Directory: \`${{ env.tf_actions_working_dir }}\`, Workflow: \`${{ github.workflow }}\`* From f50dd4aa9b1af48a705c3bc66219e393dce952c3 Mon Sep 17 00:00:00 2001 From: Benjamin Chiverton Date: Wed, 26 Jun 2024 17:47:44 +0100 Subject: [PATCH 17/24] Update instance-deploy-test.yml --- .github/workflows/instance-deploy-test.yml | 25 ++++++++++------------ 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/.github/workflows/instance-deploy-test.yml b/.github/workflows/instance-deploy-test.yml index ac9b6b7c..2e90fa30 100644 --- a/.github/workflows/instance-deploy-test.yml +++ b/.github/workflows/instance-deploy-test.yml @@ -133,22 +133,19 @@ jobs: resourceGroup: ${{ env.resource_group_name }} targetPort: 80 environmentVariables: "API__BASEPATH=https://${{ env.container_app_api_fqdn }}" - # - name: Find Comment - # uses: peter-evans/find-comment@v1 - # id: fc - # with: - # issue-number: ${{ github.event.pull_request.number }} - # comment-author: 'github-actions[bot]' - # body-includes: | - # ### Test environment information + - name: Find Comment + uses: peter-evans/find-comment@v1 + id: fc + with: + issue-number: ${{ github.event.pull_request.number }} + comment-author: 'github-actions[bot]' + body-includes: "### Test environment information" # - name: Create comment # if: steps.fc.outputs.comment-id == '' # uses: peter-evans/create-or-update-comment@v1 # with: # issue-number: ${{ github.event.pull_request.number }} - # body: | - # ### Test environment information - # reactions: rocket + # body: "### Test environment information" # - name: Update comment # if: steps.fc.outputs.comment-id != '' # uses: peter-evans/create-or-update-comment@v1 @@ -156,8 +153,8 @@ jobs: # comment-id: ${{ steps.fc.outputs.comment-id }} # body: | # ### Test environment information - # #### 🔗[Visit website](https://${{ env.container_app_website_fqdn }}/) - # #### 🔗[Visit API](https://${{ env.container_app_api_fqdn }}/swagger/) - # #### 🔗[Visit monitoring UI](https://${{ env.container_app_monitoring_fqdn }}) + # #### 🔗 [Company Website](https://${{ env.container_app_website_fqdn }}/) + # #### 🔗 [Company API](https://${{ env.container_app_api_fqdn }}/swagger/) + # #### 🔗 [Monitoring Dashboard](https://${{ env.container_app_monitoring_fqdn }}) # *Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Working Directory: \`${{ env.tf_actions_working_dir }}\`, Workflow: \`${{ github.workflow }}\`* From c6baf48c8dabdde9beb9b551fa4a2611652bc684 Mon Sep 17 00:00:00 2001 From: Benjamin Chiverton Date: Wed, 26 Jun 2024 17:48:27 +0100 Subject: [PATCH 18/24] Update instance-deploy-test.yml --- .github/workflows/instance-deploy-test.yml | 34 +++++++++++----------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/instance-deploy-test.yml b/.github/workflows/instance-deploy-test.yml index 2e90fa30..e98d3fb4 100644 --- a/.github/workflows/instance-deploy-test.yml +++ b/.github/workflows/instance-deploy-test.yml @@ -140,21 +140,21 @@ jobs: issue-number: ${{ github.event.pull_request.number }} comment-author: 'github-actions[bot]' body-includes: "### Test environment information" - # - name: Create comment - # if: steps.fc.outputs.comment-id == '' - # uses: peter-evans/create-or-update-comment@v1 - # with: - # issue-number: ${{ github.event.pull_request.number }} - # body: "### Test environment information" - # - name: Update comment - # if: steps.fc.outputs.comment-id != '' - # uses: peter-evans/create-or-update-comment@v1 - # with: - # comment-id: ${{ steps.fc.outputs.comment-id }} - # body: | - # ### Test environment information - # #### 🔗 [Company Website](https://${{ env.container_app_website_fqdn }}/) - # #### 🔗 [Company API](https://${{ env.container_app_api_fqdn }}/swagger/) - # #### 🔗 [Monitoring Dashboard](https://${{ env.container_app_monitoring_fqdn }}) + - name: Create comment + if: steps.fc.outputs.comment-id == '' + uses: peter-evans/create-or-update-comment@v1 + with: + issue-number: ${{ github.event.pull_request.number }} + body: "### Test environment information" + - name: Update comment + if: steps.fc.outputs.comment-id != '' + uses: peter-evans/create-or-update-comment@v1 + with: + comment-id: ${{ steps.fc.outputs.comment-id }} + body: | + ### Test environment information + #### 🔗 [Company Website](https://${{ env.container_app_website_fqdn }}/) + #### 🔗 [Company API](https://${{ env.container_app_api_fqdn }}/swagger/) + #### 🔗 [Monitoring Dashboard](https://${{ env.container_app_monitoring_fqdn }}) - # *Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Working Directory: \`${{ env.tf_actions_working_dir }}\`, Workflow: \`${{ github.workflow }}\`* + *Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Working Directory: \`${{ env.tf_actions_working_dir }}\`, Workflow: \`${{ github.workflow }}\`* From d94dcbf1c7b2cad629e60de86ac5c19d66aed4cd Mon Sep 17 00:00:00 2001 From: Benjamin Chiverton Date: Wed, 26 Jun 2024 17:49:15 +0100 Subject: [PATCH 19/24] Update instance-deploy-test.yml --- .github/workflows/instance-deploy-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/instance-deploy-test.yml b/.github/workflows/instance-deploy-test.yml index e98d3fb4..e9fd6d25 100644 --- a/.github/workflows/instance-deploy-test.yml +++ b/.github/workflows/instance-deploy-test.yml @@ -146,7 +146,7 @@ jobs: with: issue-number: ${{ github.event.pull_request.number }} body: "### Test environment information" - - name: Update comment + - name: Update comment if: steps.fc.outputs.comment-id != '' uses: peter-evans/create-or-update-comment@v1 with: From 112ef565a97ee9924ccdbbe382cd53f558b4ede4 Mon Sep 17 00:00:00 2001 From: Benjamin Chiverton Date: Wed, 26 Jun 2024 17:51:40 +0100 Subject: [PATCH 20/24] Use HTTP instead of HTTPS --- .github/workflows/instance-deploy-prod.yml | 3 +-- .github/workflows/instance-deploy-test.yml | 4 +--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/instance-deploy-prod.yml b/.github/workflows/instance-deploy-prod.yml index 1cf3e5a8..da021456 100644 --- a/.github/workflows/instance-deploy-prod.yml +++ b/.github/workflows/instance-deploy-prod.yml @@ -101,7 +101,6 @@ jobs: terraform -chdir=instance output -raw resource_group_name > terraform-outputs/resource_group_name.txt terraform -chdir=instance output -raw container_app_api_fqdn > terraform-outputs/container_app_api_fqdn.txt terraform -chdir=instance output -raw container_app_website_fqdn > terraform-outputs/container_app_website_fqdn.txt - # -raw cannot handle null values - https://github.com/hashicorp/terraform/issues/32384 terraform -chdir=instance show -json | jq -r '.values.outputs.container_app_monitoring_fqdn.value // ""' > container_app_monitoring_fqdn.txt - name: Upload terraform outputs for deploy job uses: actions/upload-artifact@v3 @@ -143,7 +142,7 @@ jobs: location: 'East US' resourceGroup: ${{ env.resource_group_name }} targetPort: 8080 - environmentVariables: "OTEL_EXPORTER_OTLP_ENDPOINT=https://${{ env.container_app_monitoring_fqdn }}:18889" + environmentVariables: "OTEL_EXPORTER_OTLP_ENDPOINT=http://${{ env.container_app_monitoring_fqdn }}:18889" - name: Deploy website uses: azure/container-apps-deploy-action@v1 with: diff --git a/.github/workflows/instance-deploy-test.yml b/.github/workflows/instance-deploy-test.yml index e9fd6d25..ca2ce6c1 100644 --- a/.github/workflows/instance-deploy-test.yml +++ b/.github/workflows/instance-deploy-test.yml @@ -78,8 +78,6 @@ jobs: terraform -chdir=instance output -raw container_app_api_fqdn > terraform-outputs/container_app_api_fqdn.txt terraform -chdir=instance output -raw container_app_website_fqdn > terraform-outputs/container_app_website_fqdn.txt terraform -chdir=instance output -raw container_app_monitoring_fqdn > terraform-outputs/container_app_monitoring_fqdn.txt - # -raw cannot handle null values - https://github.com/hashicorp/terraform/issues/32384 - terraform -chdir=instance show -json | jq -r '.values.outputs.container_app_monitoring_fqdn.value // ""' > container_app_monitoring_fqdn.txt - name: Upload terraform outputs for deploy job uses: actions/upload-artifact@v3 with: @@ -120,7 +118,7 @@ jobs: location: 'East US' resourceGroup: ${{ env.resource_group_name }} targetPort: 8080 - environmentVariables: "OTEL_EXPORTER_OTLP_ENDPOINT=https://onlinestore-monitoring:18889" + environmentVariables: "OTEL_EXPORTER_OTLP_ENDPOINT=http://onlinestore-monitoring:18889" - name: Deploy website uses: azure/container-apps-deploy-action@v1 with: From 62a0553955c76c9f13bc1c0fef72cfaa7810907a Mon Sep 17 00:00:00 2001 From: Benjamin Chiverton Date: Wed, 26 Jun 2024 17:58:49 +0100 Subject: [PATCH 21/24] Remove obsolete container_instances, stop spamming comments on PR's --- .github/workflows/instance-deploy-prod.yml | 27 +------------- .github/workflows/instance-deploy-test.yml | 12 ++----- .github/workflows/instance-plan-prod.yml | 29 ++++++++------- terraform/instance/container_instances.tf | 41 ---------------------- terraform/instance/variables.tf | 6 ---- 5 files changed, 17 insertions(+), 98 deletions(-) delete mode 100644 terraform/instance/container_instances.tf diff --git a/.github/workflows/instance-deploy-prod.yml b/.github/workflows/instance-deploy-prod.yml index da021456..cbcb106d 100644 --- a/.github/workflows/instance-deploy-prod.yml +++ b/.github/workflows/instance-deploy-prod.yml @@ -3,31 +3,8 @@ on: push: branches: [main] workflow_dispatch: - inputs: - monitoring_enabled: - description: Deploy monitoring infrastructure (£20/month) - type: boolean - required: true - default: false jobs: - variables: - runs-on: ubuntu-latest - outputs: - monitoring_enabled: ${{ steps.setvars.outputs.monitoring_enabled }} - steps: - - name: Set variables needed for workflow - id: setvars - run: | - if [[ "${{ inputs.monitoring_enabled}}" == "" ]] - then - echo "monitoring_enabled=false" - echo "monitoring_enabled=false" >> $GITHUB_OUTPUT - else - echo "monitoring_enabled=${{ inputs.monitoring_enabled}}" - echo "monitoring_enabled=${{ inputs.monitoring_enabled}}" >> $GITHUB_OUTPUT - fi - build-api: uses: benchiverton/OnlineStore/.github/workflows/workflow-build-test-publish-dotnet.yml@main with: @@ -49,7 +26,7 @@ jobs: secrets: inherit deploy-terraform-prod: - needs: [variables, build-api, build-website] + needs: [build-api, build-website] environment: prod env: ARM_CLIENT_ID: ${{ secrets.TF_VAR_AGENT_CLIENT_ID }} @@ -84,7 +61,6 @@ jobs: TF_VAR_environment: prod TF_VAR_acr_username: ${{ secrets.ACR_USERNAME }} TF_VAR_acr_password: ${{ secrets.ACR_TOKEN }} - TF_VAR_monitoring_enabled: ${{ needs.variables.outputs.monitoring_enabled }} - name: Terraform Apply id: apply run: terraform -chdir=instance apply -auto-approve @@ -93,7 +69,6 @@ jobs: TF_VAR_environment: prod TF_VAR_acr_username: ${{ secrets.ACR_USERNAME }} TF_VAR_acr_password: ${{ secrets.ACR_TOKEN }} - TF_VAR_monitoring_enabled: ${{ needs.variables.outputs.monitoring_enabled }} - name: Save terraform outputs shell: bash run: | diff --git a/.github/workflows/instance-deploy-test.yml b/.github/workflows/instance-deploy-test.yml index ca2ce6c1..b7bf5bb7 100644 --- a/.github/workflows/instance-deploy-test.yml +++ b/.github/workflows/instance-deploy-test.yml @@ -60,7 +60,6 @@ jobs: TF_VAR_environment: ${{ github.head_ref }} TF_VAR_acr_username: ${{ secrets.ACR_USERNAME }} TF_VAR_acr_password: ${{ secrets.ACR_TOKEN }} - TF_VAR_monitoring_enabled: true # enabled for testing - name: Terraform Apply id: apply run: terraform -chdir=instance apply -auto-approve @@ -69,7 +68,6 @@ jobs: TF_VAR_environment: ${{ github.head_ref }} TF_VAR_acr_username: ${{ secrets.ACR_USERNAME }} TF_VAR_acr_password: ${{ secrets.ACR_TOKEN }} - TF_VAR_monitoring_enabled: true # enabled for testing - name: Save terraform outputs shell: bash run: | @@ -138,17 +136,11 @@ jobs: issue-number: ${{ github.event.pull_request.number }} comment-author: 'github-actions[bot]' body-includes: "### Test environment information" - - name: Create comment - if: steps.fc.outputs.comment-id == '' - uses: peter-evans/create-or-update-comment@v1 - with: - issue-number: ${{ github.event.pull_request.number }} - body: "### Test environment information" - - name: Update comment - if: steps.fc.outputs.comment-id != '' + - name: Create or update comment uses: peter-evans/create-or-update-comment@v1 with: comment-id: ${{ steps.fc.outputs.comment-id }} + edit-mode: replace body: | ### Test environment information #### 🔗 [Company Website](https://${{ env.container_app_website_fqdn }}/) diff --git a/.github/workflows/instance-plan-prod.yml b/.github/workflows/instance-plan-prod.yml index 74e65e21..409bcb13 100644 --- a/.github/workflows/instance-plan-prod.yml +++ b/.github/workflows/instance-plan-prod.yml @@ -39,14 +39,20 @@ jobs: TF_VAR_environment: prod TF_VAR_acr_username: ${{ secrets.ACR_USERNAME }} TF_VAR_acr_password: ${{ secrets.ACR_TOKEN }} - - uses: actions/github-script@0.9.0 - if: github.event_name == 'pull_request' - env: - PLAN: "terraform\n${{ steps.plan.outputs.stdout }}" + - name: Find Comment + uses: peter-evans/find-comment@v1 + id: fc + with: + issue-number: ${{ github.event.pull_request.number }} + comment-author: 'github-actions[bot]' + body-includes: "### Terraform plan for prod" + - name: Create or update comment + uses: peter-evans/create-or-update-comment@v1 with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - const output = `### Terraform plan for prod + comment-id: ${{ steps.fc.outputs.comment-id }} + edit-mode: replace + body: | + ### Terraform plan for prod #### Terraform Format and Style 🖌\`${{ steps.fmt.outcome }}\` #### Terraform Initialization ⚙️\`${{ steps.init.outcome }}\` #### Terraform Validation 🤖${{ steps.validate.outputs.stdout }} @@ -58,11 +64,4 @@ jobs: - *Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Working Directory: \`${{ env.tf_actions_working_dir }}\`, Workflow: \`${{ github.workflow }}\`*`; - - github.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: output - }) + *Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Working Directory: \`${{ env.tf_actions_working_dir }}\`, Workflow: \`${{ github.workflow }}\`* diff --git a/terraform/instance/container_instances.tf b/terraform/instance/container_instances.tf deleted file mode 100644 index 02fdc387..00000000 --- a/terraform/instance/container_instances.tf +++ /dev/null @@ -1,41 +0,0 @@ -resource "azurerm_container_group" "monitoring" { - count = var.monitoring_enabled ? 1 : 0 - name = "${var.name}-containergroup-monitoring" - resource_group_name = azurerm_resource_group.instance.name - location = azurerm_resource_group.instance.location - ip_address_type = "Public" - dns_name_label = "${var.name}-${lower(var.environment)}-monitoring" - os_type = "Linux" - - container { - name = "aspire-dashboard" - image = "onlinestorecontainerregistry.azurecr.io/dotnet/aspire-dashboard:8.0.0" - cpu = "0.05" - memory = "0.20" - - # serve frontend - ports { - port = 18888 - protocol = "TCP" - } - # OTLP over GRPC - ports { - port = 18889 - protocol = "TCP" - } - - environment_variables = { - DOTNET_DASHBOARD_UNSECURED_ALLOW_ANONYMOUS = "true" - } - } - - image_registry_credential { - server = "onlinestorecontainerregistry.azurecr.io" - username = var.acr_username - password = var.acr_password - } - - tags = { - environment = var.environment - } -} diff --git a/terraform/instance/variables.tf b/terraform/instance/variables.tf index 7994ae10..9957eeba 100644 --- a/terraform/instance/variables.tf +++ b/terraform/instance/variables.tf @@ -39,9 +39,3 @@ variable "acr_password" { description = "The password to log in to ACR" sensitive = true } - -variable "monitoring_enabled" { - type = bool - description = "Location to deploy the resoruce group" - default = true -} From 0d7a06a75a49f11e5ae502f9ae056deafb8060a7 Mon Sep 17 00:00:00 2001 From: Benjamin Chiverton Date: Wed, 26 Jun 2024 18:19:17 +0100 Subject: [PATCH 22/24] Fix comment workflows --- .github/workflows/instance-deploy-test.yml | 1 + .github/workflows/instance-plan-prod.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/instance-deploy-test.yml b/.github/workflows/instance-deploy-test.yml index b7bf5bb7..69e50f06 100644 --- a/.github/workflows/instance-deploy-test.yml +++ b/.github/workflows/instance-deploy-test.yml @@ -139,6 +139,7 @@ jobs: - name: Create or update comment uses: peter-evans/create-or-update-comment@v1 with: + issue-number: ${{ github.event.pull_request.number }} comment-id: ${{ steps.fc.outputs.comment-id }} edit-mode: replace body: | diff --git a/.github/workflows/instance-plan-prod.yml b/.github/workflows/instance-plan-prod.yml index 409bcb13..7e66d09c 100644 --- a/.github/workflows/instance-plan-prod.yml +++ b/.github/workflows/instance-plan-prod.yml @@ -49,6 +49,7 @@ jobs: - name: Create or update comment uses: peter-evans/create-or-update-comment@v1 with: + issue-number: ${{ github.event.pull_request.number }} comment-id: ${{ steps.fc.outputs.comment-id }} edit-mode: replace body: | From 094fb0cdc87394b24a9456e1c585a35f9be9e38c Mon Sep 17 00:00:00 2001 From: Benjamin Chiverton Date: Wed, 26 Jun 2024 18:24:47 +0100 Subject: [PATCH 23/24] Remove old references to container_instances --- docs/Telemetry/DistributedMonitoring.md | 2 +- terraform/instance/container_apps.tf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/Telemetry/DistributedMonitoring.md b/docs/Telemetry/DistributedMonitoring.md index f2c5d6ad..0df11bfc 100644 --- a/docs/Telemetry/DistributedMonitoring.md +++ b/docs/Telemetry/DistributedMonitoring.md @@ -131,7 +131,7 @@ builder.Services.Configure(options => options.AddOtl ### CICD -I copy the .NET Aspire Dashboard image to my Azure Container Registry [here](../../.github/workflows/permanent-image-import.yml), and deploy it using terraform [here](../../terraform/instance/container_instances.tf). +I copy the .NET Aspire Dashboard image to my Azure Container Registry [here](../../.github/workflows/permanent-image-import.yml), and deploy it using terraform [here](../../terraform/instance/container_apps.tf#L77). ## Data visualisation (.NET Aspire) diff --git a/terraform/instance/container_apps.tf b/terraform/instance/container_apps.tf index 886069f8..abe1b185 100644 --- a/terraform/instance/container_apps.tf +++ b/terraform/instance/container_apps.tf @@ -117,7 +117,7 @@ resource "azurerm_container_app" "monitoring" { } # update the container app with extra additionalPortMappings, as this is not supported by the existing TF provider -resource "azapi_update_resource" "container_app_api" { +resource "azapi_update_resource" "monitoring_portmappings" { type = "Microsoft.App/containerApps@2023-11-02-preview" resource_id = azurerm_container_app.monitoring.id From e60436d1cc7f2549ccd075f64ed7369ca2afaf57 Mon Sep 17 00:00:00 2001 From: Benjamin Chiverton Date: Wed, 26 Jun 2024 18:31:42 +0100 Subject: [PATCH 24/24] Set OTEL_EXPORTER_OTLP_ENDPOINT in terraform as it's now static --- .github/workflows/instance-deploy-prod.yml | 1 - .github/workflows/instance-deploy-test.yml | 1 - terraform/instance/container_apps.tf | 4 ++++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/instance-deploy-prod.yml b/.github/workflows/instance-deploy-prod.yml index cbcb106d..665987f6 100644 --- a/.github/workflows/instance-deploy-prod.yml +++ b/.github/workflows/instance-deploy-prod.yml @@ -117,7 +117,6 @@ jobs: location: 'East US' resourceGroup: ${{ env.resource_group_name }} targetPort: 8080 - environmentVariables: "OTEL_EXPORTER_OTLP_ENDPOINT=http://${{ env.container_app_monitoring_fqdn }}:18889" - name: Deploy website uses: azure/container-apps-deploy-action@v1 with: diff --git a/.github/workflows/instance-deploy-test.yml b/.github/workflows/instance-deploy-test.yml index 69e50f06..14c78912 100644 --- a/.github/workflows/instance-deploy-test.yml +++ b/.github/workflows/instance-deploy-test.yml @@ -116,7 +116,6 @@ jobs: location: 'East US' resourceGroup: ${{ env.resource_group_name }} targetPort: 8080 - environmentVariables: "OTEL_EXPORTER_OTLP_ENDPOINT=http://onlinestore-monitoring:18889" - name: Deploy website uses: azure/container-apps-deploy-action@v1 with: diff --git a/terraform/instance/container_apps.tf b/terraform/instance/container_apps.tf index abe1b185..91eee657 100644 --- a/terraform/instance/container_apps.tf +++ b/terraform/instance/container_apps.tf @@ -16,6 +16,10 @@ resource "azurerm_container_app" "api" { image = "mcr.microsoft.com/azuredocs/containerapps-helloworld:latest" cpu = 0.25 memory = "0.5Gi" + env { + name = "OTEL_EXPORTER_OTLP_ENDPOINT" + value = "http://onlinestore-monitoring:18889" + } } max_replicas = 1 }