From 40d664e4fb62058e6bf2f224195ba19999fcc9cd Mon Sep 17 00:00:00 2001 From: Paolo Salvatori Date: Fri, 4 Dec 2026 11:53:58 +0100 Subject: [PATCH] Restart the App Configuration sample's web app before checking its reads of the store The web app reads its key-values from the App Configuration store only when it starts, and Azure can drop for good the records of a new diagnostic setting's first minutes. query-logs-and-metrics.sh restarted the app so that it read its secrets again, but only after the AACHttpRequest check, so that check failed whenever every start of the app had fallen in those minutes: on 2026-12-04 the .NET sample's four startup reads were missing for good, and the workspace held only the read of the restart that followed the failed check. The script now restarts the app before both the AACHttpRequest and the AZKVAuditLogs checks, and the READMEs list the store reads among the start-up records Azure can drop. Fixes SMF-1297 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01FvNuJJKcAASYSAqWH2cusA --- .../dotnet/README.md | 2 +- .../dotnet/scripts/query-logs-and-metrics.sh | 21 ++++++++++--------- .../python/README.md | 2 +- .../python/scripts/query-logs-and-metrics.sh | 21 ++++++++++--------- 4 files changed, 24 insertions(+), 22 deletions(-) diff --git a/samples/web-app-app-configuration/dotnet/README.md b/samples/web-app-app-configuration/dotnet/README.md index 4530a334..3ecb8ce9 100644 --- a/samples/web-app-app-configuration/dotnet/README.md +++ b/samples/web-app-app-configuration/dotnet/README.md @@ -436,7 +436,7 @@ The emulator serves an emulated Azure portal at `http://localhost:4566/_localsta ### Delivery times -On the emulator the records are queryable within seconds, and the aggregated ones (`AACHttpRequest` and `AzureMetrics`) once their one-minute window is over. On Azure the records take minutes, and the first records of a new diagnostic setting can take [up to 90 minutes](https://learn.microsoft.com/azure/azure-monitor/data-collection/diagnostic-settings#expected-latency-after-creating-a-diagnostic-setting): run the queries again later, or raise `RETRY_COUNT` for the script. The exported platform metrics (`AzureMetrics`) are the exception: Azure exports them late and irregularly, so on Azure `query-logs-and-metrics.sh` reads them once, shows those that arrived and notes how many are still missing, without failing. A new setting can also take a while before it delivers anything, and on Azure the records of what the application did while it started, such as its start-up console lines or its secret reads in the key vault, can then be missing for good: once the workspace receives records, `az webapp restart --name local-webapp-test --resource-group local-rg` starts the application again, and the records of the new start arrive. +On the emulator the records are queryable within seconds, and the aggregated ones (`AACHttpRequest` and `AzureMetrics`) once their one-minute window is over. On Azure the records take minutes, and the first records of a new diagnostic setting can take [up to 90 minutes](https://learn.microsoft.com/azure/azure-monitor/data-collection/diagnostic-settings#expected-latency-after-creating-a-diagnostic-setting): run the queries again later, or raise `RETRY_COUNT` for the script. The exported platform metrics (`AzureMetrics`) are the exception: Azure exports them late and irregularly, so on Azure `query-logs-and-metrics.sh` reads them once, shows those that arrived and notes how many are still missing, without failing. A new setting can also take a while before it delivers anything, and on Azure the records of what the application did while it started, such as its start-up console lines, its reads of the App Configuration store or its secret reads in the key vault, can then be missing for good: once the workspace receives records, `az webapp restart --name local-webapp-test --resource-group local-rg` starts the application again, and the records of the new start arrive. ## Troubleshooting diff --git a/samples/web-app-app-configuration/dotnet/scripts/query-logs-and-metrics.sh b/samples/web-app-app-configuration/dotnet/scripts/query-logs-and-metrics.sh index bef64cf0..af7a2c51 100755 --- a/samples/web-app-app-configuration/dotnet/scripts/query-logs-and-metrics.sh +++ b/samples/web-app-app-configuration/dotnet/scripts/query-logs-and-metrics.sh @@ -397,16 +397,10 @@ query_workspace \ "AppServicePlatformLogs | project TimeGenerated, Level, Message | order by TimeGenerated desc | take 10" \ "[].{Time:TimeGenerated,Level:Level,Message:Message}" -# The requests to the store (AACHttpRequest), each record aggregating the requests of one method and status code: among -# them the GET with which the app reads its key-values, made by the managed identity of the web app (ClientObjectId) -query_workspace \ - "Requests to the [$APP_CONFIG_NAME] App Configuration store (AACHttpRequest)" \ - "AACHttpRequest | project TimeGenerated, Method, StatusCode, HitCount, ClientObjectId, RequestURI | order by TimeGenerated desc | take 10" \ - "[].{Time:TimeGenerated,Method:Method,Status:StatusCode,Hits:HitCount,Caller:ClientObjectId,Uri:RequestURI}" - -# Azure can drop for good the records of a new diagnostic setting's first minutes, among them the secret reads of -# the web app's start, so the web app is restarted and called again: it reads its secrets anew -echo -e "\nRestarting the [$WEB_APP_NAME] web app, so that it reads its two secrets again..." +# The web app reads its key-values from the store and its two secrets from the key vault only when it starts, and Azure +# can drop for good the records of a new diagnostic setting's first minutes, among them those reads, so the web app is +# restarted before the two queries that look for them: it reads its key-values and secrets anew +echo -e "\nRestarting the [$WEB_APP_NAME] web app, so that it reads its key-values and its two secrets again..." az webapp restart \ --name "$WEB_APP_NAME" \ --resource-group "$RESOURCE_GROUP_NAME" \ @@ -420,6 +414,13 @@ else fi wait_for_web_app "https://$WEB_APP_HOST_NAME/" +# The requests to the store (AACHttpRequest), each record aggregating the requests of one method and status code: among +# them the GET with which the app reads its key-values, made by the managed identity of the web app (ClientObjectId) +query_workspace \ + "Requests to the [$APP_CONFIG_NAME] App Configuration store (AACHttpRequest)" \ + "AACHttpRequest | project TimeGenerated, Method, StatusCode, HitCount, ClientObjectId, RequestURI | order by TimeGenerated desc | take 10" \ + "[].{Time:TimeGenerated,Method:Method,Status:StatusCode,Hits:HitCount,Caller:ClientObjectId,Uri:RequestURI}" + # The reads of the pg-user and pg-password secrets that resolved the two Key Vault references (AZKVAuditLogs) query_workspace \ "Secret reads in the [$KEY_VAULT_NAME] key vault (AZKVAuditLogs)" \ diff --git a/samples/web-app-app-configuration/python/README.md b/samples/web-app-app-configuration/python/README.md index 210d69d6..808ab645 100644 --- a/samples/web-app-app-configuration/python/README.md +++ b/samples/web-app-app-configuration/python/README.md @@ -436,7 +436,7 @@ The emulator serves an emulated Azure portal at `http://localhost:4566/_localsta ### Delivery times -On the emulator the records are queryable within seconds, and the aggregated ones (`AACHttpRequest` and `AzureMetrics`) once their one-minute window is over. On Azure the records take minutes, and the first records of a new diagnostic setting can take [up to 90 minutes](https://learn.microsoft.com/azure/azure-monitor/data-collection/diagnostic-settings#expected-latency-after-creating-a-diagnostic-setting): run the queries again later, or raise `RETRY_COUNT` for the script. The exported platform metrics (`AzureMetrics`) are the exception: Azure exports them late and irregularly, so on Azure `query-logs-and-metrics.sh` reads them once, shows those that arrived and notes how many are still missing, without failing. A new setting can also take a while before it delivers anything, and on Azure the records of what the application did while it started, such as its start-up console lines or its secret reads in the key vault, can then be missing for good: once the workspace receives records, `az webapp restart --name local-webapp-test --resource-group local-rg` starts the application again, and the records of the new start arrive. +On the emulator the records are queryable within seconds, and the aggregated ones (`AACHttpRequest` and `AzureMetrics`) once their one-minute window is over. On Azure the records take minutes, and the first records of a new diagnostic setting can take [up to 90 minutes](https://learn.microsoft.com/azure/azure-monitor/data-collection/diagnostic-settings#expected-latency-after-creating-a-diagnostic-setting): run the queries again later, or raise `RETRY_COUNT` for the script. The exported platform metrics (`AzureMetrics`) are the exception: Azure exports them late and irregularly, so on Azure `query-logs-and-metrics.sh` reads them once, shows those that arrived and notes how many are still missing, without failing. A new setting can also take a while before it delivers anything, and on Azure the records of what the application did while it started, such as its start-up console lines, its reads of the App Configuration store or its secret reads in the key vault, can then be missing for good: once the workspace receives records, `az webapp restart --name local-webapp-test --resource-group local-rg` starts the application again, and the records of the new start arrive. ## Troubleshooting diff --git a/samples/web-app-app-configuration/python/scripts/query-logs-and-metrics.sh b/samples/web-app-app-configuration/python/scripts/query-logs-and-metrics.sh index bef64cf0..af7a2c51 100755 --- a/samples/web-app-app-configuration/python/scripts/query-logs-and-metrics.sh +++ b/samples/web-app-app-configuration/python/scripts/query-logs-and-metrics.sh @@ -397,16 +397,10 @@ query_workspace \ "AppServicePlatformLogs | project TimeGenerated, Level, Message | order by TimeGenerated desc | take 10" \ "[].{Time:TimeGenerated,Level:Level,Message:Message}" -# The requests to the store (AACHttpRequest), each record aggregating the requests of one method and status code: among -# them the GET with which the app reads its key-values, made by the managed identity of the web app (ClientObjectId) -query_workspace \ - "Requests to the [$APP_CONFIG_NAME] App Configuration store (AACHttpRequest)" \ - "AACHttpRequest | project TimeGenerated, Method, StatusCode, HitCount, ClientObjectId, RequestURI | order by TimeGenerated desc | take 10" \ - "[].{Time:TimeGenerated,Method:Method,Status:StatusCode,Hits:HitCount,Caller:ClientObjectId,Uri:RequestURI}" - -# Azure can drop for good the records of a new diagnostic setting's first minutes, among them the secret reads of -# the web app's start, so the web app is restarted and called again: it reads its secrets anew -echo -e "\nRestarting the [$WEB_APP_NAME] web app, so that it reads its two secrets again..." +# The web app reads its key-values from the store and its two secrets from the key vault only when it starts, and Azure +# can drop for good the records of a new diagnostic setting's first minutes, among them those reads, so the web app is +# restarted before the two queries that look for them: it reads its key-values and secrets anew +echo -e "\nRestarting the [$WEB_APP_NAME] web app, so that it reads its key-values and its two secrets again..." az webapp restart \ --name "$WEB_APP_NAME" \ --resource-group "$RESOURCE_GROUP_NAME" \ @@ -420,6 +414,13 @@ else fi wait_for_web_app "https://$WEB_APP_HOST_NAME/" +# The requests to the store (AACHttpRequest), each record aggregating the requests of one method and status code: among +# them the GET with which the app reads its key-values, made by the managed identity of the web app (ClientObjectId) +query_workspace \ + "Requests to the [$APP_CONFIG_NAME] App Configuration store (AACHttpRequest)" \ + "AACHttpRequest | project TimeGenerated, Method, StatusCode, HitCount, ClientObjectId, RequestURI | order by TimeGenerated desc | take 10" \ + "[].{Time:TimeGenerated,Method:Method,Status:StatusCode,Hits:HitCount,Caller:ClientObjectId,Uri:RequestURI}" + # The reads of the pg-user and pg-password secrets that resolved the two Key Vault references (AZKVAuditLogs) query_workspace \ "Secret reads in the [$KEY_VAULT_NAME] key vault (AZKVAuditLogs)" \