Copy Azure SQL Database Between Azure Subscriptions
Another option is to use 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 <your-source-subscription>).TenantId (Get-AzureRmSubscription -SubscriptionName <your-destination-subscription>).TenantId
You can monitor the progress with:
SELECT state_desc, name
FROM sys.databases
Reference Links:
- https://docs.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://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-move-resources
- https://docs.microsoft.com/en-us/azure/sql-database/sql-database-copy
Create a new Azure SQL Server on a different resource group.
New-AzureSqlDatabaseServer -Location "East US" -AdministratorLogin "AdminLogin" -AdministratorLoginPassword "AdminPassword"
Copy the source database to the newly created Azure SQL Server.
Start-AzureSqlDatabaseCopy -ServerName "SourceServer" -DatabaseName "Orders" -PartnerServer "NewlyCreatedServer" -PartnerDatabase "OrdersCopy"
Move the resource group of the Newly created Azure SQL Server to another subscription.
Move-AzureRmResource -DestinationResourceGroupName [-DestinationSubscriptionId ] -ResourceId [-Force] [-ApiVersion ] [-Pre] [-DefaultProfile ] [-InformationAction ] [-InformationVariable ] [-WhatIf] [-Confirm] []