az-cost-optimize by github/awesome-copilot
npx skills add https://github.com/github/awesome-copilot --skill az-cost-optimize此工作流分析基础设施即代码(IaC)文件和 Azure 资源,以生成成本优化建议。它为每个优化机会创建单独的 GitHub issue,外加一个 EPIC issue 来协调实施,从而实现对成本节约计划的高效跟踪和执行。
azmcp-*)而非直接使用 Azure CLI操作:在分析前检索成本优化最佳实践 工具:Azure MCP 最佳实践工具 流程:
azmcp-bestpractices-get 以获取一些最新的 Azure 优化指南。这可能无法涵盖所有场景,但提供了基础。操作:动态发现和分析 Azure 资源及配置 工具:Azure MCP 工具 + Azure CLI 备用方案 + 本地文件系统访问 流程:
资源发现:
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
azmcp-subscription-list 以查找可用订阅azmcp-group-list --subscription <subscription-id> 以查找资源组az resource list --subscription <id> --resource-group <name>azmcp-cosmos-account-list --subscription <id> - Cosmos DB 账户azmcp-storage-account-list --subscription <id> - 存储账户azmcp-monitor-workspace-list --subscription <id> - Log Analytics 工作区azmcp-keyvault-key-list - Key Vaultsaz webapp list - Web 应用(备用 - 无可用 MCP 工具)az appservice plan list - 应用服务计划(备用)az functionapp list - 函数应用(备用)az sql server list - SQL 服务器(备用)az redis list - Redis 缓存(备用)IaC 检测:
file_search 扫描 IaC 文件:"/*.bicep"、" /*.tf"、"/main.json"、" /template.json"配置分析:
操作:收集使用数据并验证实际资源成本 工具:Azure MCP 监控工具 + Azure CLI 流程:
查找监控源:
azmcp-monitor-workspace-list --subscription <id> 查找 Log Analytics 工作区azmcp-monitor-table-list --subscription <id> --workspace <name> --table-type "CustomLog" 发现可用数据执行使用情况查询:
使用 azmcp-monitor-log-query 配合以下预定义查询:
对于自定义分析,使用 KQL 查询:
// 应用服务的 CPU 使用率 AppServiceAppLogs | where TimeGenerated > ago(7d) | summarize avg(CpuTime) by Resource, bin(TimeGenerated, 1h)
// Cosmos DB RU 消耗 AzureDiagnostics | where ResourceProvider == "MICROSOFT.DOCUMENTDB" | where TimeGenerated > ago(7d) | summarize avg(RequestCharge) by Resource
// 存储账户访问模式 StorageBlobLogs | where TimeGenerated > ago(7d) | summarize RequestCount=count() by AccountName, bin(TimeGenerated, 1d)
计算基线指标:
验证当前成本:
az billing 命令操作:分析资源以识别优化机会 工具:使用收集的数据进行本地分析 流程:
根据发现的资源类型应用优化模式:
计算优化:
数据库优化:
存储优化:
基础设施优化:
计算基于证据的节约额:
为每个建议计算优先级分数:
优先级分数 = (价值分数 × 月度节约额) / (风险分数 × 实施天数)
高优先级:分数 > 20
中优先级:分数 5-20
低优先级:分数 < 5
验证建议:
操作:在创建 GitHub issue 之前,展示摘要并获取批准 流程:
显示优化摘要:
🎯 Azure 成本优化摘要
📊 分析结果:
• 分析资源总数:X
• 当前月度成本:$X
• 潜在月度节约额:$Y
• 优化机会:Z
• 高优先级项:N
🏆 建议:
1. [资源]:[当前 SKU] → [目标 SKU] = $X/月节约额 - [风险等级] | [实施工作量]
2. [资源]:[当前配置] → [目标配置] = $Y/月节约额 - [风险等级] | [实施工作量]
3. [资源]:[当前配置] → [目标配置] = $Z/月节约额 - [风险等级] | [实施工作量]
... 等等
💡 这将创建:
• Y 个单独的 GitHub issue(每个优化一个)
• 1 个 EPIC issue 用于协调实施
❓ 是否继续创建 GitHub issue?(y/n)
等待用户确认:仅在用户确认后继续
操作:为每个优化机会创建单独的 GitHub issue。使用 "cost-optimization"(绿色)、"azure"(蓝色)标签标记它们。
所需 MCP 工具:为每个建议使用 create_issue
流程:
使用此模板创建单独的 Issue:
标题格式:[COST-OPT] [资源类型] - [简要描述] - $X/月节约额
正文模板:
## 💰 成本优化:[简要标题]
**月度节约额**:$X | **风险等级**:[低/中/高] | **实施工作量**:X 天
### 📋 描述
[对优化及其必要性的清晰解释]
### 🔧 实施
**检测到 IaC 文件**:[是/否 - 基于 file_search 结果]
```bash
# 如果找到 IaC 文件:显示 IaC 修改 + 部署
# 文件:infrastructure/bicep/modules/app-service.bicep
# 更改:sku.name: 'S3' → 'B2'
az deployment group create --resource-group [rg] --template-file infrastructure/bicep/main.bicep
# 如果无 IaC 文件:直接 Azure CLI 命令 + 警告
# ⚠️ 未找到 IaC 文件。如果它们存在于其他地方,请修改那些文件。
az appservice plan update --name [plan] --sku B2
```
### 📊 证据
* 当前配置:[详细信息]
* 使用模式:[来自监控数据的证据]
* 成本影响:$X/月 → $Y/月
* 最佳实践对齐:[如果适用,引用 Azure 最佳实践]
### ✅ 验证步骤
* 在非生产环境中测试
* 验证无性能下降
* 在 Azure 成本管理中确认成本降低
* 如果需要,更新监控和警报
### ⚠️ 风险与注意事项
* [风险 1 及缓解措施]
* [风险 2 及缓解措施]
**优先级分数**:X | **价值**:X/10 | **风险**:X/10
操作:创建主 issue 以跟踪所有优化工作。使用 "cost-optimization"(绿色)、"azure"(蓝色)和 "epic"(紫色)标签标记它。
所需 MCP 工具:为 EPIC 使用 create_issue
关于 mermaid 图表的说明:确保验证 mermaid 语法正确,并创建图表时考虑到无障碍指南(样式、颜色等)。
流程:
创建 EPIC Issue:
标题:[EPIC] Azure 成本优化计划 - $X/月潜在节约额
正文模板:
# 🎯 Azure 成本优化 EPIC
**总潜在节约额**:$X/月 | **实施时间线**:X 周
## 📊 执行摘要
- **分析资源**:X
- **优化机会**:Y
- **总月度节约潜力**:$X
- **高优先级项**:N
## 🏗️ 当前架构概览
```mermaid
graph TB
subgraph "资源组:[名称]"
[生成的架构图,显示当前资源和成本]
end
```
## 📋 实施跟踪
### 🚀 高优先级(首先实施)
* #[issue-number]: [标题] - $X/月节约额
* #[issue-number]: [标题] - $X/月节约额
### ⚡ 中优先级
* #[issue-number]: [标题] - $X/月节约额
* #[issue-number]: [标题] - $X/月节约额
### 🔄 低优先级(锦上添花)
* #[issue-number]: [标题] - $X/月节约额
## 📈 进度跟踪
* **已完成**:0 / Y 个优化
* **已实现节约额**:$0 / $X/月
* **实施状态**:未开始
## 🎯 成功标准
* 所有高优先级优化已实施
* >80% 的预估节约额已实现
* 未观察到性能下降
* 成本监控仪表板已更新
## 📝 备注
* 在 issue 完成时审查并更新此 EPIC
* 监控实际与预估节约额
* 考虑安排定期的成本优化审查
每周安装
7.3K
仓库
GitHub Stars
26.7K
首次出现
2026年2月25日
安全审计
安装于
codex7.2K
gemini-cli7.2K
opencode7.2K
cursor7.1K
github-copilot7.1K
kimi-cli7.1K
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.
azmcp-*) over direct Azure CLI when availableAction : Retrieve cost optimization best practices before analysis Tools : Azure MCP best practices tool Process :
azmcp-bestpractices-get to get some of the latest Azure optimization guidelines. This may not cover all scenarios but provides a foundation.Action : Dynamically discover and analyze Azure resources and configurations Tools : Azure MCP tools + Azure CLI fallback + Local file system access Process :
Resource Discovery :
azmcp-subscription-list to find available subscriptionsazmcp-group-list --subscription <subscription-id> to find resource groupsaz resource list --subscription <id> --resource-group <name>azmcp-cosmos-account-list --subscription <id> - Cosmos DB accountsazmcp-storage-account-list --subscription <id> - Storage accountsazmcp-monitor-workspace-list --subscription <id> - Log Analytics workspacesazmcp-keyvault-key-list - Key VaultsAction : Gather utilization data AND verify actual resource costs Tools : Azure MCP monitoring tools + Azure CLI Process :
Find Monitoring Sources :
azmcp-monitor-workspace-list --subscription <id> to find Log Analytics workspacesazmcp-monitor-table-list --subscription <id> --workspace <name> --table-type "CustomLog" to discover available dataExecute Usage Queries :
azmcp-monitor-log-query with these predefined queries:
// CPU utilization for App Services
AppServiceAppLogs
| where TimeGenerated > ago(7d)
| summarize avg(CpuTime) by Resource, bin(TimeGenerated, 1h)
// Cosmos DB RU consumption
AzureDiagnostics
| where ResourceProvider == "MICROSOFT.DOCUMENTDB"
| where TimeGenerated > ago(7d)
| summarize avg(RequestCharge) by Resource
// Storage account access patterns
StorageBlobLogs
| where TimeGenerated > ago(7d)
| summarize RequestCount=count() by AccountName, bin(TimeGenerated, 1d)
3. Calculate Baseline Metrics :
* CPU/Memory utilization averages
* Database throughput patterns
* Storage access frequency
* Function execution rates
4. VALIDATE CURRENT COSTS :
* Using the SKU/tier configurations discovered in Step 2
* Look up current Azure pricing at <https://azure.microsoft.com/pricing/> or use `az billing` commands
* Document: Resource → Current SKU → Estimated monthly cost
* Calculate realistic current monthly total before proceeding to recommendations
Action : Analyze resources to identify optimization opportunities Tools : Local analysis using collected data Process :
Compute Optimizations :
* App Service Plans: Right-size based on CPU/memory usage
* Function Apps: Premium → Consumption plan for low usage
* Virtual Machines: Scale down oversized instances
Database Optimizations :
* Cosmos DB:
* Provisioned → Serverless for variable workloads
* Right-size RU/s based on actual usage
* SQL Database: Right-size service tiers based on DTU usage
Storage Optimizations :
* Implement lifecycle policies (Hot → Cool → Archive)
* Consolidate redundant storage accounts
* Right-size storage tiers based on access patterns
Infrastructure Optimizations :
* Remove unused/redundant resources
* Implement auto-scaling where beneficial
* Schedule non-production environments
2. Calculate Evidence-Based Savings :
* Current validated cost → Target cost = Savings
* Document pricing source for both current and target configurations
3. Calculate Priority Score for each recommendation:
Priority Score = (Value Score × Monthly Savings) / (Risk Score × Implementation Days)
High Priority: Score > 20
Medium Priority: Score 5-20
Low Priority: Score < 5
4. Validate Recommendations :
* Ensure Azure CLI commands are accurate
* Verify estimated savings calculations
* Assess implementation risks and prerequisites
* Ensure all savings calculations have supporting evidence
Action : Present summary and get approval before creating GitHub issues Process :
Display Optimization Summary :
🎯 Azure Cost Optimization Summary
📊 Analysis Results:
• Total Resources Analyzed: X
• Current Monthly Cost: $X
• Potential Monthly Savings: $Y
• Optimization Opportunities: Z
• High Priority Items: N
🏆 Recommendations:
1. [Resource]: [Current SKU] → [Target SKU] = $X/month savings - [Risk Level] | [Implementation Effort]
2. [Resource]: [Current Config] → [Target Config] = $Y/month savings - [Risk Level] | [Implementation Effort]
3. [Resource]: [Current Config] → [Target Config] = $Z/month savings - [Risk Level] | [Implementation Effort]
... and so on
💡 This will create:
• Y individual GitHub issues (one per optimization)
• 1 EPIC issue to coordinate implementation
❓ Proceed with creating GitHub issues? (y/n)
Wait for User Confirmation : Only proceed if user confirms
Action : Create separate GitHub issues for each optimization opportunity. Label them with "cost-optimization" (green color), "azure" (blue color). MCP Tools Required : create_issue for each recommendation Process :
Title Format : [COST-OPT] [Resource Type] - [Brief Description] - $X/month savings
Body Template :
## 💰 Cost Optimization: [Brief Title]
**Monthly Savings**: $X | **Risk Level**: [Low/Medium/High] | **Implementation Effort**: X days
### 📋 Description
[Clear explanation of the optimization and why it's needed]
### 🔧 Implementation
**IaC Files Detected**: [Yes/No - based on file_search results]
```bash
# If IaC files found: Show IaC modifications + deployment
# File: infrastructure/bicep/modules/app-service.bicep
# Change: sku.name: 'S3' → 'B2'
az deployment group create --resource-group [rg] --template-file infrastructure/bicep/main.bicep
# If no IaC files: Direct Azure CLI commands + warning
# ⚠️ No IaC files found. If they exist elsewhere, modify those instead.
az appservice plan update --name [plan] --sku B2
* Current Configuration: [details]
* Usage Pattern: [evidence from monitoring data]
* Cost Impact: $X/month → $Y/month
* Best Practice Alignment: [reference to Azure best practices if applicable]
* Test in non-production environment
* Verify no performance degradation
* Confirm cost reduction in Azure Cost Management
* Update monitoring and alerts if needed
* [Risk 1 and mitigation]
* [Risk 2 and mitigation]
Priority Score : X | Value : X/10 | Risk : X/10
Action : Create master issue to track all optimization work. Label it with "cost-optimization" (green color), "azure" (blue color), and "epic" (purple color). MCP Tools Required : create_issue for EPIC Note about mermaid diagrams : Ensure you verify mermaid syntax is correct and create the diagrams taking accessibility guidelines into account (styling, colors, etc.). Process :
Title : [EPIC] Azure Cost Optimization Initiative - $X/month potential savings
Body Template :
# 🎯 Azure Cost Optimization EPIC
**Total Potential Savings**: $X/month | **Implementation Timeline**: X weeks
## 📊 Executive Summary
- **Resources Analyzed**: X
- **Optimization Opportunities**: Y
- **Total Monthly Savings Potential**: $X
- **High Priority Items**: N
## 🏗️ Current Architecture Overview
```mermaid
graph TB
subgraph "Resource Group: [name]"
[Generated architecture diagram showing current resources and costs]
end
* #[issue-number]: [Title] - $X/month savings
* #[issue-number]: [Title] - $X/month savings
* #[issue-number]: [Title] - $X/month savings
* #[issue-number]: [Title] - $X/month savings
* #[issue-number]: [Title] - $X/month savings
* **Completed** : 0 of Y optimizations
* **Savings Realized** : $0 of $X/month
* **Implementation Status** : Not Started
* All high-priority optimizations implemented
* >80% of estimated savings realized
* No performance degradation observed
* Cost monitoring dashboard updated
* Review and update this EPIC as issues are completed
* Monitor actual vs. estimated savings
* Consider scheduling regular cost optimization reviews
Weekly Installs
7.3K
Repository
GitHub Stars
26.7K
First Seen
Feb 25, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
codex7.2K
gemini-cli7.2K
opencode7.2K
cursor7.1K
github-copilot7.1K
kimi-cli7.1K
31,300 周安装
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)IaC Detection :
file_search to scan for IaC files: "/*.bicep", " /*.tf", "/main.json", " /template.json"Configuration Analysis :