patternMinor
Copy Azure SQL Database Between Azure Subscriptions
Viewed 0 times
sqldatabaseazurebetweensubscriptionscopy
Problem
Getting straight to the point, is this even possible?
I have successfully copied an Azure SQL database within the same subscription. In doing so, I kept it simple by copying the database to the same server (within the subscription). I used the Powershell commands
I have tried executing the
All that said, if this is something that is possible, what are the steps / commands that I need to execute?
I have successfully copied an Azure SQL database within the same subscription. In doing so, I kept it simple by copying the database to the same server (within the subscription). I used the Powershell commands
Add-AzureRmAccount and New-AzureRmSqlDatabaseCopy.I have tried executing the
Add-AzureRmAccount twice (once for each subscription) but this seems to replace the first subscription with the second in the context as the New-AzureRmSqlDatabaseCopy command reports that it cannot find the specified resource group (which exists in the source subscription).All that said, if this is something that is possible, what are the steps / commands that I need to execute?
Solution
Another option is to use
Some important notes:
-
Servers were on the same Tenant, checked via Azure PowerShell console with:
You can monitor the progress with:
Reference Links:
CREATE DATABASE, as per Richard Hauer's answer on Stackoverflow (which I executed from SQL Server Management Studio v17.5):CREATE DATABASE db_copy AS COPY OF ozabzw7545.db_original;Some important notes:
- SQL admin account and password were the same on both servers.
- Servers were in different subscriptions.
-
Servers were on the same Tenant, checked via Azure PowerShell console with:
(Get-AzureRmSubscription -SubscriptionName ).TenantId
(Get-AzureRmSubscription -SubscriptionName ).TenantIdYou can monitor the progress with:
SELECT state_desc, name
FROM sys.databasesReference Links:
- https://learn.microsoft.com/en-us/sql/t-sql/statements/create-database-azure-sql-database?view=azure-sqldw-latest#creating-a-copy-of-a-database-on-another-server
- https://learn.microsoft.com/en-us/azure/azure-resource-manager/resource-group-move-resources
- https://learn.microsoft.com/en-us/azure/sql-database/sql-database-copy
Code Snippets
CREATE DATABASE db_copy AS COPY OF ozabzw7545.db_original;(Get-AzureRmSubscription -SubscriptionName <your-source-subscription>).TenantId
(Get-AzureRmSubscription -SubscriptionName <your-destination-subscription>).TenantIdSELECT state_desc, name
FROM sys.databasesContext
StackExchange Database Administrators Q#198659, answer score: 3
Revisions (0)
No revisions yet.