Add quota and capacity pre-flight checks before ARM deployment
- Dominant language
- Go
- Stars
- 569
- Forks
- 364
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 136
Description
## Problem
Quota and capacity errors account for ~3,605 errors (2.82%) over 90 days. Users deploy templates, wait for provisioning, then fail with `InsufficientQuota`, `SkuNotAvailable`, or `LocationIsOfferRestricted`. These failures are predictable and could be caught before deployment begins.
## Current Behavior
azd has excellent quota pre-checks for AI model deployments in `pkg/ai/model_service.go` (`ResolveModelDeploymentsWithQuota()`, `ListLocationsWithQuota()`, `FilterModelsByQuota()`). However, standard ARM provisioning in `pkg/infra/provisioning/bicep/bicep_provider.go` has no quota pre-checks.
azd already runs ARM preflight validation (`ValidatePreflightToResourceGroup()`) and what-if preview before deployment, but these do not check subscription quota.
## Proposed Solution
1. After the what-if preview step, parse the output to identify resource types being created (VMs, Cognitive Services, OpenAI, etc.)
2. For high-quota-failure resource types, query the ARM quota/usage APIs:
- `Microsoft.Compute/locations/{location}/usages` for VM SKUs
- `Microsoft.CognitiveServices` quota endpoints for AI resources
3. Compare required capacity against remaining quota
4. If quota is insufficient, warn the user before deploying:
- `Warning: Your subscription has N of M vCPUs remaining in . This deployment requires K vCPUs. Consider changing region with 'azd env set AZURE_LOCATION ' or requesting a quota increase.`
5. Consider the AI model quota system in `pkg/ai/model_service.go` as an architectural reference for this feature
## Data Reference
Source: AzdProvisionErrorsByTemplate + AzdDeploymentErrorsByTemplate (DevCli on ddazureclients)
- Quota / Capacity errors: 3,605 (2.82%)
- AI templates: 3.12%, Awesome-azd: 2.26%
- Key ARM codes: `InsufficientQuota`, `SubscriptionIsOverQuotaForSku`, `SkuNotAvailable`, `LocationIsOfferRestricted`, `DeploymentModelNotSupported`
Contributor guide
Assessment
This issue has not been assessed yet.