Skip to content

Commit 54e0f11

Browse files
authored
feat: (azure-cost) add storage optimization guide and fix token limit (#2554)
* feat(azure-cost): add storage optimization guide and fix token limit - Add services/storage/azure-storage.md with optimization rules, lifecycle policy templates, Resource Graph queries, and pricing reference - Add references/tools-and-best-practices.md (extracted from SKILL.md) - Slim SKILL.md from ~2100 to ~490 tokens (fixes #2157) - Add Step 1.7 Storage routing in optimization workflow - Add 4 vally eval stimuli (3 routing + 1 response quality) Closes #2524 (partial: storage service guide) * fix: revert lockfile changes that desync npm ci * fix: tighten routing triggers to avoid azure-storage skill overlap Address Copilot review feedback: - Replace 'storage tiering' with 'reduce storage costs' in description - Tighten workflow triggers to storage-cost-specific terms (LRS/GRS, savings) - Clarify orphaned disks rule is compute-adjacent (billed as storage) - Add explicit cost/savings language to eval prompts for stable routing * fix: add required --resource-group params to CLI examples * fix: address third Copilot review round - Clarify Reader role is scoped (not global) in Quick Reference - Add --resource-group to inline verification command - Add explicit routing note for storage-only vs general optimization
1 parent 95be91b commit 54e0f11

5 files changed

Lines changed: 348 additions & 119 deletions

File tree

evals/azure-cost/eval.yaml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,67 @@ stimuli:
310310
config:
311311
pattern: "(?i)fatal error|unhandled exception|stack trace"
312312

313+
# ═══════════════════════════════════════════
314+
# Storage Cost Optimization routing prompts
315+
# ═══════════════════════════════════════════
316+
317+
# ── storage-lifecycle-policy-prompt ──
318+
# Assertions: softCheckSkill + isSkillInvoked (invocation rate ≥ 80%)
319+
- name: "Storage lifecycle policy optimization"
320+
prompt: "Help me reduce storage costs by setting up lifecycle policies to move old data to cheaper tiers"
321+
tags:
322+
type: integration
323+
tier: full
324+
cost: llm
325+
area: routing
326+
earlyTerminate: '[{"type":"skill-call","skill":"azure-cost"},{"type":"tool-call-count","count":3}]'
327+
graders:
328+
- type: skill-invocation
329+
config:
330+
required:
331+
- azure-cost
332+
- type: output-not-matches
333+
config:
334+
pattern: "(?i)fatal error|unhandled exception|stack trace"
335+
336+
# ── storage-redundancy-downgrade-prompt ──
337+
# Assertions: softCheckSkill + isSkillInvoked (invocation rate ≥ 80%)
338+
- name: "Storage redundancy downgrade for dev"
339+
prompt: "I have GRS storage accounts in my dev environment, can I save money by downgrading to LRS?"
340+
tags:
341+
type: integration
342+
tier: full
343+
cost: llm
344+
area: routing
345+
earlyTerminate: '[{"type":"skill-call","skill":"azure-cost"},{"type":"tool-call-count","count":3}]'
346+
graders:
347+
- type: skill-invocation
348+
config:
349+
required:
350+
- azure-cost
351+
- type: output-not-matches
352+
config:
353+
pattern: "(?i)fatal error|unhandled exception|stack trace"
354+
355+
# ── storage-blob-tiering-prompt ──
356+
# Assertions: softCheckSkill + isSkillInvoked (invocation rate ≥ 80%)
357+
- name: "Blob access tier optimization"
358+
prompt: "Analyze my blob storage costs and recommend which containers should move to cheaper tiers to save money"
359+
tags:
360+
type: integration
361+
tier: full
362+
cost: llm
363+
area: routing
364+
earlyTerminate: '[{"type":"skill-call","skill":"azure-cost"},{"type":"tool-call-count","count":3}]'
365+
graders:
366+
- type: skill-invocation
367+
config:
368+
required:
369+
- azure-cost
370+
- type: output-not-matches
371+
config:
372+
pattern: "(?i)fatal error|unhandled exception|stack trace"
373+
313374
# ═══════════════════════════════════════════
314375
# Response quality tests
315376
# ═══════════════════════════════════════════
@@ -376,3 +437,23 @@ stimuli:
376437
- type: output-not-matches
377438
config:
378439
pattern: "(?i)fatal error|unhandled exception|stack trace"
440+
441+
# ── storage-lifecycle-policy-quality ──
442+
# Assertions: assistant output mentions lifecycle policy concepts
443+
- name: "Storage optimization mentions lifecycle policies and tiers"
444+
prompt: "How can I optimize costs on my Azure storage accounts that have data sitting in hot tier for months?"
445+
config:
446+
runs: 1
447+
tags:
448+
type: integration
449+
tier: full
450+
cost: llm
451+
area: response-quality
452+
graders:
453+
- type: output-matches
454+
config:
455+
pattern: "(?i)lifecycle|cool|archive|tiering|access tier"
456+
- type: completed
457+
- type: output-not-matches
458+
config:
459+
pattern: "(?i)fatal error|unhandled exception|stack trace"

plugin/skills/azure-cost/SKILL.md

Lines changed: 22 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
name: azure-cost
3-
description: "Unified Azure cost management: query historical costs, forecast future spending, and optimize to reduce waste. WHEN: \"Azure costs\", \"Azure spending\", \"Azure bill\", \"cost breakdown\", \"cost by service\", \"cost by resource\", \"how much am I spending\", \"show my bill\", \"monthly cost summary\", \"cost trends\", \"top cost drivers\", \"actual cost\", \"amortized cost\", \"forecast spending\", \"projected costs\", \"estimate bill\", \"future costs\", \"budget forecast\", \"end of month costs\", \"how much will I spend\", \"optimize costs\", \"reduce spending\", \"find cost savings\", \"orphaned resources\", \"rightsize VMs\", \"cost analysis\", \"reduce waste\", \"unused resources\", \"optimize Redis costs\", \"cost by tag\", \"cost by resource group\", \"AKS cost analysis add-on\", \"namespace cost\", \"cost spike\", \"anomaly\", \"budget alert\", \"AKS cost visibility\". DO NOT USE FOR: deploying resources, provisioning infrastructure, diagnostics, security audits, or estimating costs for new resources not yet deployed."
3+
description: "Azure cost management: query costs, forecast spending, optimize to reduce waste. WHEN: \"Azure costs\", \"Azure bill\", \"cost breakdown\", \"how much am I spending\", \"forecast spending\", \"optimize costs\", \"reduce spending\", \"orphaned resources\", \"rightsize VMs\", \"cost spike\", \"reduce storage costs\", \"AKS cost\". DO NOT USE FOR: deploying resources, provisioning, diagnostics, or security audits."
44
license: MIT
55
metadata:
66
author: Microsoft
@@ -9,132 +9,37 @@ metadata:
99

1010
# Azure Cost Management Skill
1111

12-
Unified skill for all Azure cost management tasks: querying historical costs, forecasting future spending, and optimizing to reduce waste.
12+
Query historical costs, forecast future spending, optimize to reduce waste.
1313

14-
## When to Use This Skill
14+
## Routing
1515

16-
Activate this skill when user wants to:
17-
- Query or analyze Azure costs (how much am I spending, show my bill, cost breakdown)
18-
- Break down costs by service, resource, location, or tag
19-
- Analyze cost trends over time
20-
- Forecast future Azure spending or project end-of-month costs
21-
- Optimize Azure costs, reduce spending, or find savings
22-
- Find orphaned or unused resources
23-
- Rightsize Azure VMs, containers, or services
24-
- Generate cost optimization reports
16+
| User Intent | Workflow |
17+
|-------------|----------|
18+
| Understand current costs | [Cost Query](cost-query/workflow.md) |
19+
| Reduce costs / find waste | [Cost Optimization](cost-optimization/workflow.md) |
20+
| Project future costs | [Cost Forecast](cost-forecast/workflow.md) |
2521

2622
## Quick Reference
2723

2824
| Property | Value |
2925
|----------|-------|
30-
| **Query API Endpoint** | `POST {scope}/providers/Microsoft.CostManagement/query?api-version=2023-11-01` |
31-
| **Forecast API Endpoint** | `POST {scope}/providers/Microsoft.CostManagement/forecast?api-version=2023-11-01` |
32-
| **MCP Tools** | `azure__documentation`, `azure__extension_cli_generate`, `azure__get_azure_bestpractices` |
33-
| **CLI** | `az rest`, `az monitor metrics list`, `az resource list` |
34-
| **Required Role** | Cost Management Reader + Monitoring Reader + Reader on scope |
35-
36-
## MCP Tools
37-
38-
| Tool | Description | Parameters | When to Use |
39-
|------|-------------|------------|-------------|
40-
| `azure__documentation` | Search Azure documentation | `query` (Required): search terms | Research Cost Management API parameters and options |
41-
| `azure__extension_cli_generate` | Generate Azure CLI commands | `intent` (Required): task description, `cli-type` (Required): `"az"` | Construct `az rest` commands for cost queries |
42-
| `azure__get_azure_bestpractices` | Get Azure best practices | `intent` (Required): optimization context | Inform query design with cost management best practices |
43-
| `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 |
44-
| `azure__aks` | Azure Kubernetes Service operations | varies by sub-command | AKS cost analysis: list clusters, get node pools, inspect configuration |
45-
46-
> 💡 **Tip:** Prefer MCP tools over direct CLI commands. Use `az rest` only when MCP tools don't cover the specific operation.
47-
48-
---
49-
50-
## Routing
51-
52-
Read the user's request and follow the appropriate workflow below.
53-
54-
| User Intent | Workflow | Example Prompts |
55-
|-------------|----------|-----------------|
56-
| Understand current costs | [Cost Query Workflow](cost-query/workflow.md) | "how much am I spending", "cost by service", "show my bill" |
57-
| Reduce costs / find waste | [Cost Optimization Workflow](cost-optimization/workflow.md) | "optimize costs", "find orphaned resources", "reduce spending" |
58-
| Project future costs | [Cost Forecast Workflow](cost-forecast/workflow.md) | "forecast costs", "end of month estimate", "how much will I spend" |
59-
| Full cost picture | All three workflows combined | "give me the full picture of my Azure costs" |
60-
61-
> **Important:** When optimizing costs, always present the total bill and cost breakdown alongside optimization recommendations.
62-
63-
---
64-
65-
## Scope Reference (Shared Across All Workflows)
66-
67-
| Scope | URL Pattern |
68-
|-------|-------------|
69-
| Subscription | `/subscriptions/<subscription-id>` |
70-
| Resource Group | `/subscriptions/<subscription-id>/resourceGroups/<resource-group-name>` |
71-
| Management Group | `/providers/Microsoft.Management/managementGroups/<management-group-id>` |
72-
| Billing Account | `/providers/Microsoft.Billing/billingAccounts/<billing-account-id>` |
73-
| Billing Profile | `/providers/Microsoft.Billing/billingAccounts/<billing-account-id>/billingProfiles/<billing-profile-id>` |
74-
75-
> 💡 **Tip:** These are scope paths only — not complete URLs. Combine with the API endpoint and version.
76-
77-
---
78-
79-
## Part 1: Cost Query Workflow
80-
81-
For the full cost query workflow (scope selection, report types, timeframes, dataset configuration, API calls, pagination, guardrails, examples, and error handling), see:
82-
83-
📄 **[Cost Query Workflow](cost-query/workflow.md)**
84-
85-
---
86-
87-
## Part 2: Cost Optimization Workflow
88-
89-
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:
90-
91-
📄 **[Cost Optimization Workflow](cost-optimization/workflow.md)**
92-
93-
---
94-
95-
## Part 3: Cost Forecast Workflow
96-
97-
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:
98-
99-
📄 **[Cost Forecast Workflow](cost-forecast/workflow.md)**
100-
101-
---
102-
103-
## Data Classification
104-
105-
- **ACTUAL DATA** = Retrieved from Azure Cost Management API
106-
- **ACTUAL METRICS** = Retrieved from Azure Monitor
107-
- **VALIDATED PRICING** = Retrieved from official Azure pricing pages
108-
- **ESTIMATED SAVINGS** = Calculated based on actual data and validated pricing
109-
110-
## Best Practices
111-
112-
- Always query actual costs first — never estimate or assume
113-
- Always present the total bill alongside optimization recommendations
114-
- Validate pricing from official sources — account for free tiers
115-
- Use REST API for cost queries (more reliable than `az costmanagement query`)
116-
- Always include the `ClientType: GitHubCopilotForAzure` header on all Cost Management API requests (`--headers "ClientType=GitHubCopilotForAzure"` in `az rest`)
117-
- Save audit trail — include all queries and responses
118-
- Include Azure Portal links for all resources
119-
- For costs < $10/month, emphasize operational improvements over financial savings
120-
- Never execute destructive operations without explicit approval
121-
- On 429 responses, check all `x-ms-ratelimit-microsoft.costmanagement-*-retry-after` headers (`qpu-retry-after`, `entity-retry-after`, `tenant-retry-after`), wait for the longest value, and do not retry until that duration has elapsed. The per-scope limit (4 requests/minute) is the most restrictive.
26+
| **Query API** | `POST {scope}/providers/Microsoft.CostManagement/query?api-version=2023-11-01` |
27+
| **Forecast API** | `POST {scope}/providers/Microsoft.CostManagement/forecast?api-version=2023-11-01` |
28+
| **Required Role** | Cost Management Reader + Monitoring Reader + Reader (on target scope) |
12229

123-
## Common Pitfalls
30+
## Scope Patterns
12431

125-
- **Assuming costs**: Always query actual data from Cost Management API
126-
- **Ignoring free tiers**: Many services have generous allowances
127-
- **Using wrong date ranges**: 30 days for costs, 14 days for utilization
128-
- **Not showing the bill**: Always present cost breakdown alongside optimization recommendations
129-
- **Cost query failures**: Use `az rest` with JSON body, not `az costmanagement query`
32+
- Subscription: `/subscriptions/<id>`
33+
- Resource Group: `/subscriptions/<id>/resourceGroups/<name>`
34+
- Management Group: `/providers/Microsoft.Management/managementGroups/<id>`
35+
- Billing Account: `/providers/Microsoft.Billing/billingAccounts/<id>`
13036

131-
## Safety Requirements
37+
## Service-Specific Optimization
13238

133-
- Get approval before deleting resources
134-
- Test changes in non-production first
135-
- Provide dry-run commands for validation
136-
- Include rollback procedures
39+
- [Redis](cost-optimization/services/redis/azure-cache-for-redis.md)
40+
- [Storage](cost-optimization/services/storage/azure-storage.md)
13741

138-
## SDK Quick References
42+
## References
13943

140-
- **Redis Management**: [.NET](cost-optimization/sdk/azure-resource-manager-redis-dotnet.md)
44+
- [MCP Tools, Best Practices, Safety](references/tools-and-best-practices.md)
45+
- [SDK: Redis .NET](cost-optimization/sdk/azure-resource-manager-redis-dotnet.md)

0 commit comments

Comments
 (0)