Blog Post

Azure SQL Blog
2 MIN READ

Cross-subscription support for SQL MI database copy and move - GA refresh!

sasapopo's avatar
sasapopo
Icon for Microsoft rankMicrosoft
Dec 26, 2023

Today I’d like to announce the refresh of database copy and move functionality. This refresh is brining support for cross-subscription copy and move operations within an Azure tenant. This means that if you are using multiple subscriptions under the same Azure tenant and are hosting multiple SQL Managed Instances under those subscriptions, now you can perform online, cross-instance database copy and move operations across all instances under the same tenant.

 

This is especially useful for those who are separating test and production environments with different subscriptions. Now, you will be able to promote a prepared database in test environment to your production subscription and environment, or to bring your production database to your test subscription to thoroughly investigate a new query performance regression.

 

How to perform cross-subscription copy and move operations?

 

Cross-subscriptions are supported with all standard interfaces, meaning via Azure portal, Azure PowerShell and CLI and REST API.

To start the operation via Azure Portal, you just go through the standard flow and on the destination details tab choose the Azure subscription.

 

 

Once the cross-subscription copy or move operation is completed, you will see the details of the operation, like in the example below.

 

 

And the same can be automated with scripts. Here’s an example of Az.Sql PowerShell.

 

 

 

Copy-AzSqlInstanceDatabase -DatabaseName 'db_copy_102' -InstanceName 'sqlmi001' -ResourceGroupName 'resourceGroup1' -TargetResourceGroupName 'resourceGroup2' -TargetInstanceName 'sqlmi002'

## Wait for the operation to be ready for completion.

Complete-AzSqlInstanceDatabaseCopy -DatabaseName 'db_copy_102' -InstanceName 'sqlmi001' -ResourceGroupName 'resourceGroup1' -TargetResourceGroupName 'resourceGroup2' -TargetInstanceName 'sqlmi002'

 

 

 

That’s right – with Az.Sql you don’t even specify the source and target subscriptions – the backend will find them for you.

 

Recommended content

 

Documentation for Azure SQL Managed Instance database copy and move operations.

GA of database copy and move for Azure SQL Managed Instance.

Azure PowerShell for database copy and move.

DEMO VIDEO for database copy and move.

 

Wrap-up

 

I think this would be it for 2023. This was a great year for SQL MI!

I wish you happy holidays, and I’m looking forward to a great year ahead of us and a number of great SQL MI announcements that will come in 2024!

Updated Dec 26, 2023
Version 2.0
  • Hi Sasa Popovic,

     Is Database Copy and Move will support if Managed Instances are in different regions?

     

     

     

  • venkateswarareddich, cross-region copy and move operations are not supported with Azure SQL Managed Instance.
    Would you like to share via comment, email or meeting, more about your use cases?

  • Hi sasapopo ,Thank you for your great essay, I would like to know if the copy- move operation will support the across-tenant methods~

  • Yijun_Chen we don't have plans for supporting cross-tenant operations on our short-term roadmap. I would like to see this supported in the future, and I'm collecting feedback on this, so please reach out via email if you'd like to share more details about your scenarios and needs.

  • mkless's avatar
    mkless
    Copper Contributor

    Dear Sasa Popovic,


    I just tried to use Az.Sql PowerShell to execute a cross subscription copy of a SQL MI database, but I have been not successfull:

    Depending on whether the context is the Target subscription or the Source subscription, I received different failures:

     

    Context: Target Subscription
    Error-Message: Resource group 'Source-RG' could not be found

     

    Context: Source Subscription
    Error-Mesage:
    Copy-AzSqlInstanceDatabase : Long running operation failed with status 'Failed'. Additional Info:'Database 'copy'
    operation failed because there is no network connectivity between source instance 'source-instance' and target instance
    'target-instance'.'


    The error occurs regardless of Powershell is running on my local computer with azure cli and Az-cmdlets installed, or in a Azure Cloud Shell.

     

    Doing an Cross-subscription database copy via the Azure Web-GUI works fine.

     

    Any idea?


    Thanks in Advance,

    Michael

  • Jags9's avatar
    Jags9
    Copper Contributor

    Hi @sasapopo, This is a wonderful article. I have a use case where two different subscriptions are having SQL MI's with TDE enabled with different customer managed keys. How this restore/copy will work as we can't create a different thumbprints like we do on normal SQL Servers. I tried copying a database and got the following error. How can we resolve this.  

     

    Error: Server 'sqlmi-001' requires permissions: 'cryptographic operations' on Azure Key Vault for key ''. Please grant the server both access and required permissions to key vault and retry.

     

    Regards

    Jags

  • mkless thanks for reaching out!

    Context should be the source instance.

    The error message you've received "because there is no network connectivity between source instance 'source-instance' and target instance
    'target-instance'.'" indicates there's no network connectivity. Most likely, there's no VNet peering or required ports are not allowed on source or destination subnets. But then it's confusing that copying via Azure portal, from the same source to the same target does succeed. If that's the case - with same instances it's working via Azure portal and not via Azure PowerShell, I advise you to (1) open a support ticket so we handle this issue officially, and (2) send me a DM here or via email, so we directly work on this as well.

  • Hello Jags9! In this case, you'd need to assign source TDE KEY to the destination SQL MI as a non-default encryptor. With this, destination SQL MI will have access to the key and will be able to decrypt incoming database. 

  • VeghPet's avatar
    VeghPet
    Copper Contributor

    Hi sasapopo , What about cross-tenant SQLMI DB migration support?

    I have 30+ DBs, with 1.6TB data to be migrated from one SQLMI1 in tenantA to SQLMI2 in tenantB. Whatever method (copy-move, SQLMI resource move, etc.) is available I would be interested.