Azure / Azure/azure-cli

[Feature Request] Add global argument `--api-version` to support choosing API version

Open
#26,397 1 comment 3 reactions 1 assignee Claimed by @jiasli View on GitHub
act-platform-engineering-squad Azure CLI Team Core feature-request
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.