Azure Cost Optimize

Azure Cost Optimize

Analyzes Azure resources and infrastructure code for cost savings and files a GitHub issue per optimisation plus an epic issue to track the work.

Skill files1 file
SKILL.md306 lines
1
---
2
name: az-cost-optimize
3
description: 'Analyze Azure resources used in the app (IaC files and/or resources in a target rg) and optimize costs - creating GitHub issues for identified optimizations.'
4
---
5
6
# Azure Cost Optimize
7
8
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.
9
10
## Prerequisites
11
- Azure MCP server configured and authenticated
12
- GitHub MCP server configured and authenticated
13
- Target GitHub repository identified
14
- Azure resources deployed (IaC files optional but helpful)
15
- Prefer Azure MCP tools (`azmcp-*`) over direct Azure CLI when available
16
17
## Workflow Steps
18
19
### Step 1: Get Azure Best Practices
20
**Action**: Retrieve cost optimization best practices before analysis
21
**Tools**: Azure MCP best practices tool
22
**Process**:
23
1. **Load Best Practices**:
24
- Execute `azmcp-bestpractices-get` to get some of the latest Azure optimization guidelines. This may not cover all scenarios but provides a foundation.
25
- Use these practices to inform subsequent analysis and recommendations as much as possible
26
- Reference best practices in optimization recommendations, either from the MCP tool output or general Azure documentation
27
28
### Step 2: Discover Azure Infrastructure
29
**Action**: Dynamically discover and analyze Azure resources and configurations
30
**Tools**: Azure MCP tools + Azure CLI fallback + Local file system access
31
**Process**:
32
1. **Resource Discovery**:
33
- Execute `azmcp-subscription-list` to find available subscriptions
34
- Execute `azmcp-group-list --subscription <subscription-id>` to find resource groups
35
- Get a list of all resources in the relevant group(s):
36
- Use `az resource list --subscription <id> --resource-group <name>`
37
- For each resource type, use MCP tools first if possible, then CLI fallback:
38
- `azmcp-cosmos-account-list --subscription <id>` - Cosmos DB accounts
39
- `azmcp-storage-account-list --subscription <id>` - Storage accounts
40
- `azmcp-monitor-workspace-list --subscription <id>` - Log Analytics workspaces
41
- `azmcp-keyvault-key-list` - Key Vaults
42
- `az webapp list` - Web Apps (fallback - no MCP tool available)
43
- `az appservice plan list` - App Service Plans (fallback)
44
- `az functionapp list` - Function Apps (fallback)
45
- `az sql server list` - SQL Servers (fallback)
46
- `az redis list` - Redis Cache (fallback)
47
- ... and so on for other resource types
48
49
2. **IaC Detection**:
50
- Use `file_search` to scan for IaC files: "**/*.bicep", "**/*.tf", "**/main.json", "**/*template*.json"
51
- Parse resource definitions to understand intended configurations
52
- Compare against discovered resources to identify discrepancies
53
- Note presence of IaC files for implementation recommendations later on
54
- Do NOT use any other file from the repository, only IaC files. Using other files is NOT allowed as it is not a source of truth.
55
- If you do not find IaC files, then STOP and report no IaC files found to the user.
56
57
3. **Configuration Analysis**:
58
- Extract current SKUs, tiers, and settings for each resource
59
- Identify resource relationships and dependencies
60
- Map resource utilization patterns where available
61
62
### Step 3: Collect Usage Metrics & Validate Current Costs
63
**Action**: Gather utilization data AND verify actual resource costs
64
**Tools**: Azure MCP monitoring tools + Azure CLI
65
**Process**:
66
1. **Find Monitoring Sources**:
67
- Use `azmcp-monitor-workspace-list --subscription <id>` to find Log Analytics workspaces
68
- Use `azmcp-monitor-table-list --subscription <id> --workspace <name> --table-type "CustomLog"` to discover available data
69
70
2. **Execute Usage Queries**:
71
- Use `azmcp-monitor-log-query` with these predefined queries:
72
- Query: "recent" for recent activity patterns
73
- Query: "errors" for error-level logs indicating issues
74
- For custom analysis, use KQL queries:
75
```kql
76
// CPU utilization for App Services
77
AppServiceAppLogs
78
| where TimeGenerated > ago(7d)
79
| summarize avg(CpuTime) by Resource, bin(TimeGenerated, 1h)
80
81
// Cosmos DB RU consumption
82
AzureDiagnostics
83
| where ResourceProvider == "MICROSOFT.DOCUMENTDB"
84
| where TimeGenerated > ago(7d)
85
| summarize avg(RequestCharge) by Resource
86
87
// Storage account access patterns
88
StorageBlobLogs
89
| where TimeGenerated > ago(7d)
90
| summarize RequestCount=count() by AccountName, bin(TimeGenerated, 1d)
91
```
92
93
3. **Calculate Baseline Metrics**:
94
- CPU/Memory utilization averages
95
- Database throughput patterns
96
- Storage access frequency
97
- Function execution rates
98
99
4. **VALIDATE CURRENT COSTS**:
100
- Using the SKU/tier configurations discovered in Step 2
101
- Look up current Azure pricing at https://azure.microsoft.com/pricing/ or use `az billing` commands
102
- Document: Resource → Current SKU → Estimated monthly cost
103
- Calculate realistic current monthly total before proceeding to recommendations
104
105
### Step 4: Generate Cost Optimization Recommendations
106
**Action**: Analyze resources to identify optimization opportunities
107
**Tools**: Local analysis using collected data
108
**Process**:
109
1. **Apply Optimization Patterns** based on resource types found:
110
111
**Compute Optimizations**:
112
- App Service Plans: Right-size based on CPU/memory usage
113
- Function Apps: Premium → Consumption plan for low usage
114
- Virtual Machines: Scale down oversized instances
115
116
**Database Optimizations**:
117
- Cosmos DB:
118
- Provisioned → Serverless for variable workloads
119
- Right-size RU/s based on actual usage
120
- SQL Database: Right-size service tiers based on DTU usage
121
122
**Storage Optimizations**:
123
- Implement lifecycle policies (Hot → Cool → Archive)
124
- Consolidate redundant storage accounts
125
- Right-size storage tiers based on access patterns
126
127
**Infrastructure Optimizations**:
128
- Remove unused/redundant resources
129
- Implement auto-scaling where beneficial
130
- Schedule non-production environments
131
132
2. **Calculate Evidence-Based Savings**:
133
- Current validated cost → Target cost = Savings
134
- Document pricing source for both current and target configurations
135
136
3. **Calculate Priority Score** for each recommendation:
137
```
138
Priority Score = (Value Score × Monthly Savings) / (Risk Score × Implementation Days)
139
140
High Priority: Score > 20
141
Medium Priority: Score 5-20
142
Low Priority: Score < 5
143
```
144
145
4. **Validate Recommendations**:
146
- Ensure Azure CLI commands are accurate
147
- Verify estimated savings calculations
148
- Assess implementation risks and prerequisites
149
- Ensure all savings calculations have supporting evidence
150
151
### Step 5: User Confirmation
152
**Action**: Present summary and get approval before creating GitHub issues
153
**Process**:
154
1. **Display Optimization Summary**:
155
```
156
🎯 Azure Cost Optimization Summary
157
158
📊 Analysis Results:
159
• Total Resources Analyzed: X
160
• Current Monthly Cost: $X
161
• Potential Monthly Savings: $Y
162
• Optimization Opportunities: Z
163
• High Priority Items: N
164
165
🏆 Recommendations:
166
1. [Resource]: [Current SKU] → [Target SKU] = $X/month savings - [Risk Level] | [Implementation Effort]
167
2. [Resource]: [Current Config] → [Target Config] = $Y/month savings - [Risk Level] | [Implementation Effort]
168
3. [Resource]: [Current Config] → [Target Config] = $Z/month savings - [Risk Level] | [Implementation Effort]
169
... and so on
170
171
💡 This will create:
172
• Y individual GitHub issues (one per optimization)
173
• 1 EPIC issue to coordinate implementation
174
175
❓ Proceed with creating GitHub issues? (y/n)
176
```
177
178
2. **Wait for User Confirmation**: Only proceed if user confirms
179
180
### Step 6: Create Individual Optimization Issues
181
**Action**: Create separate GitHub issues for each optimization opportunity. Label them with "cost-optimization" (green color), "azure" (blue color).
182
**MCP Tools Required**: `create_issue` for each recommendation
183
**Process**:
184
1. **Create Individual Issues** using this template:
185
186
**Title Format**: `[COST-OPT] [Resource Type] - [Brief Description] - $X/month savings`
187
188
**Body Template**:
189
```markdown
190
## 💰 Cost Optimization: [Brief Title]
191
192
**Monthly Savings**: $X | **Risk Level**: [Low/Medium/High] | **Implementation Effort**: X days
193
194
### 📋 Description
195
[Clear explanation of the optimization and why it's needed]
196
197
### 🔧 Implementation
198
199
**IaC Files Detected**: [Yes/No - based on file_search results]
200
201
```bash
202
# If IaC files found: Show IaC modifications + deployment
203
# File: infrastructure/bicep/modules/app-service.bicep
204
# Change: sku.name: 'S3' → 'B2'
205
az deployment group create --resource-group [rg] --template-file infrastructure/bicep/main.bicep
206
207
# If no IaC files: Direct Azure CLI commands + warning
208
# ⚠️ No IaC files found. If they exist elsewhere, modify those instead.
209
az appservice plan update --name [plan] --sku B2
210
```
211
212
### 📊 Evidence
213
- Current Configuration: [details]
214
- Usage Pattern: [evidence from monitoring data]
215
- Cost Impact: $X/month → $Y/month
216
- Best Practice Alignment: [reference to Azure best practices if applicable]
217
218
### ✅ Validation Steps
219
- [ ] Test in non-production environment
220
- [ ] Verify no performance degradation
221
- [ ] Confirm cost reduction in Azure Cost Management
222
- [ ] Update monitoring and alerts if needed
223
224
### ⚠️ Risks & Considerations
225
- [Risk 1 and mitigation]
226
- [Risk 2 and mitigation]
227
228
**Priority Score**: X | **Value**: X/10 | **Risk**: X/10
229
```
230
231
### Step 7: Create EPIC Coordinating Issue
232
**Action**: Create master issue to track all optimization work. Label it with "cost-optimization" (green color), "azure" (blue color), and "epic" (purple color).
233
**MCP Tools Required**: `create_issue` for EPIC
234
**Note about mermaid diagrams**: Ensure you verify mermaid syntax is correct and create the diagrams taking accessibility guidelines into account (styling, colors, etc.).
235
**Process**:
236
1. **Create EPIC Issue**:
237
238
**Title**: `[EPIC] Azure Cost Optimization Initiative - $X/month potential savings`
239
240
**Body Template**:
241
```markdown
242
# 🎯 Azure Cost Optimization EPIC
243
244
**Total Potential Savings**: $X/month | **Implementation Timeline**: X weeks
245
246
## 📊 Executive Summary
247
- **Resources Analyzed**: X
248
- **Optimization Opportunities**: Y
249
- **Total Monthly Savings Potential**: $X
250
- **High Priority Items**: N
251
252
## 🏗️ Current Architecture Overview
253
254
```mermaid
255
graph TB
256
subgraph "Resource Group: [name]"
257
[Generated architecture diagram showing current resources and costs]
258
end
259
```
260
261
## 📋 Implementation Tracking
262
263
### 🚀 High Priority (Implement First)
264
- [ ] #[issue-number]: [Title] - $X/month savings
265
- [ ] #[issue-number]: [Title] - $X/month savings
266
267
### ⚡ Medium Priority
268
- [ ] #[issue-number]: [Title] - $X/month savings
269
- [ ] #[issue-number]: [Title] - $X/month savings
270
271
### 🔄 Low Priority (Nice to Have)
272
- [ ] #[issue-number]: [Title] - $X/month savings
273
274
## 📈 Progress Tracking
275
- **Completed**: 0 of Y optimizations
276
- **Savings Realized**: $0 of $X/month
277
- **Implementation Status**: Not Started
278
279
## 🎯 Success Criteria
280
- [ ] All high-priority optimizations implemented
281
- [ ] >80% of estimated savings realized
282
- [ ] No performance degradation observed
283
- [ ] Cost monitoring dashboard updated
284
285
## 📝 Notes
286
- Review and update this EPIC as issues are completed
287
- Monitor actual vs. estimated savings
288
- Consider scheduling regular cost optimization reviews
289
```
290
291
## Error Handling
292
- **Cost Validation**: If savings estimates lack supporting evidence or seem inconsistent with Azure pricing, re-verify configurations and pricing sources before proceeding
293
- **Azure Authentication Failure**: Provide manual Azure CLI setup steps
294
- **No Resources Found**: Create informational issue about Azure resource deployment
295
- **GitHub Creation Failure**: Output formatted recommendations to console
296
- **Insufficient Usage Data**: Note limitations and provide configuration-based recommendations only
297
298
## Success Criteria
299
- ✅ All cost estimates verified against actual resource configurations and Azure pricing
300
- ✅ Individual issues created for each optimization (trackable and assignable)
301
- ✅ EPIC issue provides comprehensive coordination and tracking
302
- ✅ All recommendations include specific, executable Azure CLI commands
303
- ✅ Priority scoring enables ROI-focused implementation
304
- ✅ Architecture diagram accurately represents current state
305
- ✅ User confirmation prevents unwanted issue creation
306

© GitHub, Inc. · MIT · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 14,621 prompts

More by @OpenSourceBuffGuy

See all
Sea turtle carrying floating film studio island prompt image

Sea turtle carrying floating film studio island

Draws a giant sea turtle carrying a floating island film studio through a starry sky, where fairies polish rough film strips into golden film.

image-prompt, nano-banana, 3d-render, cartoon, fantasy-world, creatures, animals, whimsical, dreamy, cinematic, dramatic-lighting, vibrant-colors, bokeh, miniature, widescreen, night-scene, illustration, concept-art, surreal, storytelling, clay-3d

Desert buggy escapes drones past industrial outpost prompt image

Desert buggy escapes drones past industrial outpost

Builds a 15-second desert chase video where a racer in an armored buggy escapes drones past an industrial outpost, using five reference images with set jobs.

video-prompt, hailuo, action, multi-shot, timed-beats, camera-movement, reference-image, character-consistency, negative-prompt, cinematic, sci-fi, cars, landscape, aerial-view, tracking-shot, photorealistic, sound-effects, structured-output, long-form, widescreen

1 view
Cozy Pixel Art Farm Island Village prompt image

Cozy Pixel Art Farm Island Village

Draws a cozy 16-bit pixel-art farming village across six small islands joined by bridges, with exact counts for buildings, animals and crops.

image-prompt, gpt-image, pixel-art, isometric, game-assets, concept-art, maps, worldbuilding, cozy, vibrant-colors, ocean, landscape, wide-shot, widescreen, game-development, video-games, structured-output, whimsical, summer, high-angle, aerial-view, animals, negative-prompt, cityscape

1 view

Reviews

Loading reviews…

Discussion

Loading comments…