Azure Diagnostics
Troubleshoot Azure problems systematically: narrow scope, gather evidence, form hypotheses, validate fixes.
Use structured root cause analysis to prevent recurrence.
Use This Skill When
- The user reports application downtime, errors, or performance regression
- Deployments succeed but service behavior is broken or degraded
- There are connectivity, identity, DNS, scaling, or quota issues
- Configuration drift or unexpected resource state is observed
- Error messages are cryptic or originating from dependent services
Context: Incident Classification
Availability (0% traffic passing): Database down, network cut, authentication broken
Degradation (partial traffic/slowness): High latency, connection pool exhaustion, throttling
Configuration drift: Resource settings changed outside IaC, policy violation, quota exceeded
Data integrity: Corruption, replication lag, backup failure
Security: Unauthorized access, malicious activity, compliance violation
Required Inputs
- Affected resources: Service name, region, resource group
- Symptom timeline: Start time, duration, frequency (one-off or recurring)
- Error signals: HTTP status codes, error messages, exception stack traces, correlation IDs
- Recent changes: Deployment, config update, DNS change, certificate rotation, network topology
- Expected vs. observed: What should happen vs. what actually happened
- User impact: How many users? Business tier? SLA breach?
Decision Tree
Is the service completely unavailable (0% traffic)?
├─ Yes → Check Azure Service Health, then check compute (app/function) status
│ ├─ Resource deleted/stopped? → Restart or redeploy
│ ├─ Resource failed to start? → Check startup logs, quotas
│ └─ Resource healthy but unreachable? → Check network, DNS, firewall
└─ No (partial/slow) → Proceed to performance analysis
Did this occur after a recent deployment or change?
├─ Yes → Suspect new code, config, or infrastructure
│ ├─ Rollback or undo change → Verify symptom resolves
│ └─ If resolved: Root cause is the change; analyze diff
└─ No → Suspect environmental change, quota, or dependent service
Is the issue isolated to one region/subscription or widespread?
├─ Isolated → Check resource-specific logs, networking, IAM
└─ Widespread → Check Azure platform status, quotas, throttling
Workflow
Phase 1: Triage (First 2 minutes)
Check Azure Service Health:
# Portal: Service Health blade
# Or search "Service Health" in Azure portal
# Look for: Incidents, Advisories, Planned Maintenance affecting your region
Verify resource status:
az resource show --ids /subscriptions/$SUBID/resourceGroups/$RG/providers/$TYPE/$NAME
# Check: provisioningState, powerState, healthStatus fields
Check resource limits:
- Has quota been exceeded? (CPU, memory, concurrent connections, API calls/sec)
- Is the resource in a failed provisioning state?
Phase 2: Evidence Gathering (5-15 minutes)
Collect logs from all layers:
Application Logs (Application Insights or Log Analytics):
// Find errors in last hour
traces | where timestamp > ago(1h) and severityLevel >= 2
| summarize count() by tostring(severityLevel), message
Dependency Tracking (what services called what):
dependencies | where timestamp > ago(1h) and success == false
| summarize count() by target, type, resultCode
Network Flow (connectivity issues):
az network watcher flow-log show --resource-group $RG --nsg-name $NSG
# Download NSG flow logs from storage account
Resource Logs (Azure Monitor Diagnostics):
# For Key Vault:
az monitor diagnostic-settings list --resource $KV_ID
# Check: logs enabled, destination correct, retention policy
Extract correlation IDs and trace context:
- Application Insights: Operation ID (shows request chain across services)
- HTTP requests: x-correlation-id, x-request-id headers
- Logs: transaction ID linking app → dependency → database
Timeline of events:
10:30 AM: User reports 500 error
10:31 AM: Error rate spikes to 95%
10:32 AM: Database logs show connection timeout
10:33 AM: DBA identifies firewall rule was deleted
Phase 3: Root Cause Analysis
Check each layer bottom-up:
Infrastructure Layer:
- Is the resource running? (VM status, App Service plan load, Function runtime)
- Are quotas exceeded? (vCPU, disk, network bandwidth, RPS limits)
- Is there a network path? (ping, tracert, NSG rules, firewall)
# Check VM status
az vm get-instance-view --resource-group $RG --name $VM --query 'instanceView.statuses'
# Check App Service plan utilization
az monitor metrics list --resource $PLAN_ID --metric "CpuPercentage,MemoryPercentage"
Network Layer:
- Can DNS resolve? (nslookup, dig)
- Is there routing? (ip route show, traceroute)
- Are NSGs blocking traffic? (check inbound/outbound rules)
- Is private endpoint configured correctly? (DNS name resolution, IP routing)
# Test DNS from within the resource:
nslookup myapp.azurewebsites.net
# If fails: Check private DNS zones, conditional forwarders
Identity Layer:
- Does managed identity have permissions? (RBAC role assignments)
- Is Key Vault access allowed? (network rules, access policies, RBAC)
- Has credential rotated or expired? (service principal secret)
# Check role assignment
az role assignment list --assignee $PRINCIPAL_ID --scope $SCOPE
# Verify Key Vault access
az keyvault key list --vault-name $KV --query '[].name'
Data Layer:
- Is the database accessible? (connection string, firewall, availability)
- Are credentials valid? (username, password, connection string format)
- Is there replication lag or transaction lock? (database health check)
# Check SQL database connectivity
sqlcmd -S $SERVER.database.windows.net -U $USER -P $PWD -Q "SELECT 1"
Application Layer:
- Is there a code bug? (recent deployment, null pointer, logic error)
- Are resource limits exhausted? (connection pool, memory, threads)?
- Is there an unhandled exception? (check exception logs)
Phase 4: Hypothesis Testing
Form and test one hypothesis at a time:
Hypothesis 1: Network connectivity broken
→ Test: Can ping the endpoint? Can telnet to port?
→ Result: YES/NO → Adjust hypothesis or confirm
Hypothesis 2: Identity permissions missing
→ Test: Run az role assignment list for managed identity
→ Result: Missing "Key Vault Secrets User" role → CONFIRMED
Hypothesis 3: Quota exceeded
→ Test: az vm list-usage --location eastus --query "[?name.value=='cores'].currentValue"
→ Result: 100 cores used, limit 98 → CONFIRMED
Phase 5: Implement & Verify Fix
Minimal reversible fix:
- Do NOT make multiple changes at once
- Prefer configuration change over code deployment
- Have rollback plan ready
Verify the fix:
# Run post-fix validation
# 1. Service health check passes
# 2. Error rate returns to baseline
# 3. Latency within SLA
# 4. No cascading failures in dependent services
Monitor for 5-10 minutes:
- Is error rate stable and low?
- Are there any new errors in logs?
- Have dependent services recovered?
Output Contract
Problem Statement
- What users experience (HTTP 500, timeout, latency)
- When it started, how long it lasted
- Blast radius (% of users, which regions/tiers)
Root Cause (with Evidence)
- Most likely cause with 2-3 supporting log entries
- Alternative causes if root cause is 70-80% confidence
Supporting Evidence
- Log excerpts showing the failure
- Correlation IDs linking events across services
- Timeline of events
Fix Actions (step-by-step, reversible)
- Exact commands or portal steps
- Expected wait time for fix to take effect
- Rollback procedure if fix doesn't work
Verification Checklist
- Smoke test (e.g., GET /health returns 200)
- Full transaction test (e.g., POST /order, verify in database)
- Dependent service test (e.g., can call downstream API)
Prevention & Lessons Learned
- Alert that should have caught this earlier
- Configuration or IaC change to prevent recurrence
- Post-incident runbook for next time
Guardrails
- Separate facts from assumptions: Show evidence for each claim.
- Prefer reversible fixes: Change config before redeploying code.
- Avoid blame: Focus on systems, not people ("firewall rule was deleted" not "DBA made a mistake").
- Keep timeline explicit: Timestamps matter for correlation.
- Do not guess: If logs don't show the cause, keep investigating; don't assume.
- Test rollback: Never assume rollback works without testing.
- Create post-incident runbook: Document for faster diagnosis next time.
1---2name: azure-diagnostics3description: Diagnose Azure application and infrastructure issues with a structured, evidence-based workflow. Use this skill when users ask to troubleshoot outages, latency, failures, configuration drift, or anomalies. Root cause analysis using logs, metrics, traces, and dependency mapping.4---56# Azure Diagnostics78Troubleshoot Azure problems systematically: narrow scope, gather evidence, form hypotheses, validate fixes.9Use structured root cause analysis to prevent recurrence.1011## Use This Skill When1213- The user reports application downtime, errors, or performance regression14- Deployments succeed but service behavior is broken or degraded15- There are connectivity, identity, DNS, scaling, or quota issues16- Configuration drift or unexpected resource state is observed17- Error messages are cryptic or originating from dependent services1819## Context: Incident Classification2021**Availability** (0% traffic passing): Database down, network cut, authentication broken 22**Degradation** (partial traffic/slowness): High latency, connection pool exhaustion, throttling 23**Configuration drift**: Resource settings changed outside IaC, policy violation, quota exceeded 24**Data integrity**: Corruption, replication lag, backup failure 25**Security**: Unauthorized access, malicious activity, compliance violation 2627## Required Inputs2829- **Affected resources**: Service name, region, resource group30- **Symptom timeline**: Start time, duration, frequency (one-off or recurring)31- **Error signals**: HTTP status codes, error messages, exception stack traces, correlation IDs32- **Recent changes**: Deployment, config update, DNS change, certificate rotation, network topology33- **Expected vs. observed**: What should happen vs. what actually happened34- **User impact**: How many users? Business tier? SLA breach?3536## Decision Tree3738```39Is the service completely unavailable (0% traffic)?40├─ Yes → Check Azure Service Health, then check compute (app/function) status41│ ├─ Resource deleted/stopped? → Restart or redeploy42│ ├─ Resource failed to start? → Check startup logs, quotas43│ └─ Resource healthy but unreachable? → Check network, DNS, firewall44└─ No (partial/slow) → Proceed to performance analysis4546Did this occur after a recent deployment or change?47├─ Yes → Suspect new code, config, or infrastructure48│ ├─ Rollback or undo change → Verify symptom resolves49│ └─ If resolved: Root cause is the change; analyze diff50└─ No → Suspect environmental change, quota, or dependent service5152Is the issue isolated to one region/subscription or widespread?53├─ Isolated → Check resource-specific logs, networking, IAM54└─ Widespread → Check Azure platform status, quotas, throttling55```5657## Workflow5859### Phase 1: Triage (First 2 minutes)60611. **Check Azure Service Health**:62 ```bash63 # Portal: Service Health blade64 # Or search "Service Health" in Azure portal65 # Look for: Incidents, Advisories, Planned Maintenance affecting your region66 ```67682. **Verify resource status**:69 ```bash70 az resource show --ids /subscriptions/$SUBID/resourceGroups/$RG/providers/$TYPE/$NAME71 # Check: provisioningState, powerState, healthStatus fields72 ```73743. **Check resource limits**:75 - Has quota been exceeded? (CPU, memory, concurrent connections, API calls/sec)76 - Is the resource in a failed provisioning state?7778### Phase 2: Evidence Gathering (5-15 minutes)79801. **Collect logs from all layers**:81 82 **Application Logs** (Application Insights or Log Analytics):83 ```kql84 // Find errors in last hour85 traces | where timestamp > ago(1h) and severityLevel >= 286 | summarize count() by tostring(severityLevel), message87 ```8889 **Dependency Tracking** (what services called what):90 ```kql91 dependencies | where timestamp > ago(1h) and success == false92 | summarize count() by target, type, resultCode93 ```9495 **Network Flow** (connectivity issues):96 ```bash97 az network watcher flow-log show --resource-group $RG --nsg-name $NSG98 # Download NSG flow logs from storage account99 ```100101 **Resource Logs** (Azure Monitor Diagnostics):102 ```bash103 # For Key Vault:104 az monitor diagnostic-settings list --resource $KV_ID105 # Check: logs enabled, destination correct, retention policy106 ```1071082. **Extract correlation IDs and trace context**:109 ```110 - Application Insights: Operation ID (shows request chain across services)111 - HTTP requests: x-correlation-id, x-request-id headers112 - Logs: transaction ID linking app → dependency → database113 ```1141153. **Timeline of events**:116 ```117 10:30 AM: User reports 500 error118 10:31 AM: Error rate spikes to 95%119 10:32 AM: Database logs show connection timeout120 10:33 AM: DBA identifies firewall rule was deleted121 ```122123### Phase 3: Root Cause Analysis124125**Check each layer bottom-up**:1261271. **Infrastructure Layer**:128 - Is the resource running? (VM status, App Service plan load, Function runtime)129 - Are quotas exceeded? (vCPU, disk, network bandwidth, RPS limits)130 - Is there a network path? (ping, tracert, NSG rules, firewall)131132 ```bash133 # Check VM status134 az vm get-instance-view --resource-group $RG --name $VM --query 'instanceView.statuses'135 136 # Check App Service plan utilization137 az monitor metrics list --resource $PLAN_ID --metric "CpuPercentage,MemoryPercentage"138 ```1391402. **Network Layer**:141 - Can DNS resolve? (nslookup, dig)142 - Is there routing? (ip route show, traceroute)143 - Are NSGs blocking traffic? (check inbound/outbound rules)144 - Is private endpoint configured correctly? (DNS name resolution, IP routing)145146 ```bash147 # Test DNS from within the resource:148 nslookup myapp.azurewebsites.net149 # If fails: Check private DNS zones, conditional forwarders150 ```1511523. **Identity Layer**:153 - Does managed identity have permissions? (RBAC role assignments)154 - Is Key Vault access allowed? (network rules, access policies, RBAC)155 - Has credential rotated or expired? (service principal secret)156157 ```bash158 # Check role assignment159 az role assignment list --assignee $PRINCIPAL_ID --scope $SCOPE160 161 # Verify Key Vault access162 az keyvault key list --vault-name $KV --query '[].name'163 ```1641654. **Data Layer**:166 - Is the database accessible? (connection string, firewall, availability)167 - Are credentials valid? (username, password, connection string format)168 - Is there replication lag or transaction lock? (database health check)169170 ```bash171 # Check SQL database connectivity172 sqlcmd -S $SERVER.database.windows.net -U $USER -P $PWD -Q "SELECT 1"173 ```1741755. **Application Layer**:176 - Is there a code bug? (recent deployment, null pointer, logic error)177 - Are resource limits exhausted? (connection pool, memory, threads)?178 - Is there an unhandled exception? (check exception logs)179180### Phase 4: Hypothesis Testing181182**Form and test one hypothesis at a time**:183184```185Hypothesis 1: Network connectivity broken186 → Test: Can ping the endpoint? Can telnet to port?187 → Result: YES/NO → Adjust hypothesis or confirm188189Hypothesis 2: Identity permissions missing190 → Test: Run az role assignment list for managed identity191 → Result: Missing "Key Vault Secrets User" role → CONFIRMED192193Hypothesis 3: Quota exceeded194 → Test: az vm list-usage --location eastus --query "[?name.value=='cores'].currentValue"195 → Result: 100 cores used, limit 98 → CONFIRMED196```197198### Phase 5: Implement & Verify Fix1992001. **Minimal reversible fix**:201 - Do NOT make multiple changes at once202 - Prefer configuration change over code deployment203 - Have rollback plan ready2042052. **Verify the fix**:206 ```bash207 # Run post-fix validation208 # 1. Service health check passes209 # 2. Error rate returns to baseline210 # 3. Latency within SLA211 # 4. No cascading failures in dependent services212 ```2132143. **Monitor for 5-10 minutes**:215 - Is error rate stable and low?216 - Are there any new errors in logs?217 - Have dependent services recovered?218219## Output Contract2202211. **Problem Statement**222 - What users experience (HTTP 500, timeout, latency)223 - When it started, how long it lasted224 - Blast radius (% of users, which regions/tiers)2252262. **Root Cause (with Evidence)**227 - Most likely cause with 2-3 supporting log entries228 - Alternative causes if root cause is 70-80% confidence2292303. **Supporting Evidence**231 - Log excerpts showing the failure232 - Correlation IDs linking events across services233 - Timeline of events2342354. **Fix Actions** (step-by-step, reversible)236 - Exact commands or portal steps237 - Expected wait time for fix to take effect238 - Rollback procedure if fix doesn't work2392405. **Verification Checklist**241 - Smoke test (e.g., GET /health returns 200)242 - Full transaction test (e.g., POST /order, verify in database)243 - Dependent service test (e.g., can call downstream API)2442456. **Prevention & Lessons Learned**246 - Alert that should have caught this earlier247 - Configuration or IaC change to prevent recurrence248 - Post-incident runbook for next time249250## Guardrails251252- **Separate facts from assumptions**: Show evidence for each claim.253- **Prefer reversible fixes**: Change config before redeploying code.254- **Avoid blame**: Focus on systems, not people ("firewall rule was deleted" not "DBA made a mistake").255- **Keep timeline explicit**: Timestamps matter for correlation.256- **Do not guess**: If logs don't show the cause, keep investigating; don't assume.257- **Test rollback**: Never assume rollback works without testing.258- **Create post-incident runbook**: Document for faster diagnosis next time.