Skip to content

[SQL] az sql db replica create: Add partner subscription id for cross-subscription GeoDr#31594

Merged
evelyn-ys merged 7 commits intoAzure:devfrom
alecbain:albain/CrossSubGeoDr
Jun 16, 2025
Merged

[SQL] az sql db replica create: Add partner subscription id for cross-subscription GeoDr#31594
evelyn-ys merged 7 commits intoAzure:devfrom
alecbain:albain/CrossSubGeoDr

Conversation

@alecbain
Copy link
Copy Markdown
Contributor

@alecbain alecbain commented Jun 3, 2025

Related command

az sql db replica create

Description

This change adds support for starting GeoDr in cross-subscription scenarios (secondary server in a different subscription than primary server). This is done by adding a new optional parameter for the partner subscription id, which when passed is used to create a management client using that subscription to call the create db workflow.

Testing Guide

Added automated test matching existing automated scenarios.
Manual test done with command like:
az sql db replica create -g <rgName> -s <serverName> -n <dbname> --partner-server <cross-sub_serverName> --partner-resource-group <partner_rgName> --partner-sub-id <partner_subscription_id>


This checklist is used to make sure that common guidelines for a pull request are followed.

Copilot AI review requested due to automatic review settings June 3, 2025 22:32
@azure-client-tools-bot-prd
Copy link
Copy Markdown

azure-client-tools-bot-prd bot commented Jun 3, 2025

️✔️AzureCLI-FullTest
️✔️acr
️✔️latest
️✔️3.12
️✔️3.9
️✔️acs
️✔️latest
️✔️3.12
️✔️3.9
️✔️advisor
️✔️latest
️✔️3.12
️✔️3.9
️✔️ams
️✔️latest
️✔️3.12
️✔️3.9
️✔️apim
️✔️latest
️✔️3.12
️✔️3.9
️✔️appconfig
️✔️latest
️✔️3.12
️✔️3.9
️✔️appservice
️✔️latest
️✔️3.12
️✔️3.9
️✔️aro
️✔️latest
️✔️3.12
️✔️3.9
️✔️backup
️✔️latest
️✔️3.12
️✔️3.9
️✔️batch
️✔️latest
️✔️3.12
️✔️3.9
️✔️batchai
️✔️latest
️✔️3.12
️✔️3.9
️✔️billing
️✔️latest
️✔️3.12
️✔️3.9
️✔️botservice
️✔️latest
️✔️3.12
️✔️3.9
️✔️cdn
️✔️latest
️✔️3.12
️✔️3.9
️✔️cloud
️✔️latest
️✔️3.12
️✔️3.9
️✔️cognitiveservices
️✔️latest
️✔️3.12
️✔️3.9
️✔️compute_recommender
️✔️latest
️✔️3.12
️✔️3.9
️✔️computefleet
️✔️latest
️✔️3.12
️✔️3.9
️✔️config
️✔️latest
️✔️3.12
️✔️3.9
️✔️configure
️✔️latest
️✔️3.12
️✔️3.9
️✔️consumption
️✔️latest
️✔️3.12
️✔️3.9
️✔️container
️✔️latest
️✔️3.12
️✔️3.9
️✔️containerapp
️✔️latest
️✔️3.12
️✔️3.9
️✔️core
️✔️latest
️✔️3.12
️✔️3.9
️✔️cosmosdb
️✔️latest
️✔️3.12
️✔️3.9
️✔️databoxedge
️✔️latest
️✔️3.12
️✔️3.9
️✔️dls
️✔️latest
️✔️3.12
️✔️3.9
️✔️dms
️✔️latest
️✔️3.12
️✔️3.9
️✔️eventgrid
️✔️latest
️✔️3.12
️✔️3.9
️✔️eventhubs
️✔️latest
️✔️3.12
️✔️3.9
️✔️feedback
️✔️latest
️✔️3.12
️✔️3.9
️✔️find
️✔️latest
️✔️3.12
️✔️3.9
️✔️hdinsight
️✔️latest
️✔️3.12
️✔️3.9
️✔️identity
️✔️latest
️✔️3.12
️✔️3.9
️✔️iot
️✔️latest
️✔️3.12
️✔️3.9
️✔️keyvault
️✔️latest
️✔️3.12
️✔️3.9
️✔️lab
️✔️latest
️✔️3.12
️✔️3.9
️✔️managedservices
️✔️latest
️✔️3.12
️✔️3.9
️✔️maps
️✔️latest
️✔️3.12
️✔️3.9
️✔️marketplaceordering
️✔️latest
️✔️3.12
️✔️3.9
️✔️monitor
️✔️latest
️✔️3.12
️✔️3.9
️✔️mysql
️✔️latest
️✔️3.12
️✔️3.9
️✔️netappfiles
️✔️latest
️✔️3.12
️✔️3.9
️✔️network
️✔️latest
️✔️3.12
️✔️3.9
️✔️policyinsights
️✔️latest
️✔️3.12
️✔️3.9
️✔️privatedns
️✔️latest
️✔️3.12
️✔️3.9
️✔️profile
️✔️latest
️✔️3.12
️✔️3.9
️✔️rdbms
️✔️latest
️✔️3.12
️✔️3.9
️✔️redis
️✔️latest
️✔️3.12
️✔️3.9
️✔️relay
️✔️latest
️✔️3.12
️✔️3.9
️✔️resource
️✔️latest
️✔️3.12
️✔️3.9
️✔️role
️✔️latest
️✔️3.12
️✔️3.9
️✔️search
️✔️latest
️✔️3.12
️✔️3.9
️✔️security
️✔️latest
️✔️3.12
️✔️3.9
️✔️servicebus
️✔️latest
️✔️3.12
️✔️3.9
️✔️serviceconnector
️✔️latest
️✔️3.12
️✔️3.9
️✔️servicefabric
️✔️latest
️✔️3.12
️✔️3.9
️✔️signalr
️✔️latest
️✔️3.12
️✔️3.9
️✔️sql
️✔️latest
️✔️3.12
️✔️3.9
️✔️sqlvm
️✔️latest
️✔️3.12
️✔️3.9
️✔️storage
️✔️latest
️✔️3.12
️✔️3.9
️✔️synapse
️✔️latest
️✔️3.12
️✔️3.9
️✔️telemetry
️✔️latest
️✔️3.12
️✔️3.9
️✔️util
️✔️latest
️✔️3.12
️✔️3.9
️✔️vm
️✔️latest
️✔️3.12
️✔️3.9

@azure-client-tools-bot-prd
Copy link
Copy Markdown

azure-client-tools-bot-prd bot commented Jun 3, 2025

⚠️AzureCLI-BreakingChangeTest
⚠️sql
rule cmd_name rule_message suggest_message
⚠️ 1006 - ParaAdd sql db replica create cmd sql db replica create added parameter partner_sub_id

@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented Jun 3, 2025

Thank you for your contribution! We will review the pull request and get back to you soon.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Jun 3, 2025

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).
After that please run the following commands to enable git hooks:

pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>

Copy link
Copy Markdown
Contributor

Copilot AI left a 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 GeoDR scenarios for SQL database replicas by introducing a new optional partner subscription id parameter. Key changes include:

  • Updating test fixtures and adding a new cross‐subscription replica creation test with updated server locations.
  • Modifying key functions in custom.py and _util.py to accept an optional subscription_id parameter.
  • Adding a new CLI argument (partner_sub_id) in _params.py for specifying the partner subscription.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

File Description
tests/latest/test_sql_commands.py Updated test resource locations and added a cross‐subscription test case.
custom.py Updated functions (_get_server_location, DatabaseIdentity, db_create_replica) to propagate subscription_id.
_util.py Modified management client retrieval functions to accept subscription_id.
_params.py Introduced partner_sub_id argument with corresponding help message.
Comments suppressed due to low confidence (1)

src/azure-cli/azure/cli/command_modules/sql/_params.py:1138

  • Concatenate the help string with an explicit space (e.g. after 'in.') to ensure the final message reads clearly.
help='Subscription id to create the new replica in.'



def _get_server_location(cli_ctx, server_name, resource_group_name):
def _get_server_location(cli_ctx, server_name, resource_group_name, subscription_id = None):
Copy link

Copilot AI Jun 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider adding type hints for the new subscription_id parameter to improve code clarity and maintainability.

Suggested change
def _get_server_location(cli_ctx, server_name, resource_group_name, subscription_id = None):
def _get_server_location(cli_ctx, server_name: str, resource_group_name: str, subscription_id: Optional[str] = None) -> str:

Copilot uses AI. Check for mistakes.
@evelyn-ys
Copy link
Copy Markdown
Member

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@evelyn-ys
Copy link
Copy Markdown
Member

@alecbain Pix fix the style error

@alecbain alecbain changed the title [SQL] az sql db replica create : Add partner subscription id for cross-subscription GeoDr [SQL] az sql db replica create: Add partner subscription id for cross-subscription GeoDr Jun 12, 2025
@alecbain
Copy link
Copy Markdown
Contributor Author

@evelyn-ys Updated and fixed the style errors flagged by the pipeline.

@evelyn-ys
Copy link
Copy Markdown
Member

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@evelyn-ys
Copy link
Copy Markdown
Member

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@evelyn-ys evelyn-ys merged commit 7a1da0a into Azure:dev Jun 16, 2025
49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Auto-Assign Auto assign by bot SQL az sql

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants