jpskill.com
💼 ビジネス コミュニティ

azure-cost-optimization

Azureの利用コストを分析し、無駄なリソースの特定やVMの適切なサイズ調整など、具体的な改善提案によってAzureのコスト削減を実現するSkill。

📜 元の英語説明(参考)

Identify and quantify cost savings across Azure subscriptions by analyzing actual costs, utilization metrics, and generating actionable optimization recommendations. USE FOR: optimize Azure costs, reduce Azure spending, reduce Azure expenses, analyze Azure costs, find cost savings, generate cost optimization report, find orphaned resources, rightsize VMs, cost analysis, reduce waste, Azure spending analysis, find unused resources, optimize Redis costs. DO NOT USE FOR: deploying resources (use azure-deploy), general Azure diagnostics (use azure-diagnostics), security issues (use azure-security)

🇯🇵 日本人クリエイター向け解説

一言でいうと

Azureの利用コストを分析し、無駄なリソースの特定やVMの適切なサイズ調整など、具体的な改善提案によってAzureのコスト削減を実現するSkill。

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o azure-cost-optimization.zip https://jpskill.com/download/19660.zip && unzip -o azure-cost-optimization.zip && rm azure-cost-optimization.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/19660.zip -OutFile "$d\azure-cost-optimization.zip"; Expand-Archive "$d\azure-cost-optimization.zip" -DestinationPath $d -Force; ri "$d\azure-cost-optimization.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して azure-cost-optimization.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → azure-cost-optimization フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
5

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

Azure コスト最適化スキル

Azure サブスクリプションを分析し、孤立したリソースのクリーンアップ、適切なサイジング、実際の使用状況データに基づいた最適化の推奨事項を通じて、コスト削減を特定します。

このスキルを使用するタイミング

ユーザーが以下のことを要求した場合に、このスキルを使用します。

  • Azure コストを最適化する、または支出を削減する
  • コスト削減のために Azure サブスクリプションを分析する
  • コスト最適化レポートを生成する
  • 孤立したリソースまたは未使用のリソースを見つける
  • Azure VM、コンテナ、またはサービスのサイズを適切にする
  • Azure でどこに過剰な支出があるかを特定する
  • 特に Redis コストを最適化する - Redis 固有の分析については、Azure Redis コスト最適化を参照してください。

手順

ユーザーとの会話で、以下の手順に従ってください。

ステップ 0: 前提条件の検証

開始する前に、以下のツールと権限が利用可能であることを確認してください。

必須ツール:

  • Azure CLI がインストールされ、認証済みであること (az login)
  • Azure CLI 拡張機能: costmanagementresource-graph
  • Azure Quick Review (azqr) がインストールされていること - 詳細については、Azure Quick Reviewを参照してください。

必須権限:

  • Cost Management Reader ロール
  • Monitoring Reader ロール
  • サブスクリプション/リソースグループに対する Reader ロール

検証コマンド:

az --version
az account show
az extension show --name costmanagement
azqr version

ステップ 1: ベストプラクティスの読み込み

推奨事項の参考にするために、Azure コスト最適化のベストプラクティスを取得します。

// 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" }
})

ステップ 1.5: Redis 固有の分析 (条件付き)

ユーザーが Redis コスト最適化を具体的に要求した場合、専門の Redis スキルを使用します。

📋 参照: Azure Redis コスト最適化

Redis 固有の分析を使用するタイミング:

  • ユーザーが「Redis」、「Azure Cache for Redis」、または「Azure Managed Redis」に言及している場合
  • 一般的なサブスクリプション分析ではなく、Redis リソースの最適化に焦点が当てられている場合
  • ユーザーが Redis 固有の推奨事項 (SKU ダウングレード、失敗したキャッシュなど) を求めている場合

主な機能:

  • 対話型サブスクリプションフィルタリング (プレフィックス、ID、または「すべてのサブスクリプション」)
  • Redis 固有の最適化ルール (失敗したキャッシュ、過剰なサイズのティア、タグの欠落)
  • Redis コスト分析用の事前構築済みレポートテンプレート
  • redis_list コマンドを使用します

利用可能なレポートテンプレート:

: Redis を含む一般的なサブスクリプション全体のコスト最適化については、ステップ 2 に進んでください。Redis のみに焦点を当てた分析については、Redis 固有の参照ドキュメントの手順に従ってください。

ステップ 1.6: 分析スコープの選択 (Redis 固有の分析の場合)

Redis コスト最適化を実行する場合、ユーザーに分析スコープを選択するよう依頼します。

以下のオプションをユーザーに提示します。

  1. 特定のサブスクリプション ID - 単一のサブスクリプションを分析します
  2. サブスクリプション名 - ID の代わりに表示名を使用します
  3. サブスクリプションプレフィックス - プレフィックス (例: "CacheTeam") で始まるすべてのサブスクリプションを分析します
  4. すべてのサブスクリプション - アクセス可能なすべてのサブスクリプションをスキャンします
  5. テナント全体 - 組織全体を分析します

ステップ 2 に進む前に、ユーザーの応答を待ちます。

ステップ 2: Azure Quick Review の実行

azqr を実行して孤立したリソースを見つけます (即時のコスト削減)。

📋 参照: Azure Quick Review - azqr スキャンを実行するための詳細な手順

// Use Azure MCP extension_azqr tool
extension_azqr({
  subscription: "<SUBSCRIPTION_ID>",
  "resource-group": "<RESOURCE_GROUP>"  // optional
})

azqr の結果で探すべきもの:

  • 孤立したリソース: 未接続のディスク、未使用の NIC、アイドル状態の NAT ゲートウェイ
  • 過剰にプロビジョニングされたリソース: 過剰な保持期間、過剰なサイズの SKU
  • コストタグの欠落: 適切なコスト割り当てのないリソース

: Azure Quick Review の参照ドキュメントには、フィルター構成の作成、output/ フォルダーへの出力の保存、およびコスト最適化のための結果の解釈に関する手順が含まれています。

ステップ 3: リソースの検出

効率的なクロスサブスクリプションのリソース検出には、Azure Resource Graph を使用します。孤立したリソースの検出とコスト最適化パターンについては、Azure Resource Graph クエリを参照してください。

Azure MCP ツールまたは 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

ステップ 4: 実際のコストのクエリ

Azure Cost Management API から実際のコストデータ (過去 30 日間) を取得します。

コストクエリファイルの作成:

temp/cost-query.json を以下で作成します。

{
  "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"
      }
    ]
  }
}

アクションが必要です: <START_DATE> (30 日前) と <END_DATE> (今日) を ISO 8601 形式 (例: 2025-11-03T00:00:00Z) で計算してください。

コストクエリの実行:

# 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.C
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

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 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/ folder:

Use the create_file tool with path output/costoptimizereport<YYYYMMDD_HHMMSS>.md:

Report Structure:

# Azure Cost Optimization Report
**Generated**: <timestamp>

## Executive Summary
- Total Monthly Cost: $X (💰 ACTUAL DATA)
- Top Cost Drivers: [List top 3 resources with Azure Portal links]

## Cost Breakdown
[Table with top 10 resources by cost, including Azure Portal links]

## Free Tier Analysis
[Resources operating within free tiers showing $0 cost]

## Orphaned Resources (Immediate Savings)
[From azqr - resources that can be deleted immediately]
- Resource name with Portal link - $X/month savings

## Optimization Recommendations

### Priority 1: High Impact, Low Risk
[Example: Delete orphaned resources]
- 💰 ACTUAL cost: $X/month
- 📊 ESTIMATED savings: $Y/month
- Commands to execute (with warnings)

### Priority 2: Medium Impact, Medium Risk
[Example: Rightsize VM from D4s_v5 to D2s_v5]
- 💰 ACTUAL baseline: D4s_v5, $X/month
- 📈 ACTUAL metrics: CPU 8%, Memory 30%
- 💵 VALIDATED pricing: D4s_v5 $Y/hr, D2s_v5 $Z/hr
- 📊 ESTIMATED savings: $S/month
- Commands to execute

### Priority 3: Long-term Optimization
[Example: Reserved Instances, Storage tiering]

## Total Estimated Savings
- Monthly: $X
- Annual: $Y

## Implementation Commands
[Safe commands with approval warnings]

## Validation Appendix

### Data Sources and Files
- **Cost Query Results**: `output/cost-query-result<timestamp>.json`
  - Raw cost data from Azure Cost Management API
  - Audit trail proving actual costs at report generation time
  - Keep for at least 12 months for historical comparison
  - Contains every resource's exact cost over the analysis period
- **Pricing Sources**: [Links to Azure pricing pages]
- **Free Tier Allowances**: [Applicable allowances]

> **Note**: The `temp/cost-query.json` file (if present) is a temporary query template and can be safely deleted. All permanent audit data is in the `output/` folder.

Portal Link Format:

https://portal.azure.com/#@<TENANT_ID>/resource/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP>/providers/<RESOURCE_PROVIDER>/<RESOURCE_TYPE>/<RESOURCE_NAME>/overview

Step 8: Save Audit Trail

Save all cost query results for validation:

Use the create_file tool with path output/cost-query-result<YYYYMMDD_HHMMSS>.json:

{
  "timestamp": "<ISO_8601>",
  "subscription": "<SUBSCRIPTION_ID>",
  "resourceGroup": "<RESOURCE_GROUP>",
  "queries": [
    {
      "queryType": "ActualCost",
      "timeframe": "MonthToDate",
      "query": { },
      "response": { }
    }
  ]
}

Step 9: Clean Up Temporary Files

Remove temporary query files and folder after the report is generated:

# Delete entire temp folder (no longer needed)
Remove-Item -Path "temp" -Recurse -Force -ErrorAction SilentlyContinue

Note: The temp/cost-query.json file is only needed during API execution. The actual query and results are preserved in output/cost-query-result*.json for audit purposes.

Output

The skill generates:

  1. Cost Optimization Report (output/costoptimizereport<timestamp>.md)

    • Executive summary with total costs and top drivers
    • Detailed cost breakdown with Azure Portal links
    • Prioritized recommendations with actual data and estimated savings
    • Implementation commands with safety warnings
  2. Cost Query Results (output/cost-query-result<timestamp>.json)

    • Audit trail of all cost queries and responses
    • Validation evidence for recommendations

Important Notes

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

Best Practices

  • Always query actual costs first - never estimate or assume
  • 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
  • Use UTF-8 encoding when creating report files
  • For costs < $10/month, emphasize operational improvements over financial savings
  • Never execute destructive operations without explicit approval

Common Pitfalls

  • Assuming costs: Always query actual data from Cost Management API
  • Ignoring free tiers: Many services have generous allowances (e.g., Container Apps: 180K vCPU-sec free/month)
  • Using wrong date ranges: 30 days for costs, 14 days for utilization
  • Broken Portal links: Verify tenant ID and resource ID format
  • Cost query failures: Use az rest with JSON body, not 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
  • Monitor impact after implementation

SDK Quick References

  • Redis Management: .NET

同梱ファイル

※ ZIPに含まれるファイル一覧。`SKILL.md` 本体に加え、参考資料・サンプル・スクリプトが入っている場合があります。