Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Debug and troubleshoot Azure Container Apps and Function Apps using logs, KQL, and health checks.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/functions/README.md
1# Function Apps Troubleshooting23## Find Linked App Insights / Log Analytics45### Preferred: Use Azure Resource Graph67A single ARG query returns the App Insights name, instrumentation key, connection string, and Log Analytics workspace for a given function app:89```bash10az graph query -q "11resources | where type =~ 'microsoft.web/sites' and name == '<func-app-name>'12| project funcName=name, rg=resourceGroup13| join kind=inner (resources | where type =~ 'microsoft.insights/components' | project appiName=name, rg=resourceGroup, instrumentationKey=properties.InstrumentationKey, connectionString=properties.ConnectionString, workspaceId=properties.WorkspaceResourceId) on rg14| project funcName, appiName, instrumentationKey, connectionString, workspaceId15" -o json16```1718> 💡 **Tip:** This join matches by resource group. If App Insights is in a different resource group, use the CLI fallback below.1920### Fallback: CLI Commands2122#### Step 1: Get the App Insights connection string from app settings2324```bash25az functionapp config appsettings list \26--name <func-app-name> -g <rg-name> \27--query "[?name=='APPLICATIONINSIGHTS_CONNECTION_STRING' || name=='APPINSIGHTS_INSTRUMENTATIONKEY']"28```2930#### Step 2: Find the App Insights resource by instrumentation key3132```bash33az monitor app-insights component show \34--query "[?instrumentationKey=='<key>'] | [0].{name:name, rg:resourceGroup, workspaceId:workspaceResourceId}"35```3637#### Step 3: Find the Log Analytics workspace3839```bash40az monitor app-insights component show --app <appinsights-name> -g <rg-name> \41--query "workspaceResourceId" -o tsv42```4344### Confirm logs are flowing4546Query App Insights `traces` table to verify the function app is sending telemetry:4748```bash49az monitor app-insights query --apps <appinsights-name> -g <rg-name> \50--analytics-query "traces | where operation_Name != '' | take 1 | project timestamp, operation_Name, message"51```5253For `FunctionAppLogs` (available in Log Analytics only, not App Insights), query the workspace directly:5455```bash56az monitor log-analytics query -w <workspace-guid> \57--analytics-query "FunctionAppLogs | where _ResourceId contains '<func-app-name>' | take 5 | project TimeGenerated, FunctionName, Message, Level"58```5960> ⚠️ **Classic App Insights:** Some function apps use classic App Insights without a linked Log Analytics workspace (`workspaceId` is null). In this case, `FunctionAppLogs` is **not available** — use the `traces`, `requests`, and `exceptions` tables via `az monitor app-insights query` instead. As a last resort, `az webapp log tail --name <func-app-name> -g <rg-name>` can stream live logs directly.6162If results are returned, logs are flowing. If empty, verify the `APPLICATIONINSIGHTS_CONNECTION_STRING` app setting matches this App Insights instance.6364> ⚠️ **Always prefer querying App Insights or Log Analytics** for function app logs. `az webapp log tail` can stream live logs directly but App Insights provides richer data, historical queries, and correlation across requests.6566> 💡 **Tip:** App Insights logs can be delayed by a few minutes. If you don't see recent data, wait 3-5 minutes and query again.6768---6970## Check Recent Deployments7172Correlate issues with recent deployments by listing deployment history:7374```bash75az rest --method get \76--uri "/subscriptions/<subscription-id>/resourceGroups/<rg-name>/providers/Microsoft.Web/sites/<func-app-name>/deployments?api-version=2023-12-01"77```7879Compare deployment timestamps against when errors started appearing in App Insights to identify if a deployment caused the issue.8081