Azure diagnostics

From manu14357/zskills · View interactive version

Azure diagnostics is an AI agent skill from the GitHub repository manu14357/zskills. 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.

How to use this skill

Skill file

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

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

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)

  1. Check Azure Service Health:

```bash

# Portal: Service Health blade

# Or search "Service Health" in Azure portal

# Look for: Incidents, Advisories, Planned Maintenance affecting your region

```

  1. Verify resource status:

```bash

az resource show --ids /subscriptions/$SUBID/resourceGroups/$RG/providers/$TYPE/$NAME

# Check: provisioningState, powerState, healthStatus fields

```

  1. Check resource limits:

Phase 2: Evidence Gathering (5-15 minutes)

  1. Collect logs from all layers:

Application Logs (Application Insights or Log Analytics):

```kql

// 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):

```kql

dependencies | where timestamp > ago(1h) and success == false

| summarize count() by target, type, resultCode

```

Network Flow (connectivity issues):

```bash

az network watcher flow-log show --resource-group $RG --nsg-name $NSG

# Download NSG flow logs from storage account

```

Resource Logs (Azure Monitor Diagnostics):

```bash

# For Key Vault:

az monitor diagnostic-settings list --resource $KV_ID

# Check: logs enabled, destination correct, retention policy

```

  1. Extract correlation IDs and trace context:

```

```

  1. 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:

  1. Infrastructure Layer:

```bash

# 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"

```

  1. Network Layer:

```bash

# Test DNS from within the resource:

nslookup myapp.azurewebsites.net

# If fails: Check private DNS zones, conditional forwarders

```

  1. Identity Layer:

```bash

# 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'

```

  1. Data Layer:

```bash

# Check SQL database connectivity

sqlcmd -S $SERVER.database.windows.net -U $USER -P $PWD -Q "SELECT 1"

```

  1. Application Layer:

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

  1. Minimal reversible fix:
  1. Verify the fix:

```bash

# 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

```

  1. Monitor for 5-10 minutes:

Output Contract

  1. Problem Statement
  1. Root Cause (with Evidence)
  1. Supporting Evidence
  1. Fix Actions (step-by-step, reversible)
  1. Verification Checklist
  1. Prevention & Lessons Learned

Guardrails

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.