azure-cost-optimization

microsoft/github-copilot-for-azure · updated Apr 8, 2026

MDX-style export adds YAML metadata + attribution linking explainx.ai and this canonical listing URL.

$npx skills add https://github.com/microsoft/github-copilot-for-azure --skill azure-cost-optimization
0 commentsdiscussion
summary

Identify and quantify Azure cost savings through resource analysis, utilization metrics, and actionable optimization recommendations.

  • Discovers orphaned resources (unattached disks, unused NICs, idle gateways) and over-provisioned services using Azure Quick Review scans
  • Queries actual costs from Azure Cost Management API and utilization data from Azure Monitor to support rightsizing recommendations
  • Generates prioritized optimization reports with estimated savings, validated pricing,
skill.md

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 version

Step 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_list command

Report templates available:

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:

  1. Specific Subscription ID - Analyze a single subscription
  2. Subscription Name - Use display name instead of ID
  3. Subscription Prefix - Analyze all subscriptions starting with a prefix (e.g., "CacheTeam")
  4. All My Subscriptions - Scan all accessible subscriptions
  5. 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_aks for 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 aks and kubectl only when the specific operation cannot be performed via the MCP surface

Reference files (load only what is needed for the request):

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:

  1. Specific Cluster Name - Analyze a single AKS cluster
  2. Resource Group - Analyze all clusters in a resource group
  3. Subscription ID - Analyze all clusters in a subscription
  4. 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 commands

Step 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.

Step 5: Validate Pricing

Fetch current pricing from official Azure pricing pages using fetch_webpage:

// Validate pricing for key services
fetch_webpage({
  urls: ["https://azure.microsoft.com/en-us/pricing/details/container-apps/"],
  query: "pricing tiers and costs"
})

Key services to validate:

Important: Check for free tier allowances - many Azure services have generous free limits that may explain $0 costs.

Step 6: Collect Utilization Metrics

Query Azure Monitor for utilization data (last 14 days) to support rightsizing recommendations:

# Calculate dates for last 14 days
$startTime = (Get-Date).AddDays(-14).ToString("yyyy-MM-ddTHH:mm:ssZ")
$endTime = Get-Date -Format "yyyy-MM-ddTHH:mm:ssZ"

# VM CPU utilization
az monitor metrics list `
  --resource "<RESOURCE_ID>" `
  --metric "Percentage CPU" `
  --interval PT1H `
  --aggregation Average `
  --start-time $startTime `
  --end-time $endTime

# App Service Plan utilization
az monitor metrics list `
  --resource "<RESOURCE_ID>" `
  --metric "CpuTime,Requests" `
  --interval PT1H `
  --aggregation Total `
  --start-time $startTime `
  --end-time $endTime

# Storage capacity
az monitor metrics list `
  --resource "<RESOURCE_ID>" `
  --metric "UsedCapacity,BlobCount" `
  --interval PT1H `
  --aggregation Average `
  --start-time $startTime `
  --end-time $endTime

Step 7: Generate Optimization Report

Create a comprehensive cost optimization report in the output/

how to use azure-cost-optimization

How to use azure-cost-optimization on Cursor

AI-first code editor with Composer

1

Prerequisites

Before installing skills in Cursor, ensure your development environment meets these requirements:

  • Cursor installed and configured on your development machine
  • Node.js version 16.0+ with npm package manager (verify with node --version)
  • Active project directory or workspace where you want to add azure-cost-optimization
2

Execute installation command

Execute the skills CLI command in your project's root directory to begin installation:

$npx skills add https://github.com/microsoft/github-copilot-for-azure --skill azure-cost-optimization

The skills CLI fetches azure-cost-optimization from GitHub repository microsoft/github-copilot-for-azure and configures it for Cursor.

3

Select Cursor when prompted

The CLI will show a list of available agents. Use arrow keys to navigate and space to select Cursor:

◆ Which agents do you want to install to?
│ ── Universal (.agents/skills) ── always included ────
│ • Amp
│ • Antigravity
│ • Cline
│ • Codex
│ ●Cursor(selected)
│ • Cursor
│ • Windsurf
4

Verify installation

Confirm successful installation by checking the skill directory location:

.cursor/skills/azure-cost-optimization

Reload or restart Cursor to activate azure-cost-optimization. Access the skill through slash commands (e.g., /azure-cost-optimization) or your agent's skill management interface.

Security & Verification Notice

We perform automated surface-level scans (Gen AI Scanner, Socket, Snyk) during installation. These checks detect common vulnerabilities but do not guarantee complete security. Always review skill source code and verify the publisher's reputation before production use.

Skills execute code in your development environment. Always verify the publisher's identity, review recent commits, and test in isolated environments before production deployment.

List & Monetize Your Skill

Submit your Claude Code skill and start earning

GET_STARTED →

Use Cases

Task Automation & Efficiency

Automate repetitive workflows and reduce manual effort

Example

Generate reports, summarize documents, draft communications

Save 3-5 hours per week on routine tasks

Knowledge Enhancement

Learn new skills, understand complex topics, get expert guidance

Example

Explain concepts, provide examples, suggest learning resources

Accelerate learning and skill development by 2x

Quality Improvement

Enhance output quality through reviews, suggestions, and refinements

Example

Review drafts, suggest improvements, catch errors

Improve work quality by 30-40% with less effort

Implementation Guide

Prerequisites

  • Claude Desktop or compatible AI client with skill support
  • Clear understanding of task or problem to solve
  • Willingness to iterate and refine outputs

Time Estimate

15-45 minutes depending on use case complexity

Installation Steps

  1. 1.Install skill using provided installation command
  2. 2.Test with simple use case relevant to your work
  3. 3.Evaluate output quality and relevance
  4. 4.Iterate on prompts to improve results
  5. 5.Integrate into regular workflow if valuable

Common Pitfalls

  • Expecting perfect results without iteration
  • Not providing enough context in prompts
  • Using skill for tasks outside its intended scope
  • Accepting outputs without review and validation

Best Practices

✓ Do

  • +Start with clear, specific prompts
  • +Provide relevant context and constraints
  • +Review and refine all outputs before using
  • +Iterate to improve output quality
  • +Document successful prompt patterns

✗ Don't

  • Don't use without understanding skill limitations
  • Don't skip validation of outputs
  • Don't share sensitive information in prompts
  • Don't expect skill to replace human judgment

💡 Pro Tips

  • Be specific about desired format and style
  • Ask for multiple options to choose from
  • Request explanations to understand reasoning
  • Combine AI efficiency with human expertise

When to Use This

✓ Use When

Use when skill capabilities match your task, clear ROI on time saved, and you can validate outputs. Best for repetitive tasks, learning, and quality improvement.

✗ Avoid When

Avoid when task requires deep expertise you can't validate, involves sensitive decisions, or when learning process is more valuable than speed of completion.

Learning Path

  1. 1Familiarize yourself with skill capabilities and limitations
  2. 2Start with low-risk, non-critical tasks
  3. 3Progress to more complex and valuable use cases
  4. 4Build expertise through regular use and experimentation

Discussion

Product Hunt–style comments (not star reviews)
  • No comments yet — start the thread.
general reviews

Ratings

4.774 reviews
  • Aarav Yang· Dec 24, 2024

    azure-cost-optimization fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.

  • Alexander Tandon· Dec 20, 2024

    We added azure-cost-optimization from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.

  • Charlotte Wang· Dec 20, 2024

    I recommend azure-cost-optimization for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.

  • Shikha Mishra· Dec 8, 2024

    Registry listing for azure-cost-optimization matched our evaluation — installs cleanly and behaves as described in the markdown.

  • Valentina Zhang· Dec 4, 2024

    azure-cost-optimization fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.

  • Yash Thakker· Nov 27, 2024

    Solid pick for teams standardizing on skills: azure-cost-optimization is focused, and the summary matches what you get after install.

  • Ira Choi· Nov 23, 2024

    We added azure-cost-optimization from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.

  • Sakshi Patil· Nov 19, 2024

    azure-cost-optimization reduced setup friction for our internal harness; good balance of opinion and flexibility.

  • Carlos Malhotra· Nov 15, 2024

    We added azure-cost-optimization from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.

  • Alexander Okafor· Nov 11, 2024

    azure-cost-optimization fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.

showing 1-10 of 74

1 / 8