Azure Cost Optimization
Identify Azure cost savings from usage and spending data. USE FOR: optimize Azure costs, reduce Azure spending/expenses, analyze Azure costs, find cost savings, generate cost optimization report, identify orphaned resources to delete, rightsize VMs, reduce waste, optimize Redis costs, optimize storage costs, AKS cost analysis add-on, namespace cost, cost spike, anomaly, budget alert, AKS cost visibility. DO NOT USE FOR: deploying resources (use azure-deploy), general Azure diagnostics (use azure-diagnostics), security issues (use azure-security)
- Skill ID
- microsoft/azure-skills/azure-cost-optimization
- Publisher
- microsoft
- Repository
- azure-skills
- Installs
- 0
- Files
- 10
- License
- MIT
- Synced
- Sep 16, 2026
Open any RiverX project, open the Skills panel in the chat, and search for this identifier. The files are fetched from the source repository at install time.
microsoft/azure-skills/azure-cost-optimizationInstalls these files- SKILL.md
- references/auth-best-practices.md
- references/azure-aks-anomalies.md
- references/azure-aks-cost-addon.md
- references/azure-quick-review.md
- references/azure-redis.md
- references/azure-resource-graph.md
- references/sdk/azure-resource-manager-redis-dotnet.md
- templates/redis-detailed-cache-analysis.md
- templates/redis-subscription-level-report.md
What this skill tells the agent
Azure Cost Optimization Skill
Analyze Azure subscriptions to identify cost savings through orphaned resource cleanup, rightsizing, and optimization recommendations based on actual usage data.
When to Use This Skill
Use this skill when the user asks to:
- Optimize Azure costs or reduce spending
- Analyze Azure subscription for cost savings
- Generate cost optimization report
- Find orphaned or unused resources
- Rightsize Azure VMs, containers, or services
- Identify where they're overspending in Azure
- Optimize Redis costs specifically - See Azure Redis Cost Optimization for Redis-specific analysis
Instructions
Follow these steps in conversation with the user:
Step 0: Validate Prerequisites
Before starting, verify these tools and permissions are available:
Required Tools:
- Azure CLI installed and authenticated (
az login) - Azure CLI extensions:
costmanagement,resource-graph - Azure Quick Review (azqr) installed - See Azure Quick Review for details
Required Permissions:
- Cost Management Reader role
- Monitoring Reader role
- Reader role on subscription/resource group
Verification commands:
az --version
az account show
az extension show --name costmanagement
azqr versionStep 1: Load Best Practices
Get Azure cost optimization best practices to inform recommendations:
// Use Azure MCP best practices tool
mcp_azure_mcp_get_azure_bestpractices({
intent: "Get cost optimization best practices",
command: "get_bestpractices",
parameters: { resource: "cost-optimization", action: "all" }
})Step 1.5: Redis-Specific Analysis (Conditional)
If the user specifically requests Redis cost optimization, use the specialized Redis skill:
📋 Reference: Azure Redis Cost Optimization
When to use Redis-specific analysis:
- User mentions "Redis", "Azure Cache for Redis", or "Azure Managed Redis"
- Focus is on Redis resource optimization, not general subscription analysis
- User wants Redis-specific recommendations (SKU downgrade, failed caches, etc.)
Key capabilities:
- Interactive subscription filtering (prefix, ID, or "all subscriptions")
- Redis-specific optimization rules (failed caches, oversized tiers, missing tags)
- Pre-built report templates for Redis cost analysis
- Uses
redis_listcommand
Report templates available:
- Subscription-level Redis summary
- Detailed Redis cache analysis
Note: For general subscription-wide cost optimization (including Redis), continue with Step 2. For Redis-only focused analysis, follow the instructions in the Redis-specific reference document.
Step 1.6: Choose Analysis Scope (for Redis-specific analysis)
If performing Redis cost optimization, ask the user to select their analysis scope:
Prompt the user with these options:
- Specific Subscription ID - Analyze a single subscription
- Subscription Name - Use display name instead of ID
- Subscription Prefix - Analyze all subscriptions starting with a prefix (e.g., "CacheTeam")
- All My Subscriptions - Scan all accessible subscriptions
- Tenant-wide - Analyze entire organization
Wait for user response, then proceed to Step 2.
Step 1.7: AKS-Specific Analysis (Conditional)
If the user specifically requests AKS cost optimization, use the specialized AKS reference files:
When to use AKS-specific analysis:
- User mentions "AKS", "Kubernetes", "cluster", "node pool", "pod", or "kubectl"
- User wants to enable the AKS cost analysis add-on or namespace cost visibility
- User reports a cost spike, unusual cluster utilization, or wants budget alerts
Tool Selection:
- Prefer MCP first: Use
mcp_azure_mcp_aksfor AKS operations (list clusters, get node pools, inspect configuration) — it provides richer metadata and is consistent with AKS skill conventions in this repo - Fall back to CLI: Use
az aksandkubectlonly when the specific operation cannot be performed via the MCP surface
Reference files (load only what is needed for the request):
- Cost Analysis Add-on — enable namespace-level cost visibility
- Anomaly Investigation — cost spikes, scaling events, budget alerts
Note: For general subscription-wide cost optimization (including AKS resource groups), continue with Step 2. For AKS-focused analysis, follow the instructions in the relevant reference file above.
Step 1.8: Choose Analysis Scope (for AKS-specific analysis)
If performing AKS cost optimization, ask the user to select their analysis scope:
Prompt the user with these options:
- Specific Cluster Name - Analyze a single AKS cluster
- Resource Group - Analyze all clusters in a resource group
- Subscription ID - Analyze all clusters in a subscription
- All My Clusters - Scan all accessible clusters across subscriptions
Wait for user response before proceeding to Step 2.
Step 2: Run Azure Quick Review
Run azqr to find orphaned resources (immediate cost savings):
📋 Reference: Azure Quick Review - Detailed instructions for running azqr scans
// Use Azure MCP extension_azqr tool
extension_azqr({
subscription: "<SUBSCRIPTION_ID>",
"resource-group": "<RESOURCE_GROUP>" // optional
})What to look for in azqr results:
- Orphaned resources: unattached disks, unused NICs, idle NAT gateways
- Over-provisioned resources: excessive retention periods, oversized SKUs
- Missing cost tags: resources without proper cost allocation
Note: The Azure Quick Review reference document includes instructions for creating filter configurations, saving output to the output/ folder, and interpreting results for cost optimization.Step 3: Discover Resources
For efficient cross-subscription resource discovery, use Azure Resource Graph. See Azure Resource Graph Queries for orphaned resource detection and cost optimization patterns.
List all resources in the subscription using Azure MCP tools or CLI:
# Get subscription info
az account show
# List all resources
az resource list --subscription "<SUBSCRIPTION_ID>" --resource-group "<RESOURCE_GROUP>"
# Use MCP tools for specific services (preferred):
# - Storage accounts, Cosmos DB, Key Vaults: use Azure MCP tools
# - Redis caches: use mcp_azure_mcp_redis tool (see ./references/azure-redis.md)
# - Web apps, VMs, SQL: use az CLI commandsStep 4: Query Actual Costs
Get actual cost data from Azure Cost Management API (last 30 days):
Create cost query file:
Create temp/cost-query.json with:
{
"type": "ActualCost",
"timeframe": "Custom",
"timePeriod": {
"from": "<START_DATE>",
"to": "<END_DATE>"
},
"dataset": {
"granularity": "None",
"aggregation": {
"totalCost": {
"name": "Cost",
"function": "Sum"
}
},
"grouping": [
{
"type": "Dimension",
"name": "ResourceId"
}
]
}
}Action Required: Calculate<START_DATE>(30 days ago) and<END_DATE>(today) in ISO 8601 format (e.g.,2025-11-03T00:00:00Z).
Execute cost query:
# Create temp folder
New-Item -ItemType Directory -Path "temp" -Force
# Query using REST API (more reliable than az costmanagement query)
az rest --method post `
--url "https://management.azure.com/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP>/providers/Microsoft.CostManagement/query?api-version=2023-11-01" `
--body '@temp/cost-query.json'Important: Save the query results to output/cost-query-result<timestamp>.json for audit trail.
