Skip to content

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

@jiasli

Description

@jiasli

Is your feature request related to a problem? Please describe.

Azure CLI uses latest profile for public and sovereign clouds.

'latest': {
ResourceType.MGMT_STORAGE: '2022-09-01',
ResourceType.MGMT_NETWORK: '2022-01-01',
ResourceType.MGMT_COMPUTE: SDKProfile('2022-11-01', {

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 (Latest API version not available in sovereign clouds #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 ({Packaging} Trim mgmt SDKs #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.

Metadata

Metadata

Assignees

Labels

Azure CLI TeamThe command of the issue is owned by Azure CLI teamCoreCLI core infrastructurefeature-request

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions