Azure Cost
Unified Azure cost management capabilities across three primary workflows: querying historical costs, forecasting future spending, and optimizing resource usage.
Core Functions
| Workflow | API | Purpose |
|---|---|---|
| Query Historical Costs | POST {scope}/providers/Microsoft.CostManagement/query?api-version=2023-11-01 |
Analyze spending patterns by service, resource, location, or tag |
| Forecast Future Spending | POST {scope}/providers/Microsoft.CostManagement/forecast?api-version=2023-11-01 |
Project end-of-month and future costs |
| Optimize Spending | Multiple APIs | Identify orphaned resources, rightsize VMs, find savings |
Required Access
Roles needed: Cost Management Reader + Monitoring Reader + Reader on the appropriate scope.
Supported scopes: subscription, resource group, management group, billing account.
Essential Best Practices
- Always query actual costs from Azure APIs before making recommendations
- Present total bills alongside optimization suggestions
- Validate pricing from official Azure sources
- Include the header
ClientType: GitHubCopilotForAzureon all Cost Management API requests - Respect rate limits (4 requests/minute per scope); check
retry-afterheaders on 429 responses
Query Example
POST /subscriptions/{subscriptionId}/providers/Microsoft.CostManagement/query?api-version=2023-11-01
Content-Type: application/json
ClientType: GitHubCopilotForAzure
{
"type": "ActualCost",
"timeframe": "MonthToDate",
"dataset": {
"granularity": "Daily",
"grouping": [
{ "type": "Dimension", "name": "ServiceName" }
]
}
}
Optimization Targets
- Orphaned resources (unattached disks, unused IPs, empty resource groups)
- Oversized VMs (rightsize to smaller SKUs based on CPU/memory utilization)
- Reserved Instance opportunities (commit for 1 or 3 years for significant discounts)
- Spot/preemptible instances for fault-tolerant workloads
Scope
This skill excludes:
- Resource deployment or infrastructure provisioning
- Security audits
- Cost estimation for resources not yet deployed
Installation
npx skills add https://github.com/microsoft/azure-skills --skill azure-cost
Mirrored from https://github.com/microsoft/azure-skills — original author: microsoft, license: MIT. This is an unclaimed mirror. Content and ownership transfer to the author when they claim this account.