-
Notifications
You must be signed in to change notification settings - Fork 3.3k
{MySQL} az mysql flexible-server restore: Support different subscription and resource group
#32620
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
️✔️AzureCLI-FullTest
|
️✔️AzureCLI-BreakingChangeTest
|
|
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>
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for cross-subscription and cross-resource-group restore, geo-restore, and replica creation operations for MySQL flexible servers. This enables users to restore or replicate servers to different subscriptions and resource groups by providing a full resource ID instead of just the server name.
Key Changes
- Added
get_mysql_flexible_management_client_by_subfunction to create MySQL management clients with a specific subscription ID - Updated
flexible_server_restore,flexible_server_georestore, andflexible_replica_createto use the new client factory when working with source servers in different subscriptions - Added help documentation with examples showing how to use resource IDs for cross-subscription/cross-resource-group operations
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/azure-cli/azure/cli/command_modules/mysql/_client_factory.py | Added get_mysql_flexible_management_client_by_sub function to support creating MySQL management clients with a specified subscription ID |
| src/azure-cli/azure/cli/command_modules/mysql/custom.py | Updated restore, geo-restore, and replica create functions to fetch source server using subscription-specific client |
| src/azure-cli/azure/cli/command_modules/mysql/_help.py | Added documentation examples demonstrating cross-subscription and cross-resource-group restore/replica operations |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Here --resource-group is for the target server's resource group, and --source-server must be passed as resource ID. | ||
| text: > | ||
| az mysql flexible-server restore --resource-group testGroup --name testserverNew \\ | ||
| --source-server /subscriptions/{testSubscription}/resourceGroups/{sourceResourceGroup}/providers/Microsoft.DBforMySQL/flexibleServers/{sourceServerName} |
Copilot
AI
Jan 8, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The placeholder name should be consistent across all examples. Use {sourceSubscriptionId} instead of {testSubscription} to match the other examples in lines 410, 438, and 685.
| --source-server /subscriptions/{testSubscription}/resourceGroups/{sourceResourceGroup}/providers/Microsoft.DBforMySQL/flexibleServers/{sourceServerName} | |
| --source-server /subscriptions/{sourceSubscriptionId}/resourceGroups/{sourceResourceGroup}/providers/Microsoft.DBforMySQL/flexibleServers/{sourceServerName} |
| Here --resource-group is for the read replica's resource group, and --source-server must be passed as resource ID. | ||
| This resource ID can be in a subscription different than the subscription used for az account set. | ||
| text: > | ||
| az mysql flexible-server replica create --replica-name testReplicaServer -g newTestGroup \ |
Copilot
AI
Jan 8, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use double backslash \\ for line continuation to be consistent with other examples in the file (lines 402, 409, 437). Single backslash \ should be replaced with \\.
| az mysql flexible-server replica create --replica-name testReplicaServer -g newTestGroup \ | |
| az mysql flexible-server replica create --replica-name testReplicaServer -g newTestGroup \\ |
Related command
az mysql flexible-server restore
az mysql flexible-server geo-restore
az mysql flexible-server replica create
Description
Support different subscription and resource group in restore, geo-restore and replica creation.
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.