[Feature Request] Add global argument `--api-version` to support choosing API version
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 3.5k
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 60
Description
**Is your feature request related to a problem? Please describe.**
Azure CLI uses `latest` profile for public and sovereign clouds.
https://github.com/Azure/azure-cli/blob/fccca99adfd7526bd232ade37c3621bded3c7118/src/azure-cli-core/azure/cli/core/profiles/_shared.py#L155-L158
This approach has some problems:
- Sometimes there are breaking changes between the latest API version and a previous one. If a user updates Azure CLI (which updates API versions), but doesn't want to migrate to the latest API version immediately, error may occur due to these breaking changes.
- Sometimes a latest API version available in `AzureCloud` may not be available in sovereign clouds (https://github.com/Azure/azure-cli/issues/23985). If a user updates Azure CLI (which updates API versions), error may occur in sovereign clouds.
**Describe the solution you'd like**
Add global argument `--api-version` to each command to support choosing API version.
**Additional context**
Technical difficulties:
- Azure SDKs bundled in Azure CLI packages are now trimmed to reduce package size. Only declared API versions are preserved (#23946). If we allow each command to use a random API version, all versions in Python SDKs must be kept, which will revert Azure CLI package to its original huge size.
- Azure CLI code is only written to be compatible with certain API versions. If we allow each command to use a random API version, Azure CLI code must be compatible with all API versions. For example, for `azure-mgmt-network`, there are currently 51 API versions: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/network/resource-manager/Microsoft.Network. Supporting all of them requires huge amount of work.
- If a command involves multiple Resource Providers, there is no way to specify each of them with only one `--api-version` argument.
Contributor guide
Assessment
This issue has not been assessed yet.