How to replicate snapshot of Azure SQL from Dev subscription to Test subscription?

Viewed 28

I have Dev Azure SQL server in Dev subscription and Test Azure SQL Server in Test subscription.

I would like to copy snaphot of Azure SQL database from "dev" to "test" with script and eventually automated with Azure DevOps pipeline.

I have successfully replicated database inside "Dev" subscription with New-AzSqlDatabaseCopy. However it does not have source and destination subscription parameter.

What is best method to replicate snapshot of database from subscription to another?

1 Answers

This could be done by T-SQL. If the login is member of the dbmanager role or a server administrator, on both source and target servers/subscriptions, then below command copies Database1 on server1 to a new database named Database2 on server2. Depending on the size of your database, the copying operation might take some time to complete.

Execute on the master database of the target server (server2) to start copying from Server1 to Server2

CREATE DATABASE Database2 AS COPY OF server1.Database1;

Note: The Azure portal, PowerShell, and the Azure CLI do not support database copy to a different subscription.

Reference Link for more details: https://docs.microsoft.com/en-us/azure/azure-sql/database/database-copy?view=azuresql&tabs=azure-powershell#copy-to-a-different-subscription

Related