MR
Mayur Rathi
@github
⭐ 34.1k GitHub stars

Az-Cost-Optimize

Az-Cost-Optimize是一款code方向的AI技能,核心价值是Analyze Azure resources used in the app (IaC files and/or resources in a target rg) and optimize costs - creating GitHub issues for identified optimizations,可用于解决开发者在code领域的实际问题,帮助用户提升效率、自动化重复任务或优化工作流。

Analyze Azure resources used in the app (IaC files and/or resources in a target rg) and optimize costs - creating GitHub issues for identified optimizations.

Last verified on: 2026-05-30
mkdir -p ./skills/az-cost-optimize && curl -sfL https://raw.githubusercontent.com/github/awesome-copilot/main/skills/az-cost-optimize/SKILL.md -o ./skills/az-cost-optimize/SKILL.md

Run in terminal / PowerShell. Requires curl (Unix) or PowerShell 5+ (Windows).

Skill Content

# Azure Cost Optimize


This workflow analyzes Infrastructure-as-Code (IaC) files and Azure resources to generate cost optimization recommendations. It creates individual GitHub issues for each optimization opportunity plus one EPIC issue to coordinate implementation, enabling efficient tracking and execution of cost savings initiatives.


Prerequisites

- Azure MCP server configured and authenticated

- GitHub MCP server configured and authenticated

- Target GitHub repository identified

- Azure resources deployed (IaC files optional but helpful)

- Prefer Azure MCP tools (`azmcp-*`) over direct Azure CLI when available


Workflow Steps


Step 1: Get Azure Best Practices

**Action**: Retrieve cost optimization best practices before analysis

**Tools**: Azure MCP best practices tool

**Process**:

1. **Load Best Practices**:

- Execute `azmcp-bestpractices-get` to get some of the latest Azure optimization guidelines. This may not cover all scenarios but provides a foundation.

- Use these practices to inform subsequent analysis and recommendations as much as possible

- Reference best practices in optimization recommendations, either from the MCP tool output or general Azure documentation


Step 2: Discover Azure Infrastructure

**Action**: Dynamically discover and analyze Azure resources and configurations

**Tools**: Azure MCP tools + Azure CLI fallback + Local file system access

**Process**:

1. **Resource Discovery**:

- Execute `azmcp-subscription-list` to find available subscriptions

- Execute `azmcp-group-list --subscription <subscription-id>` to find resource groups

- Get a list of all resources in the relevant group(s):

- Use `az resource list --subscription <id> --resource-group <name>`

- For each resource type, use MCP tools first if possible, then CLI fallback:

- `azmcp-cosmos-account-list --subscription <id>` - Cosmos DB accounts

- `azmcp-storage-account-list --subscription <id>` - Storage accounts

- `azmcp-monitor-workspace-list --subscription <id>` - Log Analytics workspaces

- `azmcp-keyvault-key-list` - Key Vaults

- `az webapp list` - Web Apps (fallback - no MCP tool available)

- `az appservice plan list` - App Service Plans (fallback)

- `az functionapp list` - Function Apps (fallback)

- `az sql server list` - SQL Servers (fallback)

- `az redis list` - Redis Cache (fallback)

- ... and so on for other resource types


2. **IaC Detection**:

- Use `file_search` to scan for IaC files: "**/*.bicep", "**/*.tf", "**/main.json", "**/*template*.json"

- Parse resource definitions to understand intended configurations

- Compare against discovered resources to identify discrepancies

- Note presence of IaC files for implementation recommendations later on

- Do NOT use any other file from the repository, only IaC files. Using other files is NOT allowed as it is not a source of truth.

- If you do not find IaC files, then STOP and report no IaC files found to the user.


3. **Configuration Analysis**:

- Extract current SKUs, tiers, and settings for each resource

- Identify resource relationships and dependencies

- Map resource utilization patterns where available


Step 3: Collect Usage Metrics & Validate Current Costs

**Action**: Gather utilization data AND verify actual resource costs

**Tools**: Azure MCP monitoring tools + Azure CLI

**Process**:

1. **Find Monitoring Sources**:

- Use `azmcp-monitor-workspace-list --subscription <id>` to find Log Analytics workspaces

- Use `azmcp-monitor-table-list --subscription <id> --workspace <name> --table-type "CustomLog"` to discover available data


2. **Execute Usage Queries**:

- Use `azmcp-monitor-log-query` with these predefined queries:

- Query: "recent" for recent activity patterns

- Query: "errors" for error-level logs indicating issues

- For custom analysis, use KQL queries:

```kql

// CPU utilization for App Services

AppServiceAppLogs

| where Ti

🎯 Best For

  • Data analysts
  • Business intelligence teams
  • Claude users
  • GitHub Copilot users
  • Software engineers

💡 Use Cases

  • Finding patterns in customer data
  • Creating automated dashboards
  • Code quality improvement
  • Best practice enforcement

📖 How to Use This Skill

  1. 1

    Install the Skill

    Copy the install command from the Terminal tab and run it. The SKILL.md file downloads to your local skills directory.

  2. 2

    Load into Your AI Assistant

    Open Claude or GitHub Copilot and reference the skill. Paste the SKILL.md content or use the system prompt tab.

  3. 3

    Apply Az-Cost-Optimize to Your Work

    Open your project in the AI assistant and ask it to apply the skill. Start with a small module to verify the output quality.

  4. 4

    Review and Refine

    Review AI suggestions before committing. Run tests, check for regressions, and iterate on the skill output.

❓ Frequently Asked Questions

Can this connect to my database directly?

Most data skills accept CSV or JSON input. Database connectors are listed in the Works With section.

Is Az-Cost-Optimize compatible with Cursor and VS Code?

Yes — this skill works with any AI coding assistant including Cursor, VS Code with Copilot, and JetBrains IDEs.

Do I need specific dependencies for Az-Cost-Optimize?

Check the install command and Works With section. Most code skills only require the AI assistant and your codebase.

How do I install Az-Cost-Optimize?

Copy the install command from the Terminal tab and run it. The skill downloads to ./skills/az-cost-optimize/SKILL.md, ready to use.

Can I customize this skill for my team?

Absolutely. Edit the SKILL.md file to add team-specific instructions, examples, or workflows.

⚠️ Common Mistakes to Avoid

Not validating data quality

AI analysis is only as good as your input data. Profile and clean data before analysis.

Skipping validation

Always test AI-generated code changes, even for simple refactors.

Missing dependency updates

Check if the skill requires updated dependencies or new packages.

🔗 Related Skills