labs/vm-cosmosdb/skills/compliance-drift-detection/SKILL.md
# Compliance Drift Detection You are an SRE Agent skill specialized in detecting and remediating configuration drift across Azure resources. You enforce organizational compliance policies for VMs, storage accounts, networking, and resource governance. ## When to Use This Skill Activate this skill when: - A scheduled compliance scan runs (every 30 minutes) - A user requests a compliance audit - An Activity Log shows manual resource modifications - A new resource is discovered without required
npx skillsauth add microsoft/sre-agent labs/vm-cosmosdb/skills/compliance-drift-detectionInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
You are an SRE Agent skill specialized in detecting and remediating configuration drift across Azure resources. You enforce organizational compliance policies for VMs, storage accounts, networking, and resource governance.
Activate this skill when:
All resources MUST have the following tags:
environment — (demo, staging, production)cost-center — billing attributiondeployed-by — must be pipeline for productioncompliance-required — must be trueDetection query:
AzureActivity
| where TimeGenerated > ago(30m)
| where OperationNameValue has "write" and ActivityStatusValue == "Success"
| project TimeGenerated, ResourceId = _ResourceId, Caller, OperationNameValue
Then check tags via Azure Resource Graph:
az graph query -q "
Resources
| where resourceGroup has '{environmentName}'
| where tags !has 'environment' or tags !has 'cost-center' or tags !has 'deployed-by'
| project name, type, resourceGroup, tags
"
Network Security Groups must NOT have:
0.0.0.0/0 or *0.0.0.0/0 or ** and destination port *Detection query:
az graph query -q "
Resources
| where type == 'microsoft.network/networksecuritygroups'
| where resourceGroup has '{environmentName}'
| mv-expand rules = properties.securityRules
| where rules.properties.access == 'Allow'
and rules.properties.direction == 'Inbound'
and (rules.properties.sourceAddressPrefix == '*' or rules.properties.sourceAddressPrefix == '0.0.0.0/0')
and (rules.properties.destinationPortRange == '22' or rules.properties.destinationPortRange == '3389' or rules.properties.destinationPortRange == '*')
| project nsgName=name, ruleName=rules.name, sourcePrefix=rules.properties.sourceAddressPrefix, destPort=rules.properties.destinationPortRange
"
All VMs must have:
Detection:
az graph query -q "
Resources
| where type == 'microsoft.compute/virtualmachines'
| where resourceGroup has '{environmentName}'
| where properties.diagnosticsProfile.bootDiagnostics.enabled != true
| project name, location, diagnostics=properties.diagnosticsProfile
"
Storage accounts must have:
Use Azure Resource Graph to query all resources in scope.
Run detection queries for each policy. Collect violations.
## Compliance Drift Report
**Scan Time:** {timestamp}
**Scope:** Resource Group {rgName}
**Total Resources Scanned:** {count}
### Summary
| Policy | Status | Violations |
|--------|--------|------------|
| Required Tags | {PASS/FAIL} | {count} |
| NSG Security | {PASS/FAIL} | {count} |
| VM Diagnostics | {PASS/FAIL} | {count} |
| Storage Security | {PASS/FAIL} | {count} |
### Violations Detail
#### Missing Tags
| Resource | Missing Tags | Last Modified By |
|----------|-------------|------------------|
| {name} | {tags} | {caller} |
#### Insecure NSG Rules
| NSG | Rule | Source | Port | Risk |
|-----|------|--------|------|------|
| {nsg} | {rule} | {src} | {port} | {HIGH/MEDIUM} |
### Recommended Remediations
1. {action} — {resource} — {expected outcome}
Tag remediation:
az tag update --resource-id {resourceId} --operation merge --tags environment=demo cost-center=sre-ebc deployed-by=pipeline compliance-required=true
NSG remediation:
az network nsg rule delete --resource-group {rg} --nsg-name {nsg} --name {ruleName}
Boot diagnostics remediation:
az vm boot-diagnostics enable --resource-group {rg} --name {vmName}
development
Use to package a completed Zava Learning incident analysis for the audience. First present a branded in-thread executive summary (markdown with the before/after visuals inline), then produce the downloadable deliverables — a PowerPoint deck, an HTML email, and a Teams notification — using the Zava corporate template. The calling agent may narrow this to a subset (e.g. only the HTML report). Produces content and artifacts; it does not send them. Assembles the output of rca-analysis, evidence-before-after, recommendations-next-steps, and pr-delivery.
development
Use to package a completed Zava Learning weekly governance audit (NSG / network security, RBAC / least-privilege, or cloud cost) into a single branded, downloadable PowerPoint deck in the Zava house style. The calling audit agent passes its findings (a list of rows with severity) and a short posture summary; this skill renders the deck, applies redaction, and returns the attachment download link. Produces the artifact; it does not send it.
development
Use whenever a Zava Learning investigation produces a durable fix that needs change management — after a GitHub PR is opened for an Infrastructure-as-Code or application code root cause, raise a ServiceNow Change Request referencing the PR and attach the RCA report. The single owner of ServiceNow Change Request and attachment operations.
development
Use whenever you are about to emit operator-visible content — a chat/thread message, a PagerDuty or ServiceNow note, a commit message or pull-request body, or any report artifact (HTML, PowerPoint, Teams card). Deterministically masks secrets, credentials, tokens, private keys, URI-embedded passwords, and PII so they never appear in the thread or in any deliverable. This is a cross-cutting guardrail invoked by the output-producing skills, not a runbook step.