Azure / azure-cli

Azure Command-Line Interface
MIT License
4k stars 2.98k forks source link

Unable to create a Replica Server in a different resource group to the Source Server #27588

Closed plynch66 closed 1 year ago

plynch66 commented 1 year ago

Describe the bug

I am trying to provision an Azure Database MySQL Flexible Server Read Replica in a different region and resource group to the source server.

The docs state that the "--source-server" required parameter needs to be either "The name or resource ID of the source server to restore from."

I am retrieving the resource ID of the source server using the following command :

$srcrg = "SOURCERG" $srcsrv = "SOURCESERVER" $srcsrvid = (az mysql flexible-server show -g $srcrg -n $srcsrv --query '[id]' --output tsv)

and then trying to create the Read Replica using this :

az mysql flexible-server replica create -g $rg -l $loc --replica-name $servername --source-server $srcsrvid --geo-redundant-backup Enabled --public-access Disabled

Related command

az mysql flexible-server replica create

Errors

(InvalidParameterValue) Invalid value given for parameter SourceServerId. Specify a valid parameter value. Code: InvalidParameterValue Message: Invalid value given for parameter SourceServerId. Specify a valid parameter value.

Issue script & Debug output

PS C:> az mysql flexible-server replica create -g $rg -l $loc --replica-name $servername --source-server $srcsrvid --geo-redundant-backup Enabled --public-access Disabled --debug cli.knack.cli: Command arguments: ['mysql', 'flexible-server', 'replica', 'create', '-g', 'NAME', '-l', 'eastus2', '--replica-name', 'NAME', '--source-server', '/subscriptions/SUBSCRIPTIONID/resourceGroups/RESOURCEGROUPID/providers/Microsoft.DBforMySQL/flexibleServers/SOURCENAME', '--geo-redundant-backup', 'Enabled', '--public-access', 'Disabled', '--debug'] cli.knack.cli: init debug log: Enable color in terminal. Enable VT mode. cli.knack.cli: Event: Cli.PreExecute [] cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x016CC538>, <function OutputProducer.on_global_arguments at 0x018CB778>, <function CLIQuery.on_global_arguments at 0x018E83D0>] cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate [] cli.azure.cli.core: Modules found from index for 'mysql': ['azure.cli.command_modules.mysql', 'azure.cli.command_modules.rdbms'] cli.azure.cli.core: Loading command modules: cli.azure.cli.core: Name Load Time Groups Commands cli.azure.cli.core: mysql 0.272 14 49 cli.azure.cli.core: rdbms 0.018 44 185 cli.azure.cli.core: Total (2) 0.290 58 234 cli.azure.cli.core: These extensions are not installed and will be skipped: ['azext_ai_examples', 'azext_next'] cli.azure.cli.core: Loading extensions: cli.azure.cli.core: Name Load Time Groups Commands Directory cli.azure.cli.core: Total (0) 0.000 0 0 cli.azure.cli.core: Loaded 57 groups, 234 commands. cli.azure.cli.core: Found a match in the command table. cli.azure.cli.core: Raw command : mysql flexible-server replica create cli.azure.cli.core: Command table: mysql flexible-server replica create cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x03A7B610>] cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to 'C:\Users\USERID.azure\commands\2023-10-12.14-55-55.mysql_flexible-server_replica_create.12444.log'. az_command_data_logger: command args: mysql flexible-server replica create -g {} -l {} --replica-name {} --source-server {} --geo-redundant-backup {} --public-access {} --debug cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument..add_subscription_parameter at 0x03AA3850>] cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad [] cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument..add_ids_arguments at 0x03ACC7C0>, <function register_cache_arguments..add_cache_arguments at 0x03ACC9B8>] cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded [] cli.knack.cli: Event: CommandInvoker.OnPreParseArgs [] cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x018CB7C0>, <function CLIQuery.handle_query_parameter at 0x018E8418>, <function register_ids_argument..parse_ids_arguments at 0x03ACC970>] cli.azure.cli.core.commands.client_factory: Getting management service client client_type=MySQLManagementClient cli.azure.cli.core.auth.persistence: build_persistence: location='C:\Users\USERID\.azure\msal_token_cache.bin', encrypt=True cli.azure.cli.core.auth.binary_cache: load: C:\Users\USERID.azure\msal_http_cache.bin urllib3.util.retry: Converted retries value: 1 -> Retry(total=1, connect=None, read=None, redirect=None, status=None) msal.authority: openid_config = {'token_endpoint': 'https://login.microsoftonline.com/a8b26e32-8d62-44bd-bc89-bc41aab2f7bf/oauth2/v2.0/token', 'token_endpoint_auth_methods_supported': ['client_secret_post', 'private_key_jwt', 'client_secret_basic'], 'jwks_uri': 'https://login.microsoftonline.com/a8b26e32-8d62-44bd-bc89-bc41aab2f7bf/discovery/v2.0/keys', 'response_modes_supported': ['query', 'fragment', 'form_post'], 'subject_types_supported': ['pairwise'], 'id_token_signing_alg_values_supported': ['RS256'], 'response_types_supported': ['code', 'id_token', 'code id_token', 'id_token token'], 'scopes_supported': ['openid', 'profile', 'email', 'offline_access'], 'issuer': 'https://login.microsoftonline.com/a8b26e32-8d62-44bd-bc89-bc41aab2f7bf/v2.0', 'request_uri_parameter_supported': False, 'userinfo_endpoint': 'https://graph.microsoft.com/oidc/userinfo', 'authorization_endpoint': 'https://login.microsoftonline.com/a8b26e32-8d62-44bd-bc89-bc41aab2f7bf/oauth2/v2.0/authorize', 'device_authorization_endpoint': 'https://login.microsoftonline.com/a8b26e32-8d62-44bd-bc89-bc41aab2f7bf/oauth2/v2.0/devicecode', 'http_logout_supported': True, 'frontchannel_logout_supported': True, 'end_session_endpoint': 'https://login.microsoftonline.com/a8b26e32-8d62-44bd-bc89-bc41aab2f7bf/oauth2/v2.0/logout', 'claims_supported': ['sub', 'iss', 'cloud_instance_name', 'cloud_instance_host_name', 'cloud_graph_host_name', 'msgraph_host', 'aud', 'exp', 'iat', 'auth_time', 'acr', 'nonce', 'preferred_username', 'name', 'tid', 'ver', 'at_hash', 'c_hash', 'email'], 'kerberos_endpoint': 'https://login.microsoftonline.com/a8b26e32-8d62-44bd-bc89-bc41aab2f7bf/kerberos', 'tenant_region_scope': 'EU', 'cloud_instance_name': 'microsoftonline.com', 'cloud_graph_host_name': 'graph.windows.net', 'msgraph_host': 'graph.microsoft.com', 'rbac_url': 'https://pas.windows.net'} msal.application: Broker enabled? False cli.azure.cli.core.auth.credential_adaptor: CredentialAdaptor.get_token: scopes=('https://management.core.windows.net//.default',), kwargs={} cli.azure.cli.core.auth.msal_authentication: UserCredential.get_token: scopes=('https://management.core.windows.net//.default',), claims=None, kwargs={} msal.application: Cache hit an AT msal.telemetry: Generate or reuse correlation_id: 31a75574-ea1d-4d81-b21e-5430f0bd661f cli.azure.cli.core.sdk.policies: Request URL: 'https://management.azure.com/subscriptions/SUBSCRIPTIONID/resourceGroups/RESOURCEGROUPID/providers/Microsoft.DBforMySQL/flexibleServers/SOURCENAME?api-version=2022-09-30-preview' cli.azure.cli.core.sdk.policies: Request method: 'GET' cli.azure.cli.core.sdk.policies: Request headers: cli.azure.cli.core.sdk.policies: 'Accept': 'application/json' cli.azure.cli.core.sdk.policies: 'x-ms-client-request-id': '10100799-6907-11ee-bda6-847b57955f8c' cli.azure.cli.core.sdk.policies: 'CommandName': 'mysql flexible-server replica create' cli.azure.cli.core.sdk.policies: 'ParameterSetName': '-g -l --replica-name --source-server --geo-redundant-backup --public-access --debug' cli.azure.cli.core.sdk.policies: 'User-Agent': 'AZURECLI/2.53.0 (MSI) azsdk-python-mgmt-rdbms/10.2.0b10 Python/3.10.10 (Windows-10-10.0.19045-SP0)' cli.azure.cli.core.sdk.policies: 'Authorization': '' cli.azure.cli.core.sdk.policies: Request body: cli.azure.cli.core.sdk.policies: This request has no body urllib3.connectionpool: Starting new HTTPS connection (1): management.azure.com:443 urllib3.connectionpool: https://management.azure.com:443 "GET /subscriptions/SUBSCRIPTIONID/resourceGroups/RESOURCEGROUPID/providers/Microsoft.DBforMySQL/flexibleServers/SOURCENAME?api-version=2022-09-30-preview HTTP/1.1" 200 None cli.azure.cli.core.sdk.policies: Response status: 200 cli.azure.cli.core.sdk.policies: Response headers: cli.azure.cli.core.sdk.policies: 'Cache-Control': 'no-cache' cli.azure.cli.core.sdk.policies: 'Pragma': 'no-cache' cli.azure.cli.core.sdk.policies: 'Transfer-Encoding': 'chunked' cli.azure.cli.core.sdk.policies: 'Content-Type': 'application/json; charset=utf-8' cli.azure.cli.core.sdk.policies: 'Content-Encoding': 'gzip' cli.azure.cli.core.sdk.policies: 'Expires': '-1' cli.azure.cli.core.sdk.policies: 'Vary': 'Accept-Encoding' cli.azure.cli.core.sdk.policies: 'X-Content-Type-Options': 'nosniff' cli.azure.cli.core.sdk.policies: 'x-ms-request-id': '9c97cd51-66a1-4126-8e35-f8779115f768' cli.azure.cli.core.sdk.policies: 'Server': 'Microsoft-HTTPAPI/2.0' cli.azure.cli.core.sdk.policies: 'x-ms-ratelimit-remaining-subscription-reads': '11999' cli.azure.cli.core.sdk.policies: 'x-ms-correlation-request-id': 'cf7f96d2-6dae-4be8-b38d-83bc930b504b' cli.azure.cli.core.sdk.policies: 'x-ms-routing-request-id': 'UKSOUTH:20231012T135555Z:cf7f96d2-6dae-4be8-b38d-83bc930b504b' cli.azure.cli.core.sdk.policies: 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains' cli.azure.cli.core.sdk.policies: 'Date': 'Thu, 12 Oct 2023 13:55:55 GMT' cli.azure.cli.core.sdk.policies: Response content: cli.azure.cli.core.sdk.policies: {"sku":{"name":"Standard_D2ads_v5","tier":"GeneralPurpose"},"systemData":{"createdAt":"2023-10-12T09:38:56.1066915Z"},"properties":{"administratorLogin":"cloudsqladmin","storage":{"storageSizeGB":20,"iops":360,"autoGrow":"Enabled","autoIoScaling":"Enabled","storageSku":"Premium_LRS","logOnDisk":"Disabled"},"version":"8.0.21","state":"Ready","fullyQualifiedDomainName":"SOURCENAME.mysql.database.azure.com","availabilityZone":"2","maintenanceWindow":{"customWindow":"Disabled","dayOfWeek":0,"startHour":0,"startMinute":0},"replicationRole":"None","replicaCapacity":10,"network":{"publicNetworkAccess":"Disabled"},"backup":{"backupRetentionDays":7,"geoRedundantBackup":"Disabled","earliestRestoreDate":"2023-10-12T09:48:56.1066915+00:00"},"highAvailability":{"mode":"Disabled","state":"NotEnabled","standbyAvailabilityZone":""},"privateEndpointConnections":[{"properties":{"privateEndpoint":{"id":"/subscriptions/SUBSCRIPTIONID/resourceGroups/RESOURCEGROUPID/providers/Microsoft.Network/privateEndpoints/XXXXXMYSQLPRIVLNK"},"groupIds":["mysqlServer"],"privateLinkServiceConnectionState":{"status":"Approved","description":"Auto-approved","actionsRequired":"None"},"provisioningState":"Ready"},"id":"/subscriptions/SUBSCRIPTIONID/resourceGroups/RESOURCEGROUPID/providers/Microsoft.DBforMySQL/flexibleServers/SOURCENAME/privateEndpointConnections/XXXXXMYSQLPRIVLNK-28fc73d5-1a7b-46a0-a8e3-fe62c0e97c96"}]},"location":"West Europe","tags":{},"id":"/subscriptions/SUBSCRIPTIONID/resourceGroups/RESOURCEGROUPID/providers/Microsoft.DBforMySQL/flexibleServers/SOURCENAME","name":"SOURCENAME","type":"Microsoft.DBforMySQL/flexibleServers"} cli.azure.cli.core.sdk.policies: Request URL: 'https://management.azure.com/subscriptions/SUBSCRIPTIONID/resourceGroups/RESOURCEGROUP/providers/Microsoft.DBforMySQL/flexibleServers/REPLICANAME?api-version=2022-09-30-preview' cli.azure.cli.core.sdk.policies: Request method: 'PUT' cli.azure.cli.core.sdk.policies: Request headers: cli.azure.cli.core.sdk.policies: 'Content-Type': 'application/json' cli.azure.cli.core.sdk.policies: 'Content-Length': '463' cli.azure.cli.core.sdk.policies: 'Accept': 'application/json' cli.azure.cli.core.sdk.policies: 'x-ms-client-request-id': '10100799-6907-11ee-bda6-847b57955f8c' cli.azure.cli.core.sdk.policies: 'CommandName': 'mysql flexible-server replica create' cli.azure.cli.core.sdk.policies: 'ParameterSetName': '-g -l --replica-name --source-server --geo-redundant-backup --public-access --debug' cli.azure.cli.core.sdk.policies: 'User-Agent': 'AZURECLI/2.53.0 (MSI) azsdk-python-mgmt-rdbms/10.2.0b10 Python/3.10.10 (Windows-10-10.0.19045-SP0)' cli.azure.cli.core.sdk.policies: 'Authorization': '' cli.azure.cli.core.sdk.policies: Request body: cli.azure.cli.core.sdk.policies: {"location": "eastus2", "sku": {"name": "Standard_D2ads_v5", "tier": "GeneralPurpose"}, "properties": {"createMode": "Replica", "sourceServerResourceId": "/subscriptions/SUBSCRIPTIONID/resourceGroups/RESOURCEGROUPID/providers/Microsoft.DBforMySQL/flexibleServers/SOURCENAME", "storage": {"storageSizeGB": 20, "iops": 360, "autoGrow": "Enabled", "autoIoScaling": "Enabled"}, "backup": {"backupRetentionDays": 7, "geoRedundantBackup": "Enabled"}}} urllib3.connectionpool: https://management.azure.com:443 "PUT /subscriptions/SUBSCRIPTIONID/resourceGroups/RESOURCEGROUP/providers/Microsoft.DBforMySQL/flexibleServers/REPLICANAME?api-version=2022-09-30-preview HTTP/1.1" 400 137 cli.azure.cli.core.sdk.policies: Response status: 400 cli.azure.cli.core.sdk.policies: Response headers: cli.azure.cli.core.sdk.policies: 'Cache-Control': 'no-cache' cli.azure.cli.core.sdk.policies: 'Pragma': 'no-cache' cli.azure.cli.core.sdk.policies: 'Content-Length': '137' cli.azure.cli.core.sdk.policies: 'Content-Type': 'application/json; charset=utf-8' cli.azure.cli.core.sdk.policies: 'Expires': '-1' cli.azure.cli.core.sdk.policies: 'X-Content-Type-Options': 'nosniff' cli.azure.cli.core.sdk.policies: 'x-ms-request-id': 'ba9dd982-f3a7-4d12-935d-8c2036ecc8ab' cli.azure.cli.core.sdk.policies: 'Server': 'Microsoft-HTTPAPI/2.0' cli.azure.cli.core.sdk.policies: 'x-ms-ratelimit-remaining-subscription-writes': '1199' cli.azure.cli.core.sdk.policies: 'x-ms-correlation-request-id': '40f2c6da-51b9-464b-9e56-db6f9e1a1908' cli.azure.cli.core.sdk.policies: 'x-ms-routing-request-id': 'UKSOUTH:20231012T135557Z:40f2c6da-51b9-464b-9e56-db6f9e1a1908' cli.azure.cli.core.sdk.policies: 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains' cli.azure.cli.core.sdk.policies: 'Date': 'Thu, 12 Oct 2023 13:55:57 GMT' cli.azure.cli.core.sdk.policies: Response content: cli.azure.cli.core.sdk.policies: {"error":{"code":"InvalidParameterValue","message":"Invalid value given for parameter SourceServerId. Specify a valid parameter value."}} cli.azure.cli.core.azclierror: Traceback (most recent call last): File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 233, in invoke File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 663, in execute File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 726, in _run_jobs_serially File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 697, in _run_job File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 333, in call File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 121, in handler File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/mysql/custom.py", line 1267, in flexible_replica_create File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/core/tracing/decorator.py", line 78, in wrapper_use_tracer File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/mgmt/rdbms/mysql_flexibleservers/operations/_servers_operations.py", line 600, in begin_create File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/mgmt/rdbms/mysql_flexibleservers/operations/_servers_operations.py", line 466, in _create_initial azure.core.exceptions.HttpResponseError: (InvalidParameterValue) Invalid value given for parameter SourceServerId. Specify a valid parameter value. Code: InvalidParameterValue Message: Invalid value given for parameter SourceServerId. Specify a valid parameter value.

cli.azure.cli.core.azclierror: (InvalidParameterValue) Invalid value given for parameter SourceServerId. Specify a valid parameter value. Code: InvalidParameterValue Message: Invalid value given for parameter SourceServerId. Specify a valid parameter value. az_command_data_logger: (InvalidParameterValue) Invalid value given for parameter SourceServerId. Specify a valid parameter value. Code: InvalidParameterValue Message: Invalid value given for parameter SourceServerId. Specify a valid parameter value. cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x03A7B730>] az_command_data_logger: exit code: 1 cli.main: Command ran in 3.135 seconds (init: 0.315, invoke: 2.820) telemetry.main: Begin splitting cli events and extra events, total events: 1 telemetry.client: Accumulated 0 events. Flush the clients. telemetry.main: Finish splitting cli events and extra events, cli events: 1 telemetry.save: Save telemetry record of length 3715 in cache telemetry.main: Begin creating telemetry upload process. telemetry.process: Creating upload process: "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\python.exe C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\Lib\site-packages\azure\cli\telemetry__init__.pyc C:\Users\USERID.azure" telemetry.process: Return from creating process telemetry.main: Finish creating telemetry upload process. PS C:>

Expected behavior

I expect a Read Replica to be created in the EastUS2 resource group but this doesn't happen.

Environment Summary

PS C:> az --version azure-cli 2.53.0

core 2.53.0 telemetry 1.1.0

Extensions: front-door 1.0.17

Dependencies: msal 1.24.0b2 azure-mgmt-resource 23.1.0b2

Python location 'C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\python.exe' Extensions directory 'C:\Users\Paul Lynch.azure\cliextensions'

Python (Windows) 3.10.10 (tags/v3.10.10:aad5f6a, Feb 7 2023, 17:05:00) [MSC v.1929 32 bit (Intel)]

Your CLI is up-to-date.

Additional context

No response

yonzhan commented 1 year ago

Thank you for opening this issue, we will look into it.

microsoft-github-policy-service[bot] commented 1 year ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @ambhatna, @savjani.

plynch66 commented 1 year ago

Hi,

Apologies, the documentation states that the Replica is created in the same resource group as the source server. I missed this important detail.

https://learn.microsoft.com/en-us/azure/mysql/flexible-server/concepts-read-replicas#create-a-replica