← All runbooks
microsoft / azure-cost-optimization

Azure Cost Optimization Skill

Analy

agent claude-codemodel claude-sonnet-4-6snapshot python312-uveval programmatic13 stepsv1.0.0

Deploy Azure Cost Optimization Skill to your jetty.io

One-click installs this runbook into a collection on your Jetty account. You can run it from the Spot dashboard, schedule it, or pipe inputs in via the API.

The shape of the run

13 steps · start to finish.

  1. 1
    Step 1

    Environment Setup

    Verify all required tools, permissions, and inputs are available before proceeding.

    echo "=== ENVIRONMENT SETUP ==="
    
    # Verify az CLI
    az --version || { echo "ERROR: Azure CLI not installed"; exit 1; }
    
    # Verify azqr
    azqr version || { echo "ERROR: Azure Quick Review (azqr) not installed"; exit 1; }
    
    # Verify az extensions
    az extension show --name costmanagement || az extension add --name costmanagement
    az extension show --name resource-graph || az extension add --name resource-graph
    
    # Verify authentication
    az account show || { echo "ERROR: Not authenticated — run 'az login'"; exit 1; }
    
    # Show subscription context
    az account list --output table
    
    # Create output directory
    mkdir -p /app/results
    
    echo "=== SETUP COMPLETE ==="
    

    Prompt the user for:

    • SUBSCRIPTION_ID (required): the Azure subscription to analyze
    • RESOURCE_GROUP (optional): leave blank for subscription-wide analysis
    • ANALYSIS_SCOPE (optional, default: subscription): narrow to redis-only or aks-only if the user specifies
  2. 2
    Step 2

    Validate Prerequisites

    SUBSCRIPTION_ID="<SUBSCRIPTION_ID>" RESOURCE_GROUP="<RESOURCE_GROUP>" # leave empty for subscription-wide

  3. 3
    Step 3

    Conditional — Redis-Specific Analysis

    **Skip this step unless** the user specifically asks about Redis, Azure Cache for Redis, or Azure Managed Redis optimization.

  4. 4
    Step 4

    Conditional — AKS-Specific Analysis

    **Skip this step unless** the user mentions AKS, Kubernetes, cluster, node pool, pod, or kubectl.

  5. 5
    Step 5

    Load Best Practices

    Load Azure cost optimization best practices to inform recommendations:

  6. 6
    Step 6

    Run Azure Quick Review

    Run azqr to identify orphaned resources eligible for immediate deletion:

  7. 7
    Step 7

    Discover Resources

    Use Azure Resource Graph for efficient cross-subscription resource discovery:

  8. 8
    Step 8

    Query Actual Costs

    Get actual cost data from Azure Cost Management API (last 30 days):

  9. 9
    Step 9

    Validate Pricing

    Fetch current pricing from official Azure pricing pages for the top resources identified in Step 8:

  10. 10
    Step 10

    Collect Utilization Metrics

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

  11. 11
    Step 11

    Iterate on Errors (max 3 rounds)

    If any step above returns an error or incomplete data:

  12. 12
    Step 12

    Generate Optimization Report

    Create a comprehensive cost optimization report at `/app/results/cost-optimization-report.md`:

  13. 13
    Step 13

    Final Checklist (MANDATORY — do not skip)

    echo "=== FINAL OUTPUT VERIFICATION ===" RESULTS_DIR="/app/results" for f in \ "$RESULTS_DIR/cost-optimization-report.md" \