fraim-framework 2.0.67 → 2.0.68
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -2
- package/dist/registry/ai-manager-rules/customer-development-phases/phase1-customer-profiling.md +0 -101
- package/dist/registry/ai-manager-rules/customer-development-phases/phase2-platform-discovery.md +0 -235
- package/dist/registry/ai-manager-rules/customer-development-phases/phase3-prospect-qualification.md +0 -243
- package/dist/registry/ai-manager-rules/customer-development-phases/phase4-inventory-compilation.md +0 -206
- package/dist/registry/ai-manager-rules/design-phases/design-completeness-review.md +0 -73
- package/dist/registry/ai-manager-rules/design-phases/design-design.md +0 -145
- package/dist/registry/ai-manager-rules/design-phases/design.md +0 -108
- package/dist/registry/ai-manager-rules/design-phases/finalize.md +0 -60
- package/dist/registry/ai-manager-rules/design-phases/validate.md +0 -125
- package/dist/registry/ai-manager-rules/design.json +0 -97
- package/dist/registry/ai-manager-rules/implement-phases/code.md +0 -323
- package/dist/registry/ai-manager-rules/implement-phases/completeness-review.md +0 -94
- package/dist/registry/ai-manager-rules/implement-phases/finalize.md +0 -177
- package/dist/registry/ai-manager-rules/implement-phases/implement-code.md +0 -283
- package/dist/registry/ai-manager-rules/implement-phases/implement-completeness-review.md +0 -120
- package/dist/registry/ai-manager-rules/implement-phases/implement-regression.md +0 -173
- package/dist/registry/ai-manager-rules/implement-phases/implement-repro.md +0 -104
- package/dist/registry/ai-manager-rules/implement-phases/implement-scoping.md +0 -100
- package/dist/registry/ai-manager-rules/implement-phases/implement-smoke.md +0 -237
- package/dist/registry/ai-manager-rules/implement-phases/implement-spike.md +0 -121
- package/dist/registry/ai-manager-rules/implement-phases/implement-validate.md +0 -375
- package/dist/registry/ai-manager-rules/implement-phases/quality-review.md +0 -304
- package/dist/registry/ai-manager-rules/implement-phases/regression.md +0 -159
- package/dist/registry/ai-manager-rules/implement-phases/repro.md +0 -101
- package/dist/registry/ai-manager-rules/implement-phases/scoping.md +0 -93
- package/dist/registry/ai-manager-rules/implement-phases/smoke.md +0 -225
- package/dist/registry/ai-manager-rules/implement-phases/spike.md +0 -118
- package/dist/registry/ai-manager-rules/implement-phases/validate.md +0 -347
- package/dist/registry/ai-manager-rules/implement.json +0 -153
- package/dist/registry/ai-manager-rules/retrospective.md +0 -116
- package/dist/registry/ai-manager-rules/shared-phases/address-pr-feedback.md +0 -188
- package/dist/registry/ai-manager-rules/shared-phases/finalize.md +0 -169
- package/dist/registry/ai-manager-rules/shared-phases/submit-pr.md +0 -202
- package/dist/registry/ai-manager-rules/shared-phases/wait-for-pr-review.md +0 -170
- package/dist/registry/ai-manager-rules/spec-phases/finalize.md +0 -60
- package/dist/registry/ai-manager-rules/spec-phases/spec-competitor-analysis.md +0 -105
- package/dist/registry/ai-manager-rules/spec-phases/spec-completeness-review.md +0 -66
- package/dist/registry/ai-manager-rules/spec-phases/spec-spec.md +0 -139
- package/dist/registry/ai-manager-rules/spec-phases/spec.md +0 -102
- package/dist/registry/ai-manager-rules/spec-phases/validate.md +0 -118
- package/dist/registry/ai-manager-rules/spec.json +0 -112
- package/dist/registry/ai-manager-rules/test.json +0 -98
- package/dist/registry/ai-manager-rules/user-survey-phases/phase1-survey-scoping.md +0 -60
- package/dist/registry/ai-manager-rules/user-survey-phases/phase2-survey-build-linkedin.md +0 -23
- package/dist/registry/ai-manager-rules/user-survey-phases/phase3-survey-build-reddit.md +0 -22
- package/dist/registry/ai-manager-rules/user-survey-phases/phase4-survey-build-x.md +0 -21
- package/dist/registry/ai-manager-rules/user-survey-phases/phase5-survey-build-facebook.md +0 -19
- package/dist/registry/ai-manager-rules/user-survey-phases/phase6-survey-build-custom.md +0 -15
- package/dist/registry/ai-manager-rules/user-survey-phases/phase7-survey-dispatch.md +0 -45
- package/dist/registry/delivery/address-feedback.md +0 -83
- package/dist/registry/delivery/retrospective.md +0 -78
- package/dist/registry/delivery/submit.md +0 -79
- package/dist/registry/providers/ado.json +0 -19
- package/dist/registry/providers/delivery-conversation.json +0 -9
- package/dist/registry/providers/delivery-pr.json +0 -9
- package/dist/registry/providers/github.json +0 -19
- package/dist/registry/rules/agent-success-criteria.md +0 -101
- package/dist/registry/rules/agent-testing-guidelines.md +0 -502
- package/dist/registry/rules/architecture.md +0 -126
- package/dist/registry/rules/communication.md +0 -122
- package/dist/registry/rules/continuous-learning.md +0 -55
- package/dist/registry/rules/debugging-multitenancy-issues.md +0 -85
- package/dist/registry/rules/ephemeral-execution.md +0 -54
- package/dist/registry/rules/git-safe-commands.md +0 -34
- package/dist/registry/rules/hitl-ppe-record-analysis.md +0 -302
- package/dist/registry/rules/integrity-and-test-ethics.md +0 -275
- package/dist/registry/rules/local-development.md +0 -275
- package/dist/registry/rules/mandatory-pre-completion-reflection.md +0 -193
- package/dist/registry/rules/merge-requirements.md +0 -238
- package/dist/registry/rules/simplicity.md +0 -118
- package/dist/registry/rules/software-development-lifecycle.md +0 -105
- package/dist/registry/rules/spike-first-development.md +0 -205
- package/dist/registry/rules/successful-debugging-patterns.md +0 -488
- package/dist/registry/scripts/build-scripts-generator.js +0 -205
- package/dist/registry/scripts/cleanup-branch.js +0 -287
- package/dist/registry/scripts/evaluate-code-quality.js +0 -66
- package/dist/registry/scripts/exec-with-timeout.js +0 -142
- package/dist/registry/scripts/fraim-config.js +0 -61
- package/dist/registry/scripts/generate-engagement-emails.js +0 -705
- package/dist/registry/scripts/generic-issues-api.js +0 -100
- package/dist/registry/scripts/newsletter-helpers.js +0 -671
- package/dist/registry/scripts/openapi-generator.js +0 -664
- package/dist/registry/scripts/performance/profile-server.js +0 -390
- package/dist/registry/scripts/profile-server.js +0 -389
- package/dist/registry/scripts/run-thank-you-workflow.js +0 -92
- package/dist/registry/scripts/send-newsletter-simple.js +0 -85
- package/dist/registry/scripts/send-thank-you-emails.js +0 -54
- package/dist/registry/scripts/validate-openapi-limits.js +0 -311
- package/dist/registry/scripts/validate-test-coverage.js +0 -262
- package/dist/registry/scripts/verify-test-coverage.js +0 -66
- package/dist/registry/stubs/workflows/azure/cost-optimization.md +0 -11
- package/dist/registry/stubs/workflows/bootstrap/create-architecture.md +0 -11
- package/dist/registry/stubs/workflows/bootstrap/detect-broken-windows.md +0 -11
- package/dist/registry/stubs/workflows/bootstrap/evaluate-code-quality.md +0 -11
- package/dist/registry/stubs/workflows/bootstrap/verify-test-coverage.md +0 -11
- package/dist/registry/stubs/workflows/brainstorming/blue-sky-brainstorming.md +0 -11
- package/dist/registry/stubs/workflows/brainstorming/codebase-brainstorming.md +0 -11
- package/dist/registry/stubs/workflows/business-development/create-business-plan.md +0 -11
- package/dist/registry/stubs/workflows/business-development/ideate-business-opportunity.md +0 -11
- package/dist/registry/stubs/workflows/business-development/price-product.md +0 -18
- package/dist/registry/stubs/workflows/compliance/detect-compliance-requirements.md +0 -11
- package/dist/registry/stubs/workflows/compliance/generate-audit-evidence.md +0 -11
- package/dist/registry/stubs/workflows/compliance/soc2-evidence-generator.md +0 -11
- package/dist/registry/stubs/workflows/customer-development/insight-analysis.md +0 -11
- package/dist/registry/stubs/workflows/customer-development/insight-triage.md +0 -11
- package/dist/registry/stubs/workflows/customer-development/interview-preparation.md +0 -11
- package/dist/registry/stubs/workflows/customer-development/linkedin-outreach.md +0 -11
- package/dist/registry/stubs/workflows/customer-development/strategic-brainstorming.md +0 -11
- package/dist/registry/stubs/workflows/customer-development/thank-customers.md +0 -11
- package/dist/registry/stubs/workflows/customer-development/user-survey-dispatch.md +0 -11
- package/dist/registry/stubs/workflows/customer-development/users-to-target.md +0 -11
- package/dist/registry/stubs/workflows/customer-development/weekly-newsletter.md +0 -11
- package/dist/registry/stubs/workflows/deploy/cloud-deployment.md +0 -11
- package/dist/registry/stubs/workflows/improve-fraim/contribute.md +0 -11
- package/dist/registry/stubs/workflows/improve-fraim/file-issue.md +0 -11
- package/dist/registry/stubs/workflows/learning/build-skillset.md +0 -11
- package/dist/registry/stubs/workflows/learning/synthesize-learnings.md +0 -11
- package/dist/registry/stubs/workflows/legal/contract-review-analysis.md +0 -11
- package/dist/registry/stubs/workflows/legal/nda.md +0 -11
- package/dist/registry/stubs/workflows/legal/patent-filing.md +0 -11
- package/dist/registry/stubs/workflows/legal/saas-contract-development.md +0 -11
- package/dist/registry/stubs/workflows/legal/trademark-filing.md +0 -11
- package/dist/registry/stubs/workflows/marketing/content-creation.md +0 -11
- package/dist/registry/stubs/workflows/marketing/convert-to-pdf.md +0 -11
- package/dist/registry/stubs/workflows/marketing/create-modern-website.md +0 -11
- package/dist/registry/stubs/workflows/marketing/domain-registration.md +0 -11
- package/dist/registry/stubs/workflows/marketing/evangelize.md +0 -11
- package/dist/registry/stubs/workflows/marketing/hbr-article.md +0 -11
- package/dist/registry/stubs/workflows/marketing/launch-checklist.md +0 -11
- package/dist/registry/stubs/workflows/marketing/marketing-strategy.md +0 -11
- package/dist/registry/stubs/workflows/marketing/storytelling.md +0 -11
- package/dist/registry/stubs/workflows/performance/analyze-performance.md +0 -11
- package/dist/registry/stubs/workflows/product-building/design.md +0 -11
- package/dist/registry/stubs/workflows/product-building/implement.md +0 -11
- package/dist/registry/stubs/workflows/product-building/iterate-on-pr-comments.md +0 -11
- package/dist/registry/stubs/workflows/product-building/prep-issue.md +0 -11
- package/dist/registry/stubs/workflows/product-building/prototype.md +0 -11
- package/dist/registry/stubs/workflows/product-building/resolve.md +0 -11
- package/dist/registry/stubs/workflows/product-building/retrospect.md +0 -11
- package/dist/registry/stubs/workflows/product-building/spec.md +0 -11
- package/dist/registry/stubs/workflows/product-building/test.md +0 -11
- package/dist/registry/stubs/workflows/productivity-report/productivity-report.md +0 -11
- package/dist/registry/stubs/workflows/quality-assurance/browser-validation.md +0 -11
- package/dist/registry/stubs/workflows/quality-assurance/iterative-improvement-cycle.md +0 -11
- package/dist/registry/stubs/workflows/replicate/replicate-discovery.md +0 -11
- package/dist/registry/stubs/workflows/replicate/replicate-to-issues.md +0 -11
- package/dist/registry/stubs/workflows/reviewer/review-implementation-vs-design-spec.md +0 -11
- package/dist/registry/stubs/workflows/reviewer/review-implementation-vs-feature-spec.md +0 -11
- package/dist/registry/stubs/workflows/startup-credits/aws-activate-application.md +0 -11
- package/dist/registry/stubs/workflows/startup-credits/google-cloud-application.md +0 -11
- package/dist/registry/stubs/workflows/startup-credits/microsoft-azure-application.md +0 -11
- package/dist/registry/templates/bootstrap/ARCHITECTURE-TEMPLATE.md +0 -53
- package/dist/registry/templates/bootstrap/CODE-QUALITY-REPORT-TEMPLATE.md +0 -37
- package/dist/registry/templates/bootstrap/TEST-COVERAGE-REPORT-TEMPLATE.md +0 -35
- package/dist/registry/templates/business-development/IDEATION-REPORT-TEMPLATE.md +0 -29
- package/dist/registry/templates/business-development/PRICING-STRATEGY-TEMPLATE.md +0 -126
- package/dist/registry/templates/customer-development/customer-interview-template.md +0 -99
- package/dist/registry/templates/customer-development/customer-persona-template.md +0 -69
- package/dist/registry/templates/customer-development/follow-up-email-templates.md +0 -132
- package/dist/registry/templates/customer-development/insight-analysis-template.md +0 -74
- package/dist/registry/templates/customer-development/prospect-inventory-template.csv +0 -3
- package/dist/registry/templates/customer-development/search-strategy-template.md +0 -123
- package/dist/registry/templates/customer-development/strategic-recommendations-template.md +0 -53
- package/dist/registry/templates/customer-development/thank-you-email-template.html +0 -124
- package/dist/registry/templates/customer-development/thank-you-note-template.md +0 -16
- package/dist/registry/templates/customer-development/triage-log-template.md +0 -278
- package/dist/registry/templates/customer-development/weekly-newsletter-template.html +0 -204
- package/dist/registry/templates/evidence/Design-Evidence.md +0 -30
- package/dist/registry/templates/evidence/Implementation-BugEvidence.md +0 -122
- package/dist/registry/templates/evidence/Implementation-FeatureEvidence.md +0 -160
- package/dist/registry/templates/evidence/Spec-Evidence.md +0 -19
- package/dist/registry/templates/help/HelpNeeded.md +0 -14
- package/dist/registry/templates/legal/NDA-TEMPLATE.md +0 -170
- package/dist/registry/templates/legal/PATENT-TEMPLATE.md +0 -372
- package/dist/registry/templates/legal/TRADEMARK-TEMPLATE.md +0 -339
- package/dist/registry/templates/legal/contract-review-checklist.md +0 -193
- package/dist/registry/templates/legal/review-report-template.md +0 -198
- package/dist/registry/templates/legal/saas-terms-template.md +0 -174
- package/dist/registry/templates/legal/sow-template.md +0 -117
- package/dist/registry/templates/legal/template-variables.md +0 -131
- package/dist/registry/templates/marketing/DOMAIN-REGISTRATION-TEMPLATE.md +0 -194
- package/dist/registry/templates/marketing/EVANGELIZE-TEMPLATE.md +0 -102
- package/dist/registry/templates/marketing/HBR-ARTICLE-TEMPLATE.md +0 -66
- package/dist/registry/templates/marketing/STORYTELLING-TEMPLATE.md +0 -130
- package/dist/registry/templates/marketing/WEBSITE-TEMPLATE.md +0 -262
- package/dist/registry/templates/marketing/github-pages-workflow.yml +0 -64
- package/dist/registry/templates/replicate/implementation-checklist.md +0 -39
- package/dist/registry/templates/replicate/use-cases-template.md +0 -88
- package/dist/registry/templates/retrospective/RETROSPECTIVE-TEMPLATE.md +0 -55
- package/dist/registry/templates/specs/BUGSPEC-TEMPLATE.md +0 -37
- package/dist/registry/templates/specs/FEATURESPEC-TEMPLATE.md +0 -66
- package/dist/registry/templates/specs/TECHSPEC-TEMPLATE.md +0 -39
- package/dist/registry/workflows/azure/cost-optimization.md +0 -772
- package/dist/registry/workflows/bootstrap/create-architecture.md +0 -37
- package/dist/registry/workflows/bootstrap/detect-broken-windows.md +0 -300
- package/dist/registry/workflows/bootstrap/evaluate-code-quality.md +0 -35
- package/dist/registry/workflows/bootstrap/verify-test-coverage.md +0 -36
- package/dist/registry/workflows/brainstorming/blue-sky-brainstorming.md +0 -211
- package/dist/registry/workflows/brainstorming/codebase-brainstorming.md +0 -159
- package/dist/registry/workflows/business-development/create-business-plan.md +0 -737
- package/dist/registry/workflows/business-development/ideate-business-opportunity.md +0 -55
- package/dist/registry/workflows/business-development/price-product.md +0 -325
- package/dist/registry/workflows/compliance/detect-compliance-requirements.md +0 -80
- package/dist/registry/workflows/compliance/generate-audit-evidence.md +0 -80
- package/dist/registry/workflows/compliance/soc2-evidence-generator.md +0 -332
- package/dist/registry/workflows/customer-development/insight-analysis.md +0 -156
- package/dist/registry/workflows/customer-development/insight-triage.md +0 -933
- package/dist/registry/workflows/customer-development/interview-preparation.md +0 -452
- package/dist/registry/workflows/customer-development/linkedin-outreach.md +0 -599
- package/dist/registry/workflows/customer-development/strategic-brainstorming.md +0 -146
- package/dist/registry/workflows/customer-development/thank-customers.md +0 -203
- package/dist/registry/workflows/customer-development/user-survey-dispatch.md +0 -312
- package/dist/registry/workflows/customer-development/users-to-target.md +0 -427
- package/dist/registry/workflows/customer-development/weekly-newsletter.md +0 -366
- package/dist/registry/workflows/deploy/cloud-deployment.md +0 -310
- package/dist/registry/workflows/improve-fraim/contribute.md +0 -32
- package/dist/registry/workflows/improve-fraim/file-issue.md +0 -32
- package/dist/registry/workflows/learning/build-skillset.md +0 -212
- package/dist/registry/workflows/learning/synthesize-learnings.md +0 -369
- package/dist/registry/workflows/legal/contract-review-analysis.md +0 -382
- package/dist/registry/workflows/legal/nda.md +0 -69
- package/dist/registry/workflows/legal/patent-filing.md +0 -76
- package/dist/registry/workflows/legal/saas-contract-development.md +0 -204
- package/dist/registry/workflows/legal/trademark-filing.md +0 -77
- package/dist/registry/workflows/marketing/content-creation.md +0 -40
- package/dist/registry/workflows/marketing/convert-to-pdf.md +0 -265
- package/dist/registry/workflows/marketing/create-modern-website.md +0 -456
- package/dist/registry/workflows/marketing/domain-registration.md +0 -323
- package/dist/registry/workflows/marketing/evangelize.md +0 -426
- package/dist/registry/workflows/marketing/hbr-article.md +0 -73
- package/dist/registry/workflows/marketing/launch-checklist.md +0 -37
- package/dist/registry/workflows/marketing/marketing-strategy.md +0 -45
- package/dist/registry/workflows/marketing/storytelling.md +0 -65
- package/dist/registry/workflows/performance/analyze-performance.md +0 -65
- package/dist/registry/workflows/product-building/design.md +0 -263
- package/dist/registry/workflows/product-building/implement.md +0 -771
- package/dist/registry/workflows/product-building/iterate-on-pr-comments.md +0 -70
- package/dist/registry/workflows/product-building/prep-issue.md +0 -41
- package/dist/registry/workflows/product-building/prototype.md +0 -60
- package/dist/registry/workflows/product-building/resolve.md +0 -175
- package/dist/registry/workflows/product-building/retrospect.md +0 -86
- package/dist/registry/workflows/product-building/spec.md +0 -303
- package/dist/registry/workflows/product-building/test.md +0 -125
- package/dist/registry/workflows/productivity-report/productivity-report.md +0 -263
- package/dist/registry/workflows/quality-assurance/browser-validation.md +0 -221
- package/dist/registry/workflows/quality-assurance/iterative-improvement-cycle.md +0 -562
- package/dist/registry/workflows/replicate/replicate-discovery.md +0 -336
- package/dist/registry/workflows/replicate/replicate-to-issues.md +0 -319
- package/dist/registry/workflows/reviewer/review-implementation-vs-design-spec.md +0 -694
- package/dist/registry/workflows/reviewer/review-implementation-vs-feature-spec.md +0 -734
- package/dist/registry/workflows/startup-credits/aws-activate-application.md +0 -535
- package/dist/registry/workflows/startup-credits/google-cloud-application.md +0 -647
- package/dist/registry/workflows/startup-credits/microsoft-azure-application.md +0 -538
|
@@ -1,772 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
{
|
|
3
|
-
"name": "cost-optimization",
|
|
4
|
-
"initialPhase": "verify-auth",
|
|
5
|
-
"phases": {
|
|
6
|
-
"verify-auth": {
|
|
7
|
-
"onSuccess": "gather-data",
|
|
8
|
-
"onFailure": "verify-auth"
|
|
9
|
-
},
|
|
10
|
-
"gather-data": {
|
|
11
|
-
"onSuccess": "identify-opportunities",
|
|
12
|
-
"onFailure": "gather-data"
|
|
13
|
-
},
|
|
14
|
-
"identify-opportunities": {
|
|
15
|
-
"onSuccess": "prioritize-actions",
|
|
16
|
-
"onFailure": "identify-opportunities"
|
|
17
|
-
},
|
|
18
|
-
"prioritize-actions": {
|
|
19
|
-
"onSuccess": "execute-changes",
|
|
20
|
-
"onFailure": "prioritize-actions"
|
|
21
|
-
},
|
|
22
|
-
"execute-changes": {
|
|
23
|
-
"onSuccess": null,
|
|
24
|
-
"onFailure": "execute-changes"
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
---
|
|
29
|
-
# Workflow: Azure Cloud Cost Optimization
|
|
30
|
-
|
|
31
|
-
## INTENT
|
|
32
|
-
|
|
33
|
-
Enable AI agents to systematically analyze Azure subscription costs, identify optimization opportunities, and implement cost-saving measures while maintaining production reliability.
|
|
34
|
-
|
|
35
|
-
## PRINCIPLES
|
|
36
|
-
|
|
37
|
-
- **Safety First**: Explicit user approval required before any changes
|
|
38
|
-
- **Full Documentation**: Every action logged with before/after states
|
|
39
|
-
- **Risk-Based Prioritization**: Balance savings against production impact
|
|
40
|
-
- **Agent Autonomy**: Clear commands agents can execute
|
|
41
|
-
- **Learning Capture**: Document lessons learned for future optimizations
|
|
42
|
-
|
|
43
|
-
## VALUE PROPOSITION
|
|
44
|
-
|
|
45
|
-
- Systematic 5-phase workflow (Auth → Gather → Identify → Prioritize → Execute)
|
|
46
|
-
- Real-world tested: Successfully reduced costs by 65% ($344 → $119/month)
|
|
47
|
-
- Agent-friendly with clear commands, error handling, and decision trees
|
|
48
|
-
- Maintains production reliability while optimizing costs
|
|
49
|
-
|
|
50
|
-
## WORKFLOW ACTIVATION
|
|
51
|
-
|
|
52
|
-
When you need to optimize Azure cloud costs, START here:
|
|
53
|
-
|
|
54
|
-
```javascript
|
|
55
|
-
seekMentoring({
|
|
56
|
-
workflowType: "cost-optimization",
|
|
57
|
-
issueNumber: "{issue_number}",
|
|
58
|
-
currentPhase: "verify-auth",
|
|
59
|
-
status: "starting"
|
|
60
|
-
})
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
---
|
|
64
|
-
|
|
65
|
-
## Phase: verify-auth
|
|
66
|
-
|
|
67
|
-
### INTENT
|
|
68
|
-
Verify Azure CLI is installed and user is authenticated before proceeding.
|
|
69
|
-
|
|
70
|
-
### CRITICAL CONSTRAINT
|
|
71
|
-
**Agents CANNOT authenticate interactively**. User must run `az login` manually.
|
|
72
|
-
|
|
73
|
-
### STEPS
|
|
74
|
-
|
|
75
|
-
1. **Check Azure CLI Installation**
|
|
76
|
-
```bash
|
|
77
|
-
az --version
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
If not installed, instruct user to install:
|
|
81
|
-
- Windows: `winget install Microsoft.AzureCLI`
|
|
82
|
-
- Mac: `brew install azure-cli`
|
|
83
|
-
- Linux: See https://docs.microsoft.com/en-us/cli/azure/install-azure-cli
|
|
84
|
-
|
|
85
|
-
2. **Verify Authentication**
|
|
86
|
-
```bash
|
|
87
|
-
az account show
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
**If authentication fails**:
|
|
91
|
-
- Tell user: "Please run `az login` in your terminal and follow the browser authentication flow"
|
|
92
|
-
- Wait for user confirmation
|
|
93
|
-
- Retry `az account show`
|
|
94
|
-
|
|
95
|
-
3. **Capture Subscription Info**
|
|
96
|
-
```bash
|
|
97
|
-
az account show --query "{SubscriptionId:id, Name:name, TenantId:tenantId}" -o json
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
Store subscription ID for cost queries.
|
|
101
|
-
|
|
102
|
-
### SUCCESS CRITERIA
|
|
103
|
-
- Azure CLI installed and accessible
|
|
104
|
-
- User authenticated (can run `az account show` successfully)
|
|
105
|
-
- Subscription ID captured
|
|
106
|
-
|
|
107
|
-
### REPORT BACK
|
|
108
|
-
```javascript
|
|
109
|
-
seekMentoring({
|
|
110
|
-
workflowType: "cost-optimization",
|
|
111
|
-
issueNumber: "{issue_number}",
|
|
112
|
-
currentPhase: "verify-auth",
|
|
113
|
-
status: "complete",
|
|
114
|
-
findings: {
|
|
115
|
-
subscriptionId: "...",
|
|
116
|
-
subscriptionName: "...",
|
|
117
|
-
tenantId: "..."
|
|
118
|
-
}
|
|
119
|
-
})
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
---
|
|
123
|
-
|
|
124
|
-
## Phase: gather-data
|
|
125
|
-
|
|
126
|
-
### INTENT
|
|
127
|
-
Collect comprehensive cost data across multiple dimensions to identify patterns.
|
|
128
|
-
|
|
129
|
-
### STEPS
|
|
130
|
-
|
|
131
|
-
1. **Set Time Range**
|
|
132
|
-
```bash
|
|
133
|
-
# Last 30 days
|
|
134
|
-
START_DATE=$(date -u -d '30 days ago' '+%Y-%m-%dT00:00:00Z')
|
|
135
|
-
END_DATE=$(date -u '+%Y-%m-%dT23:59:59Z')
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
2. **Query Costs by Resource Group**
|
|
139
|
-
```bash
|
|
140
|
-
az rest --method post \
|
|
141
|
-
--url "https://management.azure.com/subscriptions/{SUBSCRIPTION_ID}/providers/Microsoft.CostManagement/query?api-version=2023-03-01" \
|
|
142
|
-
--body '{
|
|
143
|
-
"type": "ActualCost",
|
|
144
|
-
"timeframe": "Custom",
|
|
145
|
-
"timePeriod": {
|
|
146
|
-
"from": "'$START_DATE'",
|
|
147
|
-
"to": "'$END_DATE'"
|
|
148
|
-
},
|
|
149
|
-
"dataset": {
|
|
150
|
-
"granularity": "None",
|
|
151
|
-
"aggregation": {
|
|
152
|
-
"totalCost": {
|
|
153
|
-
"name": "Cost",
|
|
154
|
-
"function": "Sum"
|
|
155
|
-
}
|
|
156
|
-
},
|
|
157
|
-
"grouping": [
|
|
158
|
-
{
|
|
159
|
-
"type": "Dimension",
|
|
160
|
-
"name": "ResourceGroupName"
|
|
161
|
-
}
|
|
162
|
-
]
|
|
163
|
-
}
|
|
164
|
-
}'
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
3. **Query Costs by Service Type**
|
|
168
|
-
```bash
|
|
169
|
-
# Same query but group by "ServiceName" instead of "ResourceGroupName"
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
4. **Query Costs by Resource Type & Location**
|
|
173
|
-
```bash
|
|
174
|
-
# Same query but group by "ResourceType" and "ResourceLocation"
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
5. **Calculate Daily Averages**
|
|
178
|
-
- Total cost / 30 days = daily average
|
|
179
|
-
- Daily average × 30 = monthly projection
|
|
180
|
-
|
|
181
|
-
### SUCCESS CRITERIA
|
|
182
|
-
- Cost data collected for all resource groups
|
|
183
|
-
- Cost data collected by service type
|
|
184
|
-
- Cost data collected by location
|
|
185
|
-
- Daily averages and monthly projections calculated
|
|
186
|
-
|
|
187
|
-
### REPORT BACK
|
|
188
|
-
```javascript
|
|
189
|
-
seekMentoring({
|
|
190
|
-
workflowType: "cost-optimization",
|
|
191
|
-
issueNumber: "{issue_number}",
|
|
192
|
-
currentPhase: "gather-data",
|
|
193
|
-
status: "complete",
|
|
194
|
-
findings: {
|
|
195
|
-
totalMonthlyCost: 344.00,
|
|
196
|
-
costByResourceGroup: {...},
|
|
197
|
-
costByService: {...},
|
|
198
|
-
costByLocation: {...},
|
|
199
|
-
topCostDrivers: [
|
|
200
|
-
{ service: "App Service", cost: 220, percentage: 64 },
|
|
201
|
-
{ service: "Cosmos DB", cost: 80, percentage: 23 }
|
|
202
|
-
]
|
|
203
|
-
}
|
|
204
|
-
})
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
---
|
|
208
|
-
|
|
209
|
-
## Phase: identify-opportunities
|
|
210
|
-
|
|
211
|
-
### INTENT
|
|
212
|
-
Analyze cost data and resource configurations to find optimization opportunities.
|
|
213
|
-
|
|
214
|
-
### STEPS
|
|
215
|
-
|
|
216
|
-
1. **Inspect High-Cost Resources**
|
|
217
|
-
|
|
218
|
-
For each top cost driver:
|
|
219
|
-
|
|
220
|
-
```bash
|
|
221
|
-
# List resources in resource group
|
|
222
|
-
az resource list --resource-group {RG} \
|
|
223
|
-
--query "[].{Name:name, Type:type, SKU:sku.name}" -o table
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
2. **Analyze App Service Plans**
|
|
227
|
-
|
|
228
|
-
```bash
|
|
229
|
-
az appservice plan show --name {PLAN_NAME} --resource-group {RG} \
|
|
230
|
-
--query "{Name:name, SKU:sku.name, Tier:sku.tier, Capacity:sku.capacity, \
|
|
231
|
-
Features:properties.reserved, VNet:properties.isXenon, \
|
|
232
|
-
Slots:properties.maximumNumberOfWorkers}" -o json
|
|
233
|
-
```
|
|
234
|
-
|
|
235
|
-
**Optimization Opportunities**:
|
|
236
|
-
- Premium (P0v3) → Basic (B2) for low traffic (<1000 req/day)
|
|
237
|
-
- Check if using premium features (VNet, staging slots, auto-scale)
|
|
238
|
-
- Tier comparison:
|
|
239
|
-
| Tier | vCPU | RAM | Cost/Month | Features |
|
|
240
|
-
|------|------|-----|------------|----------|
|
|
241
|
-
| P0v3 | 1 | 4GB | $220 | VNet, slots, auto-scale |
|
|
242
|
-
| B2 | 2 | 3.5GB | $55 | Basic features only |
|
|
243
|
-
| B1 | 1 | 1.75GB | $13 | Minimal features |
|
|
244
|
-
|
|
245
|
-
3. **Analyze Cosmos DB**
|
|
246
|
-
|
|
247
|
-
```bash
|
|
248
|
-
az cosmosdb show --name {DB_NAME} --resource-group {RG} \
|
|
249
|
-
--query "{Name:name, Kind:kind, Tier:properties.databaseAccountOfferType, \
|
|
250
|
-
Capabilities:capabilities}" -o json
|
|
251
|
-
```
|
|
252
|
-
|
|
253
|
-
**Optimization Opportunities**:
|
|
254
|
-
- Check if eligible for free tier (RU-based only, not vCore)
|
|
255
|
-
- Review connection pooling in code
|
|
256
|
-
- Check for singleton patterns
|
|
257
|
-
|
|
258
|
-
4. **Analyze Key Vault Usage**
|
|
259
|
-
|
|
260
|
-
```bash
|
|
261
|
-
az keyvault show --name {KV_NAME} \
|
|
262
|
-
--query "{Name:name, SKU:properties.sku.name, Location:location}" -o json
|
|
263
|
-
```
|
|
264
|
-
|
|
265
|
-
**Code Pattern Analysis**:
|
|
266
|
-
- Search codebase for Key Vault operations
|
|
267
|
-
- Check if secrets are cached (should be!)
|
|
268
|
-
- Review cache TTL (can it be extended?)
|
|
269
|
-
- Calculate operations per month
|
|
270
|
-
|
|
271
|
-
5. **Analyze Storage Accounts**
|
|
272
|
-
|
|
273
|
-
```bash
|
|
274
|
-
az storage account show --name {STORAGE_NAME} --resource-group {RG} \
|
|
275
|
-
--query "{Name:name, SKU:sku.name, Tier:accessTier, Kind:kind}" -o json
|
|
276
|
-
```
|
|
277
|
-
|
|
278
|
-
**Optimization Opportunities**:
|
|
279
|
-
- Hot → Cool for infrequently accessed data
|
|
280
|
-
- Implement lifecycle management policies
|
|
281
|
-
|
|
282
|
-
### SUCCESS CRITERIA
|
|
283
|
-
- All high-cost resources inspected
|
|
284
|
-
- Optimization opportunities identified with estimated savings
|
|
285
|
-
- Risk level assessed for each opportunity
|
|
286
|
-
- Code patterns analyzed where relevant
|
|
287
|
-
|
|
288
|
-
### REPORT BACK
|
|
289
|
-
```javascript
|
|
290
|
-
seekMentoring({
|
|
291
|
-
workflowType: "cost-optimization",
|
|
292
|
-
issueNumber: "{issue_number}",
|
|
293
|
-
currentPhase: "identify-opportunities",
|
|
294
|
-
status: "complete",
|
|
295
|
-
findings: {
|
|
296
|
-
opportunities: [
|
|
297
|
-
{
|
|
298
|
-
resource: "App Service Plan (ashley-cal-plan)",
|
|
299
|
-
current: "P0v3 ($220/month)",
|
|
300
|
-
proposed: "B2 ($55/month)",
|
|
301
|
-
savings: 165,
|
|
302
|
-
risk: "Medium",
|
|
303
|
-
reasoning: "Low traffic, not using premium features"
|
|
304
|
-
},
|
|
305
|
-
{
|
|
306
|
-
resource: "Key Vault token cache",
|
|
307
|
-
current: "5min TTL",
|
|
308
|
-
proposed: "30min TTL",
|
|
309
|
-
savings: 5,
|
|
310
|
-
risk: "Low",
|
|
311
|
-
reasoning: "OAuth tokens valid 1 hour, safe to extend"
|
|
312
|
-
}
|
|
313
|
-
],
|
|
314
|
-
codeQualityFindings: {
|
|
315
|
-
connectionPooling: "✅ Already optimized",
|
|
316
|
-
caching: "✅ Proper singleton patterns",
|
|
317
|
-
cacheHitRate: "98%"
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
})
|
|
321
|
-
```
|
|
322
|
-
|
|
323
|
-
---
|
|
324
|
-
|
|
325
|
-
## Phase: prioritize-actions
|
|
326
|
-
|
|
327
|
-
### INTENT
|
|
328
|
-
Rank optimization opportunities by savings potential vs risk.
|
|
329
|
-
|
|
330
|
-
### PRIORITIZATION FORMULA
|
|
331
|
-
|
|
332
|
-
```
|
|
333
|
-
Priority Score = (Monthly Savings × 10) - (Risk Level × 3)
|
|
334
|
-
|
|
335
|
-
Risk Levels:
|
|
336
|
-
- Low: 1 (config changes, cache TTL)
|
|
337
|
-
- Medium: 2 (tier downgrades with feature verification)
|
|
338
|
-
- High: 3 (architectural changes, data migration)
|
|
339
|
-
```
|
|
340
|
-
|
|
341
|
-
### STEPS
|
|
342
|
-
|
|
343
|
-
1. **Calculate Priority Scores**
|
|
344
|
-
|
|
345
|
-
For each opportunity:
|
|
346
|
-
- Estimate monthly savings
|
|
347
|
-
- Assess risk level
|
|
348
|
-
- Calculate priority score
|
|
349
|
-
- Add notes on what could break
|
|
350
|
-
|
|
351
|
-
2. **Sort by Priority**
|
|
352
|
-
|
|
353
|
-
Highest score = highest priority
|
|
354
|
-
|
|
355
|
-
3. **Group by Environment**
|
|
356
|
-
|
|
357
|
-
- Start with non-production (dev, staging)
|
|
358
|
-
- Then production (with extra caution)
|
|
359
|
-
|
|
360
|
-
4. **Create Implementation Plan**
|
|
361
|
-
|
|
362
|
-
For each opportunity:
|
|
363
|
-
- Exact commands to execute
|
|
364
|
-
- Verification steps
|
|
365
|
-
- Rollback plan
|
|
366
|
-
- User approval required: YES/NO
|
|
367
|
-
|
|
368
|
-
### SUCCESS CRITERIA
|
|
369
|
-
- All opportunities ranked by priority
|
|
370
|
-
- Implementation plan created
|
|
371
|
-
- Rollback plans documented
|
|
372
|
-
- User approval checkpoints identified
|
|
373
|
-
|
|
374
|
-
### REPORT BACK
|
|
375
|
-
```javascript
|
|
376
|
-
seekMentoring({
|
|
377
|
-
workflowType: "cost-optimization",
|
|
378
|
-
issueNumber: "{issue_number}",
|
|
379
|
-
currentPhase: "prioritize-actions",
|
|
380
|
-
status: "complete",
|
|
381
|
-
findings: {
|
|
382
|
-
prioritizedActions: [
|
|
383
|
-
{
|
|
384
|
-
priority: 1,
|
|
385
|
-
score: 1644,
|
|
386
|
-
action: "Downgrade App Service Plan P0v3 → B2",
|
|
387
|
-
savings: 165,
|
|
388
|
-
risk: "Medium",
|
|
389
|
-
requiresApproval: true,
|
|
390
|
-
commands: ["az appservice plan update..."],
|
|
391
|
-
rollback: ["az appservice plan update... --sku P0v3"]
|
|
392
|
-
},
|
|
393
|
-
{
|
|
394
|
-
priority: 2,
|
|
395
|
-
score: 47,
|
|
396
|
-
action: "Extend Key Vault cache TTL 5min → 30min",
|
|
397
|
-
savings: 5,
|
|
398
|
-
risk: "Low",
|
|
399
|
-
requiresApproval: true,
|
|
400
|
-
commands: ["Update config file..."],
|
|
401
|
-
rollback: ["Revert config file..."]
|
|
402
|
-
}
|
|
403
|
-
]
|
|
404
|
-
}
|
|
405
|
-
})
|
|
406
|
-
```
|
|
407
|
-
|
|
408
|
-
---
|
|
409
|
-
|
|
410
|
-
## Phase: execute-changes
|
|
411
|
-
|
|
412
|
-
### INTENT
|
|
413
|
-
Safely implement approved optimizations with full documentation.
|
|
414
|
-
|
|
415
|
-
### CRITICAL RULES
|
|
416
|
-
|
|
417
|
-
1. **User Approval Required**: Get explicit YES before each change
|
|
418
|
-
2. **Document Everything**: Log all commands, outputs, timestamps
|
|
419
|
-
3. **Verify After Each Change**: Confirm resource still works
|
|
420
|
-
4. **One Change at a Time**: Don't batch changes
|
|
421
|
-
5. **Create Documentation File**: `docs/azure-cloud/cost-optimization-{DATE}.md`
|
|
422
|
-
|
|
423
|
-
### DOCUMENTATION TEMPLATE
|
|
424
|
-
|
|
425
|
-
```markdown
|
|
426
|
-
# Azure Cost Optimization - {DATE}
|
|
427
|
-
|
|
428
|
-
## Summary
|
|
429
|
-
- **Initial Cost**: ${BEFORE}/month
|
|
430
|
-
- **Target Cost**: ${AFTER}/month
|
|
431
|
-
- **Expected Savings**: ${SAVINGS}/month ({PERCENTAGE}% reduction)
|
|
432
|
-
|
|
433
|
-
## Changes Implemented
|
|
434
|
-
|
|
435
|
-
### Change 1: {DESCRIPTION}
|
|
436
|
-
- **Timestamp**: {ISO_TIMESTAMP}
|
|
437
|
-
- **User Approval**: YES (timestamp)
|
|
438
|
-
- **Command**:
|
|
439
|
-
\`\`\`bash
|
|
440
|
-
{EXACT_COMMAND}
|
|
441
|
-
\`\`\`
|
|
442
|
-
- **Output**:
|
|
443
|
-
\`\`\`
|
|
444
|
-
{COMMAND_OUTPUT}
|
|
445
|
-
\`\`\`
|
|
446
|
-
- **Verification**:
|
|
447
|
-
- [ ] Resource accessible
|
|
448
|
-
- [ ] Application functional
|
|
449
|
-
- [ ] No errors in logs
|
|
450
|
-
- **Actual Savings**: ${AMOUNT}/month
|
|
451
|
-
|
|
452
|
-
### Change 2: ...
|
|
453
|
-
|
|
454
|
-
## Lessons Learned
|
|
455
|
-
1. {LESSON_1}
|
|
456
|
-
2. {LESSON_2}
|
|
457
|
-
|
|
458
|
-
## Final Results
|
|
459
|
-
- **Actual Cost**: ${FINAL}/month
|
|
460
|
-
- **Actual Savings**: ${TOTAL_SAVINGS}/month ({PERCENTAGE}% reduction)
|
|
461
|
-
```
|
|
462
|
-
|
|
463
|
-
### STEPS FOR EACH CHANGE
|
|
464
|
-
|
|
465
|
-
1. **Present Change to User**
|
|
466
|
-
```
|
|
467
|
-
I'm ready to implement:
|
|
468
|
-
|
|
469
|
-
Change: Downgrade App Service Plan from P0v3 to B2
|
|
470
|
-
Expected Savings: $165/month
|
|
471
|
-
Risk: Medium (will lose VNet integration, staging slots)
|
|
472
|
-
|
|
473
|
-
Command to execute:
|
|
474
|
-
az appservice plan update --name ashley-cal-plan \
|
|
475
|
-
--resource-group ashley-cal-rg --sku B2
|
|
476
|
-
|
|
477
|
-
Rollback command (if needed):
|
|
478
|
-
az appservice plan update --name ashley-cal-plan \
|
|
479
|
-
--resource-group ashley-cal-rg --sku P0v3
|
|
480
|
-
|
|
481
|
-
Do you approve this change? (YES/NO)
|
|
482
|
-
```
|
|
483
|
-
|
|
484
|
-
2. **Wait for Explicit YES**
|
|
485
|
-
|
|
486
|
-
- If NO: Skip this change, move to next
|
|
487
|
-
- If YES: Proceed to execution
|
|
488
|
-
|
|
489
|
-
3. **Execute Command**
|
|
490
|
-
```bash
|
|
491
|
-
az appservice plan update --name {PLAN} --resource-group {RG} --sku B2
|
|
492
|
-
```
|
|
493
|
-
|
|
494
|
-
Capture full output.
|
|
495
|
-
|
|
496
|
-
4. **Verify Change**
|
|
497
|
-
```bash
|
|
498
|
-
# Verify resource updated
|
|
499
|
-
az appservice plan show --name {PLAN} --resource-group {RG} \
|
|
500
|
-
--query "{Name:name, SKU:sku.name, State:properties.status}" -o json
|
|
501
|
-
|
|
502
|
-
# Test application endpoint
|
|
503
|
-
curl -I https://{APP_URL}
|
|
504
|
-
|
|
505
|
-
# Check for errors
|
|
506
|
-
az webapp log tail --name {APP} --resource-group {RG}
|
|
507
|
-
```
|
|
508
|
-
|
|
509
|
-
5. **Document in File**
|
|
510
|
-
|
|
511
|
-
Add to `docs/azure-cloud/cost-optimization-{DATE}.md`
|
|
512
|
-
|
|
513
|
-
6. **Calculate Actual Savings**
|
|
514
|
-
|
|
515
|
-
Wait 24 hours, then query costs again to confirm savings.
|
|
516
|
-
|
|
517
|
-
### SUCCESS CRITERIA
|
|
518
|
-
- All approved changes executed successfully
|
|
519
|
-
- All changes verified and working
|
|
520
|
-
- Complete documentation file created
|
|
521
|
-
- Actual savings calculated and documented
|
|
522
|
-
- Lessons learned captured
|
|
523
|
-
|
|
524
|
-
### REPORT BACK
|
|
525
|
-
```javascript
|
|
526
|
-
seekMentoring({
|
|
527
|
-
workflowType: "cost-optimization",
|
|
528
|
-
issueNumber: "{issue_number}",
|
|
529
|
-
currentPhase: "execute-changes",
|
|
530
|
-
status: "complete",
|
|
531
|
-
findings: {
|
|
532
|
-
changesAttempted: 3,
|
|
533
|
-
changesSuccessful: 2,
|
|
534
|
-
changesFailed: 1,
|
|
535
|
-
changes: [
|
|
536
|
-
{
|
|
537
|
-
description: "App Service Plan P0v3 → B2",
|
|
538
|
-
status: "SUCCESS",
|
|
539
|
-
savings: 165,
|
|
540
|
-
timestamp: "2026-02-05T10:30:00Z"
|
|
541
|
-
},
|
|
542
|
-
{
|
|
543
|
-
description: "Key Vault cache TTL 5min → 30min",
|
|
544
|
-
status: "SUCCESS",
|
|
545
|
-
savings: 5,
|
|
546
|
-
timestamp: "2026-02-05T10:45:00Z"
|
|
547
|
-
},
|
|
548
|
-
{
|
|
549
|
-
description: "Cosmos DB free tier",
|
|
550
|
-
status: "FAILED",
|
|
551
|
-
reason: "vCore MongoDB not eligible for free tier",
|
|
552
|
-
timestamp: "2026-02-05T11:00:00Z"
|
|
553
|
-
}
|
|
554
|
-
],
|
|
555
|
-
totalSavings: 170,
|
|
556
|
-
documentationFile: "docs/azure-cloud/cost-optimization-2026-02-05.md",
|
|
557
|
-
lessonsLearned: [
|
|
558
|
-
"vCore Cosmos DB not eligible for free tier (RU-based only)",
|
|
559
|
-
"Cache extension is safe for OAuth tokens",
|
|
560
|
-
"Always verify resource types before optimization"
|
|
561
|
-
]
|
|
562
|
-
}
|
|
563
|
-
})
|
|
564
|
-
```
|
|
565
|
-
|
|
566
|
-
---
|
|
567
|
-
|
|
568
|
-
## COMMON COST DRIVERS & OPTIMIZATIONS
|
|
569
|
-
|
|
570
|
-
### App Service Plans
|
|
571
|
-
|
|
572
|
-
**Cost Drivers**:
|
|
573
|
-
- Premium tiers (P0v3, P1v3, P2v3): $220-$880/month
|
|
574
|
-
- Often over-provisioned for actual traffic
|
|
575
|
-
|
|
576
|
-
**Optimization Strategies**:
|
|
577
|
-
1. **Analyze Traffic**:
|
|
578
|
-
```bash
|
|
579
|
-
az monitor metrics list --resource {RESOURCE_ID} \
|
|
580
|
-
--metric "Requests" --start-time {START} --end-time {END}
|
|
581
|
-
```
|
|
582
|
-
|
|
583
|
-
2. **Check Feature Usage**:
|
|
584
|
-
- VNet integration: Required?
|
|
585
|
-
- Staging slots: Used?
|
|
586
|
-
- Auto-scale: Needed?
|
|
587
|
-
|
|
588
|
-
3. **Tier Comparison**:
|
|
589
|
-
| Tier | vCPU | RAM | Cost | Use Case |
|
|
590
|
-
|------|------|-----|------|----------|
|
|
591
|
-
| P0v3 | 1 | 4GB | $220 | Production with premium features |
|
|
592
|
-
| B2 | 2 | 3.5GB | $55 | Low-traffic production |
|
|
593
|
-
| B1 | 1 | 1.75GB | $13 | Development/staging |
|
|
594
|
-
|
|
595
|
-
4. **Downgrade Command**:
|
|
596
|
-
```bash
|
|
597
|
-
az appservice plan update --name {PLAN} --resource-group {RG} --sku B2
|
|
598
|
-
```
|
|
599
|
-
|
|
600
|
-
### Cosmos DB
|
|
601
|
-
|
|
602
|
-
**Cost Drivers**:
|
|
603
|
-
- vCore-based: $80-$200/month minimum
|
|
604
|
-
- RU-based: $24/month minimum (or free tier)
|
|
605
|
-
|
|
606
|
-
**Optimization Strategies**:
|
|
607
|
-
1. **Check Eligibility for Free Tier**:
|
|
608
|
-
- Only RU-based Cosmos DB
|
|
609
|
-
- Not vCore MongoDB
|
|
610
|
-
- One per subscription
|
|
611
|
-
|
|
612
|
-
2. **Verify Connection Pooling**:
|
|
613
|
-
```javascript
|
|
614
|
-
// Good: Singleton with connection pooling
|
|
615
|
-
const client = new MongoClient(uri, { maxPoolSize: 10 });
|
|
616
|
-
|
|
617
|
-
// Bad: New connection per request
|
|
618
|
-
app.get('/', async (req, res) => {
|
|
619
|
-
const client = new MongoClient(uri); // ❌ Don't do this
|
|
620
|
-
});
|
|
621
|
-
```
|
|
622
|
-
|
|
623
|
-
3. **Check for Proper Singleton**:
|
|
624
|
-
```javascript
|
|
625
|
-
// Good: Module-level singleton
|
|
626
|
-
let dbInstance = null;
|
|
627
|
-
export async function getDb() {
|
|
628
|
-
if (!dbInstance) {
|
|
629
|
-
dbInstance = await client.db();
|
|
630
|
-
}
|
|
631
|
-
return dbInstance;
|
|
632
|
-
}
|
|
633
|
-
```
|
|
634
|
-
|
|
635
|
-
### Key Vault
|
|
636
|
-
|
|
637
|
-
**Cost Drivers**:
|
|
638
|
-
- Operations: $0.03 per 10,000 operations
|
|
639
|
-
- Can add up with frequent secret retrieval
|
|
640
|
-
|
|
641
|
-
**Optimization Strategies**:
|
|
642
|
-
1. **Analyze Operation Count**:
|
|
643
|
-
```bash
|
|
644
|
-
az monitor metrics list --resource {KV_RESOURCE_ID} \
|
|
645
|
-
--metric "ServiceApiHit" --aggregation Total
|
|
646
|
-
```
|
|
647
|
-
|
|
648
|
-
2. **Check for Caching**:
|
|
649
|
-
```javascript
|
|
650
|
-
// Good: Cache secrets with TTL
|
|
651
|
-
const cache = new Map();
|
|
652
|
-
async function getSecret(name) {
|
|
653
|
-
if (cache.has(name) && !isExpired(cache.get(name))) {
|
|
654
|
-
return cache.get(name).value;
|
|
655
|
-
}
|
|
656
|
-
const secret = await keyVaultClient.getSecret(name);
|
|
657
|
-
cache.set(name, { value: secret, expires: Date.now() + TTL });
|
|
658
|
-
return secret;
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
// Bad: Fetch every time
|
|
662
|
-
async function getSecret(name) {
|
|
663
|
-
return await keyVaultClient.getSecret(name); // ❌ No caching
|
|
664
|
-
}
|
|
665
|
-
```
|
|
666
|
-
|
|
667
|
-
3. **Extend Cache TTL**:
|
|
668
|
-
- OAuth tokens: Valid 1 hour → 30min cache is safe
|
|
669
|
-
- Connection strings: Rarely change → 1 hour cache is safe
|
|
670
|
-
- API keys: Rarely change → 1 hour cache is safe
|
|
671
|
-
|
|
672
|
-
### Storage Accounts
|
|
673
|
-
|
|
674
|
-
**Cost Drivers**:
|
|
675
|
-
- Hot tier: $0.0184/GB/month
|
|
676
|
-
- Cool tier: $0.01/GB/month
|
|
677
|
-
- Archive tier: $0.00099/GB/month
|
|
678
|
-
|
|
679
|
-
**Optimization Strategies**:
|
|
680
|
-
1. **Analyze Access Patterns**:
|
|
681
|
-
```bash
|
|
682
|
-
az storage blob list --account-name {ACCOUNT} --container-name {CONTAINER} \
|
|
683
|
-
--query "[].{Name:name, LastModified:properties.lastModified, \
|
|
684
|
-
AccessTier:properties.blobTier}" -o table
|
|
685
|
-
```
|
|
686
|
-
|
|
687
|
-
2. **Implement Lifecycle Policies**:
|
|
688
|
-
```json
|
|
689
|
-
{
|
|
690
|
-
"rules": [
|
|
691
|
-
{
|
|
692
|
-
"name": "move-to-cool",
|
|
693
|
-
"type": "Lifecycle",
|
|
694
|
-
"definition": {
|
|
695
|
-
"actions": {
|
|
696
|
-
"baseBlob": {
|
|
697
|
-
"tierToCool": {
|
|
698
|
-
"daysAfterModificationGreaterThan": 30
|
|
699
|
-
}
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
}
|
|
703
|
-
}
|
|
704
|
-
]
|
|
705
|
-
}
|
|
706
|
-
```
|
|
707
|
-
|
|
708
|
-
---
|
|
709
|
-
|
|
710
|
-
## REAL-WORLD EXAMPLE
|
|
711
|
-
|
|
712
|
-
### Ashley Calendar AI Project
|
|
713
|
-
|
|
714
|
-
**Initial State**:
|
|
715
|
-
- Monthly Cost: $344
|
|
716
|
-
- App Service Plan: P0v3 ($220/month)
|
|
717
|
-
- Cosmos DB: vCore MongoDB ($80/month)
|
|
718
|
-
- Key Vault: ~10,000 operations/day ($3-5/month)
|
|
719
|
-
- Storage: Minimal
|
|
720
|
-
|
|
721
|
-
**Optimizations Implemented**:
|
|
722
|
-
|
|
723
|
-
1. **App Service Plan: P0v3 → B2**
|
|
724
|
-
- Savings: $165/month
|
|
725
|
-
- Risk: Medium
|
|
726
|
-
- Verification: Traffic <1000 req/day, no premium features used
|
|
727
|
-
- Result: ✅ SUCCESS
|
|
728
|
-
|
|
729
|
-
2. **Key Vault Cache: 5min → 30min TTL**
|
|
730
|
-
- Savings: $3-5/month
|
|
731
|
-
- Risk: Low
|
|
732
|
-
- Verification: OAuth tokens valid 1 hour
|
|
733
|
-
- Result: ✅ SUCCESS
|
|
734
|
-
|
|
735
|
-
3. **Cosmos DB Free Tier**
|
|
736
|
-
- Savings: $80/month (attempted)
|
|
737
|
-
- Risk: Low
|
|
738
|
-
- Result: ❌ FAILED (vCore not eligible)
|
|
739
|
-
|
|
740
|
-
**Final Results**:
|
|
741
|
-
- New Monthly Cost: $119
|
|
742
|
-
- Actual Savings: $225/month (65% reduction)
|
|
743
|
-
- Code Quality: Already optimized (connection pooling, caching, circuit breakers)
|
|
744
|
-
|
|
745
|
-
**Lessons Learned**:
|
|
746
|
-
1. vCore Cosmos DB not eligible for free tier (RU-based only)
|
|
747
|
-
2. Cache extension is safe for OAuth tokens
|
|
748
|
-
3. Code-level optimizations sometimes more effective than infrastructure
|
|
749
|
-
4. Always verify resource types before optimization
|
|
750
|
-
|
|
751
|
-
---
|
|
752
|
-
|
|
753
|
-
## SUCCESS CRITERIA
|
|
754
|
-
|
|
755
|
-
- [ ] Azure CLI authenticated
|
|
756
|
-
- [ ] Cost data gathered across all dimensions
|
|
757
|
-
- [ ] Optimization opportunities identified with savings estimates
|
|
758
|
-
- [ ] Actions prioritized by savings vs risk
|
|
759
|
-
- [ ] User approval obtained for each change
|
|
760
|
-
- [ ] Changes executed and verified
|
|
761
|
-
- [ ] Complete documentation file created
|
|
762
|
-
- [ ] Actual savings calculated and confirmed
|
|
763
|
-
- [ ] Lessons learned captured
|
|
764
|
-
|
|
765
|
-
## NOTES
|
|
766
|
-
|
|
767
|
-
- **Agent Limitation**: Cannot authenticate interactively - user must run `az login`
|
|
768
|
-
- **Safety First**: Always get explicit user approval before changes
|
|
769
|
-
- **Documentation**: Full audit trail enables learning and rollback
|
|
770
|
-
- **Verification**: Test after each change to catch issues early
|
|
771
|
-
- **Learning**: Capture lessons learned for future optimizations
|
|
772
|
-
- **Real-World Tested**: Successfully reduced costs by 65% in production
|