4

How to copy an Azure SQL Database to a different server or subscription using Az...

 2 years ago
source link: https://techcommunity.microsoft.com/t5/azure-database-support-blog/how-to-copy-an-azure-sql-database-to-a-different-server-or/ba-p/2649689?WT_mc_id=DOP-MVP-4025064
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
How to copy an Azure SQL Database to a different server or subscription using Azure Automation

How to copy an Azure SQL Database to a different server or subscription using Azure Automation

Published Oct 24 2021 05:43 AM 864 Views

In this article we will demonstrate how to copy an Azure SQL DB to a different server or subscription using Azure Automation.

This article will explain the following:

1- The requirements on Azure SQL DB and how to fulfil it.

2- How to create an Azure Automation account and add a runbook to execute the copy operation.





1. Requirements for Azure SQL DB





--Step# 1

--Create login and user in the master database of the source server.



CREATE LOGIN loginname WITH PASSWORD = 'xxxxxxxxx'

GO

CREATE USER [loginname] FOR LOGIN [loginname] WITH DEFAULT_SCHEMA=[dbo];

GO

ALTER ROLE dbmanager ADD MEMBER loginname;

GO



--Step# 2

--Create the user in the source database and grant dbowner permission to the database.



CREATE USER [loginname] FOR LOGIN [loginname] WITH DEFAULT_SCHEMA=[dbo];

GO

ALTER ROLE db_owner ADD MEMBER loginname;

GO



--Step# 3

--Capture the SID of the user "loginname" from master database



SELECT [sid] FROM sysusers WHERE [name] = 'loginname';



--Step# 4

--Connect to Destination server.

--Create login and user in the master database, same as of the source server.



CREATE LOGIN loginname WITH PASSWORD = 'xxxxxxxxx', SID = [SID of loginname login on source server];

GO

CREATE USER [loginname] FOR LOGIN [loginname] WITH DEFAULT_SCHEMA=[dbo];

GO

ALTER ROLE dbmanager ADD MEMBER loginname;

GO







From the above script we have created a same login on the source and target server that we will use on the Automation account to execute the copy.



2. Create Azure automation account and add runbook











1 Comment

‎Oct 24 2021 11:30 PM

You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.

%3CLINGO-SUB%20id%3D%22lingo-sub-2649689%22%20slang%3D%22en-US%22%3EHow%20to%20copy%20an%20Azure%20SQL%20Database%20to%20a%20different%20server%20or%20subscription%20using%20Azure%20Automation%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2649689%22%20slang%3D%22en-US%22%3E%3CP%3EIn%20this%20article%20we%20will%20demonstrate%20how%20to%20copy%20an%20Azure%20SQL%20DB%20to%20a%20different%20server%20or%20subscription%20using%20Azure%20Automation.%3C%2FP%3E%0A%3CP%3EThis%20article%20will%20explain%20the%20following%3A%3C%2FP%3E%0A%3CP%3E1-%20The%20requirements%20on%20Azure%20SQL%20DB%20and%20how%20to%20fulfil%20it.%3C%2FP%3E%0A%3CP%3E2-%20How%20to%20create%20an%20Azure%20Automation%20account%20and%20add%20a%20runbook%20to%20execute%20the%20copy%20operation.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E1.%20Requirements%20for%20Azure%20SQL%20DB%20%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EUse%20a%20login%20that%20has%20the%20same%20name%20and%20password%20as%20the%20database%20owner%20of%20the%20source%20database%20on%20the%20source%20server.%20The%20login%20on%20the%20target%20server%20must%20also%20be%20a%20member%20of%20the%26nbsp%3Bdbmanager%26nbsp%3Brole%2C%20or%20be%20the%20server%20administrator%20login.%3C%2FLI%3E%0A%3CLI%3EThe%20below%20steps%20can%20be%20used%20to%20create%20the%20login%20on%20the%20source%20and%20the%20target%20server.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-sql%22%3E%3CCODE%3E--Step%23%201%0A%0A--Create%20login%20and%20user%20in%20the%20master%20database%20of%20the%20source%20server.%0A%0A%0A%0ACREATE%20LOGIN%20loginname%20WITH%20PASSWORD%20%3D%20'xxxxxxxxx'%0A%0AGO%0A%0ACREATE%20USER%20%5Bloginname%5D%20FOR%20LOGIN%20%5Bloginname%5D%20WITH%20DEFAULT_SCHEMA%3D%5Bdbo%5D%3B%0A%0AGO%0A%0AALTER%20ROLE%20dbmanager%20ADD%20MEMBER%20loginname%3B%0A%0AGO%0A%0A%0A%0A--Step%23%202%0A%0A--Create%20the%20user%20in%20the%20source%20database%20and%20grant%20dbowner%20permission%20to%20the%20database.%0A%0A%0A%0ACREATE%20USER%20%5Bloginname%5D%20FOR%20LOGIN%20%5Bloginname%5D%20WITH%20DEFAULT_SCHEMA%3D%5Bdbo%5D%3B%0A%0AGO%0A%0AALTER%20ROLE%20db_owner%20ADD%20MEMBER%20loginname%3B%0A%0AGO%0A%0A%0A%0A--Step%23%203%0A%0A--Capture%20the%20SID%20of%20the%20user%20%22loginname%22%20from%20master%20database%0A%0A%0A%0ASELECT%20%5Bsid%5D%20FROM%20sysusers%20WHERE%20%5Bname%5D%20%3D%20'loginname'%3B%0A%0A%0A%0A--Step%23%204%0A%0A--Connect%20to%20Destination%20server.%0A%0A--Create%20login%20and%20user%20in%20the%20master%20database%2C%20same%20as%20of%20the%20source%20server.%0A%0A%0A%0ACREATE%20LOGIN%20loginname%20WITH%20PASSWORD%20%3D%20'xxxxxxxxx'%2C%20SID%20%3D%20%5BSID%20of%20loginname%20login%20on%20source%20server%5D%3B%0A%0AGO%0A%0ACREATE%20USER%20%5Bloginname%5D%20FOR%20LOGIN%20%5Bloginname%5D%20WITH%20DEFAULT_SCHEMA%3D%5Bdbo%5D%3B%0A%0AGO%0A%0AALTER%20ROLE%20dbmanager%20ADD%20MEMBER%20loginname%3B%0A%0AGO%0A%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFrom%20the%20above%20script%20we%20have%20created%20a%20same%20login%20on%20the%20source%20and%20target%20server%20that%20we%20will%20use%20on%20the%20Automation%20account%20to%20execute%20the%20copy.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E2.%20Create%20Azure%20automation%20account%20and%20add%20runbook%20%3C%2FSTRONG%3E%3C%2FP%3E%0A%3COL%20class%3D%22lia-list-style-type-lower-alpha%22%3E%0A%3CLI%3E%3CSTRONG%3ECreate%20an%20Automation%20account%3C%2FSTRONG%3E%3A%20From%20the%20Azure%20Portal%20go%20to%20Automation%20account%20and%20create%20a%20new%20account.%20If%20you%20already%20have%20an%20Automation%20account%20you%20can%20skip%20this%20step%20and%20use%20your%20existing%20Automation%20account%20instead.%3CDIV%20id%3D%22tinyMceEditormohammad_belbaisi_20%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22mohammad_belbaisi_21-1635077353771.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F319551iF22B5A5CF712F8B0%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22mohammad_belbaisi_21-1635077353771.png%22%20alt%3D%22mohammad_belbaisi_21-1635077353771.png%22%20%2F%3E%3C%2FSPAN%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EImport%20SQLServer%20module%3C%2FSTRONG%3E%3A%20Go%20to%20the%20modules%20on%20your%20Automation%20account%2C%20click%20on%20modules%20gallery.%20From%20the%20search%20option%20type%20sqlserver%20and%20select%20this%20module.%20The%20next%20screen%20allows%20you%20to%20import%20the%20module.%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22mohammad_belbaisi_22-1635077409451.png%22%20style%3D%22width%3A%20607px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F319552iC8164F4189636B4B%2Fimage-dimensions%2F607x358%3Fv%3Dv2%22%20width%3D%22607%22%20height%3D%22358%22%20role%3D%22button%22%20title%3D%22mohammad_belbaisi_22-1635077409451.png%22%20alt%3D%22mohammad_belbaisi_22-1635077409451.png%22%20%2F%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22mohammad_belbaisi_23-1635077422784.png%22%20style%3D%22width%3A%20496px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F319553iE8739441804336A5%2Fimage-dimensions%2F496x298%3Fv%3Dv2%22%20width%3D%22496%22%20height%3D%22298%22%20role%3D%22button%22%20title%3D%22mohammad_belbaisi_23-1635077422784.png%22%20alt%3D%22mohammad_belbaisi_23-1635077422784.png%22%20%2F%3E%3C%2FSPAN%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%26nbsp%3B%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3ECreate%20Credential%20to%20access%20Azure%20SQL%20DB%3C%2FSTRONG%3E%3A%20Now%20we%20need%20to%20create%20a%20credential%20that%20we%20use%20to%20allow%20the%20automation%20account%20able%20to%20connect%20to%20the%20target%20SQL%20server%20and%20execute%20the%20copy%20operation.%20This%20credential%20must%20be%20the%20login%20that%20we%20created%20on%20using%20the%20above%20steps%20that%20have%20access%20to%20the%20source%20and%20destination%20servers%20.From%20the%20Automation%20account%20click%20on%20credential%20and%20provide%20a%20name%20for%20the%20credential%2C%20password%20and%20confirm%20the%20password.%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%26nbsp%3B%20%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22mohammad_belbaisi_0-1635078959934.png%22%20style%3D%22width%3A%20573px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F319561i5ABC0D2AF7C6451E%2Fimage-dimensions%2F573x335%3Fv%3Dv2%22%20width%3D%22573%22%20height%3D%22335%22%20role%3D%22button%22%20title%3D%22mohammad_belbaisi_0-1635078959934.png%22%20alt%3D%22mohammad_belbaisi_0-1635078959934.png%22%20%2F%3E%3C%2FSPAN%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3ECreate%20Variables%20for%20the%20Azure%20SQL%20DB%20server%20name%3C%2FSTRONG%3E%3A%20Create%20a%20variable%20that%20we%20will%20use%20to%20connect%20to%20the%20target%20SQL%20server%2C%20as%20the%20copy%20operation%20should%20be%20done%20from%20the%20target%20server.%20The%20value%20for%20this%20variable%20should%20be%20the%20FQDN%20of%20the%20target%20server%20(servername.database.windows.net)%3A%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22mohammad_belbaisi_1-1635078987468.png%22%20style%3D%22width%3A%20525px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F319562i4B72C0552E65876C%2Fimage-dimensions%2F525x244%3Fv%3Dv2%22%20width%3D%22525%22%20height%3D%22244%22%20role%3D%22button%22%20title%3D%22mohammad_belbaisi_1-1635078987468.png%22%20alt%3D%22mohammad_belbaisi_1-1635078987468.png%22%20%2F%3E%3C%2FSPAN%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3ECreate%20the%20run%20book%3C%2FSTRONG%3E%3A%20Click%20on%20the%20runbook%20from%20the%20Automation%20account.%20On%20the%20create%20runbook%20screen%20you%20have%20to%20type%20the%20name%20for%20this%20runbook%20and%20choose%20PowerShell%20as%20the%20runbook%20type.%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22mohammad_belbaisi_26-1635077593057.png%22%20style%3D%22width%3A%20608px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F319556iCA7494AF6E5ADA9A%2Fimage-dimensions%2F608x336%3Fv%3Dv2%22%20width%3D%22608%22%20height%3D%22336%22%20role%3D%22button%22%20title%3D%22mohammad_belbaisi_26-1635077593057.png%22%20alt%3D%22mohammad_belbaisi_26-1635077593057.png%22%20%2F%3E%3C%2FSPAN%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%3C%2FLI%3E%0A%3CLI%3EWhen%20the%20creation%20is%20completed%2C%20click%20on%20the%20created%20runbook%2C%20click%20on%20the%20edit%20and%20enter%20the%20below%20sample%20code%20(you%20can%20use%20the%20test%20pane%20to%20test%20the%20runbook%20and%20click%20save%20to%20save%20it).%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3E%20%24Cred%20%3D%20Get-AutomationPSCredential%20-Name%20%22name_of_created_credintial%22%0A%0A%20%24Server_Name%20%3D%20Get-AutomationVariable%20-Name%20%22name_of_created_variable%20%22%0A%20%0A%20%24Query%20%3D%20%22CREATE%20DATABASE%20copy13%20AS%20COPY%20OF%20%5Bsource_server_name%5D.%5Bsource_DB_name%5D%3B%22%0A%0A%20invoke-sqlcmd%20-ServerInstance%20%22%24Server_Name%22%20%20-Credential%20%24Cred%20-%20%20Query%20%22%24Query%22%20-Encrypt%0A%E2%80%8B%3C%2FCODE%3E%3C%2FPRE%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%26nbsp%3B%3C%2FLI%3E%0A%3CLI%3EIf%20you%20want%20to%20run%20this%20runbook%20on%20a%20schedule%2C%20you%20need%20to%20create%20a%20schedule%20and%20link%20this%20runbook%20to%20the%20created%20schedule.%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22mohammad_belbaisi_27-1635077715731.png%22%20style%3D%22width%3A%20577px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F319557i2F4E0AE149DA931C%2Fimage-dimensions%2F577x329%3Fv%3Dv2%22%20width%3D%22577%22%20height%3D%22329%22%20role%3D%22button%22%20title%3D%22mohammad_belbaisi_27-1635077715731.png%22%20alt%3D%22mohammad_belbaisi_27-1635077715731.png%22%20%2F%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22mohammad_belbaisi_28-1635077738587.png%22%20style%3D%22width%3A%20574px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F319558iFE480C3C295C7318%2Fimage-dimensions%2F574x280%3Fv%3Dv2%22%20width%3D%22574%22%20height%3D%22280%22%20role%3D%22button%22%20title%3D%22mohammad_belbaisi_28-1635077738587.png%22%20alt%3D%22mohammad_belbaisi_28-1635077738587.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2880468%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20copy%20an%20Azure%20SQL%20Database%20to%20a%20different%20server%20or%20subscription%20using%20Azure%20Automation%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2880468%22%20slang%3D%22en-US%22%3E%3CP%3EWow%2C%20that%20is%20great%2C%20thx!%20gonna%20use%20it%20for%20sure!%3C%2FP%3E%3C%2FLINGO-BODY%3E

Version history
Last update:

‎Oct 24 2021 05:41 AM

Updated by:

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK