1

I am trying to set up a Sql Sync Member to a database in another tenant using the New-AzSqlSyncMember however whenever i run it get the error message

New-AzSqlSyncMember: Long running operation failed with status 'BadRequest'.

The command im running is:

New-AzSqlSyncMember -Name "datamigrationtest" -MemberDatabaseType "SqlServerDatabase" -MemberServerName "datamigrationtest" -MemberDatabaseName "AutomationTest_Copy" -SyncDirection "Bidirectional" -SyncMemberAzureDatabaseResourceId "/subscriptions/xxxxx/resourceGroups/zzzzz/providers/Microsoft.Sql/servers/datamigrationtest/databases/AutomationTest_Copy" -SyncGroupName "automationmigrationtest" -ServerName "automation-qa" -DatabaseName "AutomationTest" -ResourceGroupName "yyyy" -DefaultProfile $DefaultProfile

It asks for the credentials to the member server when running which I confirmed are correct when connecting to the server in SSMS

1
  • Double-check that the SyncMemberAzureDatabaseResourceId is absolutely correct. Copy it directly from the Azure portal or using Get-AzResource. Even a minor typo will cause this error. Commented Apr 10 at 6:09

1 Answer 1

0

Error you are facing is due to use of different MemberDatabaseType

We need to have the following before adding NewSqlSyncMember:

  1. Both hub and member should have same database type.
  2. SQL authentication should be enabled on both hub and member databases
  3. Login to Hub and member tenant using
Connect-AzAccount -Tenant '<MEMBER_TENANT_ID>' -SubscriptionId '<MEMBER_SUBSCRIPTION_ID>' -UseDeviceAuthentication
Connect-AzAccount -Tenant '<HUB_TENANT_ID>' -SubscriptionId '<HUB_SUBSCRIPTION_ID>' -UseDeviceAuthentication
  1. You should have access to both Hub and Member Databases.

I have tried with the same command used by you. I got the similar error. Note the MemberDatabaseType Before enter image description here

Then, MemberDatabaseType changed to AzureSqlDatabase

Command:

New-AzSqlSyncMember -Name "datamigrationtest" -MemberDatabaseType "SqlServerDatabase" -MemberServerName "servername" -MemberDatabaseName "<databasename>" -SyncDirection "Bidirectional" -SyncMemberAzureDatabaseResourceId "/subscriptions/xxxx-xxx-xxxx-xxx/resourceGroups/<memberresourcegrp>/providers/Microsoft.Sql/servers/<servername>/databases/<databasename>" -SyncGroupName "DataSyncGroup" -ServerName "<servername>" -DatabaseName "<datamabasename>" -ResourceGroupName "<resourcegrp>" -DefaultProfile $DefaultProfile

Then it will ask for username and password for Member Database. Provide Correct credentials. enter image description here

Now SqlSyncMember created successfully.

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.