[MySQL] fix resolve api version in vnet or subnet existence check#33446
[MySQL] fix resolve api version in vnet or subnet existence check#33446ramnov wants to merge 2 commits into
Conversation
️✔️AzureCLI-FullTest
|
️✔️AzureCLI-BreakingChangeTest
|
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates MySQL command module API-version resolution to prefer the provider’s default_api_version when available for an unambiguous resource type.
Changes:
- Return
default_api_versionwhen exactly one matching resource type is found and it provides a non-empty default. - Preserve existing fallback behavior that prefers non-preview versions from
api_versions.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if len(rt) == 1 and rt[0].default_api_version not in (None, ''): | ||
| return rt[0].default_api_version | ||
| if len(rt) == 1 and rt[0].api_versions: | ||
| npv = [v for v in rt[0].api_versions if 'preview' not in v.lower()] | ||
| return npv[0] if npv else rt[0].api_versions[0] |
|
Thank you for your contribution! We will review the pull request and get back to you soon. |
|
The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR. Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions). pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>
|
Related command
any path that resolves a --subnet / --vnet / --private-dns-zone)
Description
In regions where the Microsoft.Network/virtualNetworks RP has not yet rolled out its newest API version (e.g. UAE North, where the RP tops out at 2025-07-01 while the global newest is 2025-09-01), az mysql flexible-server commands that take an existing subnet fail with:
ERROR: Invalid Vnet. The vnet id of the subnet id your provided was not found.
Root cause: _resolve_api_version in mysql/_util.py picked the first non-preview entry from provider.resource_types[].api_versions, i.e. the RP's globally-newest version. ARM rolls API versions out per region, so the picked version is not yet enabled in UAE North. ARM returns 400 NoRegisteredProviderFound; the existence check treats that as "not found" and aborts with the misleading Invalid Vnet message.
Fix: prefer the RP-declared default_api_version (pinned by the RP to a broadly-supported stable version available in every region), and fall back to the previous api_versions[0] logic only when no default is declared. This matches the pattern already used by PostgreSQL flexible-server (postgresql/utils/_flexible_server_util.py::_resolve_api_version).
Effect: VNet/subnet/private-DNS-zone existence probes now succeed in regions like UAE North; no behavior change for regions/RPs that already work (they fall through to the existing logic).
Testing Guide
History Notes
This checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.
I adhere to the Error Handling Guidelines.