| name | az-cost-optimize |
| description | Azure cost optimization workflow for Terraform IaC and deployed resources. Use when analyzing Azure spend, reducing costs, finding right-sizing opportunities, comparing dev/uat/prd environments, or creating cost optimization recommendations for Container Apps, PostgreSQL, Redis, Service Bus, Event Hubs, Storage, Key Vault, and Log Analytics. |
Azure Cost Optimization
Source: adapted from github/awesome-copilot skill az-cost-optimize and narrowed to this repository's Terraform-first Azure architecture.
When to Use
- The user asks to reduce Azure costs, estimate savings, or identify cost drivers
- Reviewing
infra/**/*.tf or infra/environments/*.tfvars for cost impact
- Comparing
dev, uat, and prd environment SKUs
- Creating GitHub issues for approved optimization work
Guardrails
- Start with Azure best practices guidance when Azure MCP best-practices tooling is available.
- Treat Terraform as the source of truth. Read IaC and tfvars files before inspecting live resources.
- Do not create GitHub issues or modify Terraform until the user approves the recommendations.
- Never recommend manual Azure Portal changes as the primary fix. Prefer Terraform changes.
- Keep subscription IDs as runtime inputs; never hardcode them.
- Do not inspect application files unless needed to understand a resource's usage pattern.
Workflow
- Read
.github/copilot-instructions.md, .github/instructions/terraform.instructions.md, and the target infra/environments/*.tfvars files.
- Identify cost-significant resources and dimensions:
- Azure Container Apps CPU, memory, min/max replicas, ingress, and scale-to-zero settings
- PostgreSQL SKU, storage, backup retention, high availability, and public/private networking
- Redis SKU and capacity
- Service Bus SKU and messaging units
- Event Hubs SKU, throughput units, retention, and capture settings
- Storage replication, lifecycle policies, access tier, blob soft delete, and retention
- Log Analytics ingestion and retention assumptions
- Use the
azure-pricing skill or Azure MCP pricing tools to validate current and target monthly costs.
- If the user asks for live-resource analysis, list subscriptions and resource groups, then inspect only the relevant resource group(s). Prefer Azure MCP tools over raw Azure CLI when available.
- Calculate each opportunity:
Monthly Savings = Current Monthly Cost - Target Monthly Cost
Priority Score = (Value Score x Monthly Savings) / (Risk Score x Implementation Days)
- Classify opportunities:
- High: material savings, low implementation risk, no architecture change
- Medium: meaningful savings with testing or workload validation needed
- Low: small savings or changes that may reduce demo clarity
- Present a recommendation report and ask for approval before creating issues or editing files.
Recommendation Template
## Azure Cost Optimization Report
| Priority | Resource | Current | Recommended | Est. Savings/mo | Risk | Implementation |
|---|---|---|---|---:|---|---|
| High | Container Apps backend | min replicas 1 | min replicas 0 in dev | $X | Low | Update dev.tfvars |
### Evidence
- Pricing source: [Azure Retail Prices API or MCP result]
- Usage signal: [Terraform setting, metric, or stated assumption]
- Best practice alignment: [managed identity, right-sizing, scale-to-zero, lifecycle policy, etc.]
### Next Steps
1. [Terraform file or setting to change]
2. [Validation command]
3. [Monitoring or rollback check]
Issue Creation
Only after approval, create one issue per recommendation plus an optional coordinating issue. Use labels cost-optimization and azure when available.