locked
Move Elastic Pool database from One tenant to another tenant. RRS feed

  • Question

  • We want to move a DB from 1 SQL elastic pool to another SQL elastic pool in different tenant hosted in Azure. So can you please help us to write the script for it? Or if you already have any, then kindly share it with us. Below is the exact requirement.

     

    1. Tenant 1 : abc.onmicrosoft.com

        Subscription : abc

        SQL Elastic Pool : abc.database.windows.net

        DB : abc (This DB to be moved to tenant 2

     

    Need to move DB : abc to new tenant and a different SQL elastic pool

     

    2. Tenant 2 : xyz.onmicrosoft.com

        Subscription : xyz

        SQL Elastic Pool : xyz.database.windows.net

        DB: abc (This should be the moved item from tenant 1)

     


    Chidambar

    Friday, April 19, 2019 12:48 PM

All replies

  • Hi Chidambar,

    If you take a look at the following Transact-SQL: Manage pooled databases there are examples of the T-SQL needed to perform certain actions within managed pools. In your case, you will use ALTER DATABASE (Azure SQL Database) to move databases between managed pools. 

    An example T-SQL will look like:

    ALTER DATABASE db1
    MODIFY ( SERVICE_OBJECTIVE = ELASTIC_POOL ( name = pool1 ) ) ;

    If you need to move databases between subscriptions, you cannot use T-SQL. You need to use PowerShell and by exporting as a .bacpac from the source db and importing that .bacpac in the target elastic pool for the subscription it is rooted to, you can move between subscriptions. The following document explains all the ways in which you can export databases.

    You are going to include a sign-in function to your PowerShell script to authenticate with each subscription and set the appropriate variables for that target database instance.

     I hope this helps.

    Monday, April 22, 2019 8:58 PM