azure-cost

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Azure Cost Management Skill

Azure 成本管理技能

Unified skill for all Azure cost management tasks: querying historical costs, forecasting future spending, and optimizing to reduce waste.
适用于所有Azure成本管理任务的统一技能:查询历史成本、预测未来支出、优化以减少浪费。

When to Use This Skill

何时使用该技能

Activate this skill when user wants to:
  • Query or analyze Azure costs (how much am I spending, show my bill, cost breakdown)
  • Break down costs by service, resource, location, or tag
  • Analyze cost trends over time
  • Forecast future Azure spending or project end-of-month costs
  • Optimize Azure costs, reduce spending, or find savings
  • Find orphaned or unused resources
  • Rightsize Azure VMs, containers, or services
  • Generate cost optimization reports
当用户需要完成以下操作时激活该技能:
  • 查询或分析Azure成本(我的支出是多少、查看我的账单、成本明细)
  • 按服务、资源、地域或标签拆分成本
  • 分析不同时间段的成本趋势
  • 预测未来Azure支出或估算月末成本
  • 优化Azure成本、减少支出或寻找节约空间
  • 查找孤立或未使用的资源
  • 对Azure VM、容器或服务进行规格优化
  • 生成成本优化报告

Quick Reference

快速参考

PropertyValue
Query API Endpoint
POST {scope}/providers/Microsoft.CostManagement/query?api-version=2023-11-01
Forecast API Endpoint
POST {scope}/providers/Microsoft.CostManagement/forecast?api-version=2023-11-01
MCP Tools
azure__documentation
,
azure__extension_cli_generate
,
azure__get_azure_bestpractices
CLI
az rest
,
az monitor metrics list
,
az resource list
Required RoleCost Management Reader + Monitoring Reader + Reader on scope
属性
查询API端点
POST {scope}/providers/Microsoft.CostManagement/query?api-version=2023-11-01
预测API端点
POST {scope}/providers/Microsoft.CostManagement/forecast?api-version=2023-11-01
MCP工具
azure__documentation
,
azure__extension_cli_generate
,
azure__get_azure_bestpractices
CLI
az rest
,
az monitor metrics list
,
az resource list
所需角色成本管理读取者 + 监控读取者 + 对应范围的读取权限

MCP Tools

MCP工具

ToolDescriptionParametersWhen to Use
azure__documentation
Search Azure documentation
query
(Required): search terms
Research Cost Management API parameters and options
azure__extension_cli_generate
Generate Azure CLI commands
intent
(Required): task description,
cli-type
(Required):
"az"
Construct
az rest
commands for cost queries
azure__get_azure_bestpractices
Get Azure best practices
intent
(Required): optimization context
Inform query design with cost management best practices
azure__extension_azqr
Run Azure Quick Review compliance scan
subscription
(Required): subscription ID,
resource-group
(Optional): resource group name
Find orphaned resources and cost optimization opportunities
azure__aks
Azure Kubernetes Service operationsvaries by sub-commandAKS cost analysis: list clusters, get node pools, inspect configuration
💡 Tip: Prefer MCP tools over direct CLI commands. Use
az rest
only when MCP tools don't cover the specific operation.

工具描述参数使用场景
azure__documentation
搜索Azure文档
query
(必填):搜索关键词
调研成本管理API的参数和可选配置
azure__extension_cli_generate
生成Azure CLI命令
intent
(必填):任务描述,
cli-type
(必填):
"az"
构造用于成本查询的
az rest
命令
azure__get_azure_bestpractices
获取Azure最佳实践
intent
(必填):优化场景
结合成本管理最佳实践设计查询逻辑
azure__extension_azqr
运行Azure快速审核合规扫描
subscription
(必填):订阅ID,
resource-group
(可选):资源组名称
查找孤立资源和成本优化机会
azure__aks
Azure Kubernetes Service操作随子命令变化AKS成本分析:列出集群、获取节点池、查看配置
💡 提示: 优先使用MCP工具而非直接执行CLI命令。仅当MCP工具不覆盖特定操作时使用
az rest

Routing

路由

Read the user's request and follow the appropriate workflow below.
User IntentWorkflowExample Prompts
Understand current costsCost Query Workflow"how much am I spending", "cost by service", "show my bill"
Reduce costs / find wasteCost Optimization Workflow"optimize costs", "find orphaned resources", "reduce spending"
Project future costsCost Forecast Workflow"forecast costs", "end of month estimate", "how much will I spend"
Full cost pictureAll three workflows combined"give me the full picture of my Azure costs"
Important: When optimizing costs, always present the total bill and cost breakdown alongside optimization recommendations.

读取用户请求,遵循对应工作流处理:
用户意图工作流示例提示
了解当前成本成本查询工作流"我的支出是多少", "按服务拆分成本", "查看我的账单"
降低成本/查找浪费成本优化工作流"优化成本", "查找孤立资源", "减少支出"
预估未来成本成本预测工作流"预测成本", "月末估算", "我将支出多少"
完整成本视图组合三个工作流"给我展示Azure成本的完整情况"
重要提示: 做成本优化时,始终在给出优化建议的同时展示总账单和成本明细。

Scope Reference (Shared Across All Workflows)

范围参考(所有工作流通用)

ScopeURL Pattern
Subscription
/subscriptions/<subscription-id>
Resource Group
/subscriptions/<subscription-id>/resourceGroups/<resource-group-name>
Management Group
/providers/Microsoft.Management/managementGroups/<management-group-id>
Billing Account
/providers/Microsoft.Billing/billingAccounts/<billing-account-id>
Billing Profile
/providers/Microsoft.Billing/billingAccounts/<billing-account-id>/billingProfiles/<billing-profile-id>
💡 Tip: These are scope paths only — not complete URLs. Combine with the API endpoint and version.

范围URL格式
订阅
/subscriptions/<subscription-id>
资源组
/subscriptions/<subscription-id>/resourceGroups/<resource-group-name>
管理组
/providers/Microsoft.Management/managementGroups/<management-group-id>
计费账户
/providers/Microsoft.Billing/billingAccounts/<billing-account-id>
计费配置文件
/providers/Microsoft.Billing/billingAccounts/<billing-account-id>/billingProfiles/<billing-profile-id>
💡 提示: 以上仅为范围路径,不是完整URL。需要与API端点和版本拼接使用。

Part 1: Cost Query Workflow

第一部分:成本查询工作流

For the full cost query workflow (scope selection, report types, timeframes, dataset configuration, API calls, pagination, guardrails, examples, and error handling), see:
📄 Cost Query Workflow

完整的成本查询工作流(范围选择、报告类型、时间范围、数据集配置、API调用、分页、防护规则、示例和错误处理)请查看:
📄 成本查询工作流

Part 2: Cost Optimization Workflow

第二部分:成本优化工作流

For the full cost optimization workflow (prerequisites, best practices, Redis/AKS-specific analysis, Azure Quick Review, resource discovery, cost queries, pricing validation, utilization metrics, and report generation), see:
📄 Cost Optimization Workflow

完整的成本优化工作流(前置条件、最佳实践、Redis/AKS专属分析、Azure快速审核、资源发现、成本查询、定价校验、使用率指标和报告生成)请查看:
📄 成本优化工作流

Part 3: Cost Forecast Workflow

第三部分:成本预测工作流

For the full cost forecast workflow (scope selection, time period rules, dataset configuration, forecast-specific options, API calls, response interpretation, guardrails, and error handling), see:
📄 Cost Forecast Workflow

完整的成本预测工作流(范围选择、时间周期规则、数据集配置、预测专属选项、API调用、响应解析、防护规则和错误处理)请查看:
📄 成本预测工作流

Data Classification

数据分类

  • ACTUAL DATA = Retrieved from Azure Cost Management API
  • ACTUAL METRICS = Retrieved from Azure Monitor
  • VALIDATED PRICING = Retrieved from official Azure pricing pages
  • ESTIMATED SAVINGS = Calculated based on actual data and validated pricing
  • 实际数据 = 从Azure成本管理API获取
  • 实际指标 = 从Azure Monitor获取
  • 已校验定价 = 从Azure官方定价页面获取
  • 预估节约金额 = 基于实际数据和已校验定价计算得出

Best Practices

最佳实践

  • Always query actual costs first — never estimate or assume
  • Always present the total bill alongside optimization recommendations
  • Validate pricing from official sources — account for free tiers
  • Use REST API for cost queries (more reliable than
    az costmanagement query
    )
  • Save audit trail — include all queries and responses
  • Include Azure Portal links for all resources
  • For costs < $10/month, emphasize operational improvements over financial savings
  • Never execute destructive operations without explicit approval
  • 始终优先查询实际成本——绝不估算或假设
  • 始终在给出优化建议的同时展示总账单
  • 从官方来源校验定价——考虑免费 tier 的影响
  • 使用REST API查询成本(比
    az costmanagement query
    更可靠)
  • 留存审计轨迹——包含所有查询和响应
  • 所有资源都附带Azure Portal链接
  • 对于月成本低于10美元的资源,优先强调运营改进而非财务节约
  • 没有明确批准的情况下绝不执行破坏性操作

Common Pitfalls

常见陷阱

  • Assuming costs: Always query actual data from Cost Management API
  • Ignoring free tiers: Many services have generous allowances
  • Using wrong date ranges: 30 days for costs, 14 days for utilization
  • Not showing the bill: Always present cost breakdown alongside optimization recommendations
  • Cost query failures: Use
    az rest
    with JSON body, not
    az costmanagement query
  • 假设成本:始终从成本管理API查询实际数据
  • 忽略免费 tier:很多服务有 generous 的使用额度
  • 使用错误的日期范围:成本查询取30天数据,使用率查询取14天数据
  • 不展示账单:始终在给出优化建议的同时展示成本明细
  • 成本查询失败:使用带JSON请求体的
    az rest
    ,不要用
    az costmanagement query

Safety Requirements

安全要求

  • Get approval before deleting resources
  • Test changes in non-production first
  • Provide dry-run commands for validation
  • Include rollback procedures
  • 删除资源前必须获得审批
  • 先在非生产环境测试变更
  • 提供试运行命令用于校验
  • 包含回滚流程

SDK Quick References

SDK快速参考

  • Redis Management: .NET
  • Redis管理.NET