Database migration from Managed Instance to SQL Server with transactional replication

Published 05-14-2021 09:51 AM 1,944 Views
Microsoft

Introduction

 

When we talk about large databases with hundreds of GBs and significant number of database objects, when transactional consistency is required and migration needs to be done in an online fashion with short down time, Transactional replication is currently the most robust and advised way to perform migration from Azure SQL Managed Instance to SQL Server whether it’s hosted on IaaS or on-premises.

 

Transactional replication has been around for many years, and there is lots of documentation and other kind of resources where you can learn more about it. This blog post will focus on using transactional replication to migrate a database from Managed Instance to SQL Server.

 

Transactional replication overview

 

If you haven’t had experience with Transactional replication so far, here is a brief overview of this technology from database migration point of view. There will be three subjects that will participate in the replication process:

  • Publisher is the source of the replication, and for us this will be Managed Instance.
  • Distributor is coordinating replication, and this can be either Managed Instance or SQL Server.
  • Subscriber is replication target, and this will be SQL Server, as we migrate to SQL Server.

TranRepl - diagram.png

Transactional replication is based on three SQL Agent jobs:

  • Snapshot Agent (gets the initial database snapshot).
  • Log Reader Agent (tracks source database changes after the snapshot is taken).
  • Distribution Agent (applies the database changes to target).

Replication can be done in Push or Pull model. Push means that distributor is on the Publisher side, pushing the replication towards Subscriber. In Pull model, distributor is on the Subscriber side, pulling the replication from the Publisher. Each approach has its pros and cons. Distributor needs some resources to run, so it will have some performance impact to the side where it is deployed. Having distributor on a Publisher side means that replication is delivered continuously. If it is on the Subscriber side then the changes are delivered periodically, per schedule. In rare cases when both source and target don’t have enough resources to run the distributor, third option is available – to host distributor on a third server, and it can be either Managed Instance or SQL Server. In this case changes are also delivered periodically.

 

Transactional replication setup

 

In this section we will setup a transactional replication for the purpose of migrating database from Managed Instance to SQL Server 2019 hosted on Azure VM. Managed Instance will be both Publisher and Distributor, while SQL Server will be Subscriber. This topology will enable us to perform online migration, as changes from publisher to subscriber are delivered continuously.

Prerequisites

 

For replication to work, there must be a network connectivity between Managed Instance and SQL Server. In our case this is ensured by having both servers on the same Virtual Network. If that were not the case then VNet peering setup would be required.

 

Outbound TCP port 445 needs to be open for transactional replication, so in case you have NSG make sure this port is allowed. Allowing this port will enable Managed Instance to access Azure Storage account, which will be covered a bit later. To allow the port, go to the virtual network of your Managed Instance and identify the security group name.

TranRepl - nsg name 01 .png

 

Then find that Security group in the Azure portal, and in its Settings section open Outbound security rules. Click Add and add outbound security rule for port 445.

TranRepl - 02 port 445.png

 

Transactional replication will require a storage account, so if you don’t have one yet, use the Azure Portal to create it. Alternatively, you can use one of your existing storage accounts. Within the Storage account, create a File Share with quota of 20 GiB. 

Go to the File share Properties and copy the storage URL because this value will be needed in the following T-SQL script.

TranRepl - 03 storage account file share.png

Also, go to the Settings of the Storage account, to Access keys section and copy Connection string, that will also be needed for the T-SQL script.

TranRepl - 04 storage account connection string.png

Once the prerequisites are met, we will setup the transactional replication by creating distribution, publication and finally a subscription.

 

Configure replication distribution

Storage URL and connection string we’ve already copied will be needed in the following T-SQL script.

 

 

DECLARE @distribution_db_name NVARCHAR(50) = N'distribution'

-- Assign the storage connection string you got from the Azure Portal.
DECLARE @storage_conn_string NVARCHAR(MAX) = N'DefaultEndpointsProtocol=https;AccountName=rmstoragesp01;AccountKey=asdf000000000000000000000000000000000000000000000000000000000000000000000000000000000a==;EndpointSuffix=core.windows.net'

-- Assign the storage URL you got from the Azure Portal.
DECLARE @storage_url NVARCHAR(MAX) = N'https://rmstoragesp01.file.core.windows.net/rm-transactinoal-replication-sp-01'

-- Adjust storage URL format.
DECLARE @working_dir NVARCHAR(MAX) = SUBSTRING(@storage_url, 9, LEN(@storage_url) - 8)
SET @working_dir = '\\' + REPLACE(@working_dir, '/', '\')
PRINT @working_dir

-- With following three commands you will set distributor server, distributor database name and configure publisher to use a specified distribution database.
--
EXEC sp_adddistributor @distributor = @@SERVERNAME

EXEC sp_adddistributiondb @database = @distribution_db_name

EXEC sp_adddistpublisher @publisher = @@SERVERNAME,
     @distribution_db = @distribution_db_name,
     @security_mode = 0,
     @login = N'login_name',
     @password = N'password',
     @working_directory = @working_dir,
     @storage_connection_string = @storage_conn_string

 

 

Once this is set you can run following three commands to verify the settings. 

 

 

EXEC sp_helpdistributor
GO
EXEC sp_helpdistributiondb
GO
EXEC sp_helpdistpublisher 
GO

 

 

If you want to drop any of these settings use stored procedures sp_dropdistpublisher, sp_dropdistributiondb and sp_dropdistributor, or in case you need to reset the settings entirely you can run EXEC sp_dropdistributor @no_checks = 1, @ignore_distributor = 1.

 

Configure replication publication

 

To create publication, use SSMS, connect to the Managed Instance with the private endpoint (with public endpoint publication and replication will not work). In the Object Explorer go to Replication, Local Publications and finally New Publication as on the screen shoot below.

TranRepl - 05 new pub.png

 

This will open a New Publication Wizard. Click Next, select the database you want to publish and again click Next.

As on the screenshot below, for Publication Type chose Transactional publication and click Next. Then on the Articles window, choose objects you want to replicate. In this example we will chose all Tables, Stored Procedures, Views, Indexed Views and only ufnLeadingZeros from User Defined Functions. Once this is selected, click on the Article properties button.

TranRepl - 06 pub type and articles.png

On Article Properties, select Set Properties of All Table Articles, and then in the menu find properties Copy full text indexes and Copy XML indexes and set their values to True.

TranRepl - 07 article properties.png

 

Wizard will warn about potential problems on the Article Issues window. We will ignore these and click Next. On the Filter Table Rows window we don’t add any filters, just click Next.

On Snapshot Agent windows check “Create a snapshot immediately…” and click Next. On Agent Security windows click on Security Settings to provide credentials for both Snapshot Agent and connection to the Publisher.

TranRepl - 08 securitypng.png

 

On the Wizard Actions window check Create the Publication and click Next.

Finally in the Complete the Wizard, provide the name for the publication and click Finish. Wizard will show progress and once the process is done you should see a Success sign with 0 Errors and 0 Warnings. Click the Close button. With this the publication is successfully created.

TranRepl - 09 success.png

 

To check the status of the publication, refresh the Local Publications in SSMS and you will find newly created publication. From the context menu of the newly created Publication, click Launch Replication Monitor and find the publisher that has been just created. On the Agents tab you can monitor the progress of the Snapshot Agent and Log Reader Agent. Time needed for a snapshot to be created varies and depends on the size of data that’s participating in the replication. Once Snapshot Agent’s Last Action is “[100%] A snapshot of x article(s) was generated.” the publication is ready.

TranRepl - 10 monitor.png

 

Configure replication subscription

 

Now when distribution and publication are configured, we need to create a subscription as the last piece of transactional replication setup. In the context menu of the Publication we’ve created, we are going to click on New Subscriptions. New Subscription Wizard will open. Let’s follow its steps.

Tran repl - 200 Sub.png

 

On the Publication window, select the Publisher, database and the publication and click Next. On the Distribution Agent Location select option to Run all agents at the Distributor and click Next.

Tran repl - 201 select publication.png

 

On the Subscriber window, click on Add Subscriber and then Add SQL Server Subscriber. Then connect to the SQL Server that will be the Subscriber. This SQL Server will be the target for the database migration. Use the server’s local IP address for this connection.

Tran repl - 202 Subscribers.png

 

For the newly added Subscriber, for the Subscription Database chose New database option from the drop down menu, and in the New Database window, provide the Database name. This will be the name of the target database for the migration. Then click OK and then Next.

Tran repl - 203 new database.png

 

On the Distribution Agent Security window, click on the button with three dots, and in Distribution Agent Security window provide login and password for Distributor and Subscriber.

Tran repl - 204 dist agent sec.png

 

Follow through the wizard. On Synchronization Schedule leave the Agent Schedule set to Run continuously. This will enable continuous data flow from the source database to the destination and help with the online migration. On the Initialize Subscription window leave Initialize When set to Immediately. Then on the next window, Wizard Actions, leave Create the subscription(s) checked and click Next. On the Complete the Wizard click Next and wait for the Success status on the final Creating Subscription(s) step.

Once this is done, from the context menu of the newly created subscription, open the View Synchronization Status. You will see its progress and eventually all transactions will be replicated.

Tran repl - 205 view sync stat.png

 

From the context menu of the Publication click Launch Replication Monitor.

Tran repl - 206 Launch replication monitor.png

 

Here in the Replication Monitor, in Agents tab you will see the progress of the Snapshot Agent and Log Reader Agent. On Snapshot agent reaches 100%, database is replicated, and ongoing transactions will be replicated as well.

Tran repl - 207 replication monitor.png

 

Finally, connect to the SQL Server that is Subscriber and you will see that database is replicated.

Tran repl - 208 target database.png

 

With this you source database is migrated from Managed Instance to SQL Server. If the workload on the source database is still running, changes it might make will be replicated to the target database. Once you want to finalize the migration, you can set the source database to read-only mode, wait for the replication to complete (in the Replication monitor, Log Reader Agent's last action will be "No replicated transactions are available") and stop the transactional replication. This is done by disabling the corresponding SQL Agent jobs and deleting subscriber, distributor and publisher.

 

Transactional replication limitations and workarounds

 

Managed Instance documentation contains list of know errors related to transactional replication.

In case you want to know more, take a look at the official Managed Instance transactional replication documentation.

 

Primary key requirement

 

All tables that participate in transactional replication need to have primary key. If a table does not have one, you will have to create it. Alternatively, you can create materialized view over the table that's missing primary key, and replicate that materialized view. Once the data is in the target database, you can create the missing table and insert data from the replicated materialized view to the newly created table.

 

Conclusion

 

Transactional replication offers performant and robust way to migrate database from Managed Instance to SQL Server, with some limitations mentioned in this blog. For more information on the migration options, see Moving databases from Azure SQL Managed Instance to SQL Server.

2 Comments
Senior Member

Thank you for the article @sasapopo , I liked all the steps with all the pictures. 

While Transactional Replication is a valid option for migrating from Managed Instance to SQL Server would you suggesting it the other way around, from SQL Server to Managed Instance? 

 

...after a rigorous compatibility assessment from the DMA...

Microsoft

Hi @fmantovani! Thanks for the feedback!

 

When it comes to migration to Managed Instance it is always migration to a higher version of SQL hence there are more available options. Currently Database Migration Service and Log Replay Service and probably most suitable for online migration. Transactional replication is also available. This article covers the topic in more details: SQL Server to SQL Managed Instance: Migration overview - Azure SQL | Microsoft Docs.

 

Let me know if you have more questions!

%3CLINGO-SUB%20id%3D%22lingo-sub-2382978%22%20slang%3D%22en-US%22%3ERe%3A%20Database%20migration%20from%20Managed%20Instance%20to%20SQL%20Server%20with%20transactional%20replication%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2382978%22%20slang%3D%22en-US%22%3E%3CP%3EThank%20you%20for%20the%20article%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F749038%22%20target%3D%22_blank%22%3E%40sasapopo%3C%2FA%3E%26nbsp%3B%2C%20I%20liked%20all%20the%20steps%20with%20all%20the%20pictures.%26nbsp%3B%3C%2FP%3E%3CP%3EWhile%20Transactional%20Replication%20is%20a%20valid%20option%20for%20migrating%20from%20Managed%20Instance%20to%20SQL%20Server%20would%20you%20suggesting%20it%20the%20other%20way%20around%2C%20from%20SQL%20Server%20to%20Managed%20Instance%3F%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E...after%20a%20rigorous%20compatibility%20assessment%20from%20the%20DMA...%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2394911%22%20slang%3D%22en-US%22%3ERe%3A%20Database%20migration%20from%20Managed%20Instance%20to%20SQL%20Server%20with%20transactional%20replication%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2394911%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1020378%22%20target%3D%22_blank%22%3E%40fmantovani%3C%2FA%3E!%20Thanks%20for%20the%20feedback!%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhen%20it%20comes%20to%20migration%20to%20Managed%20Instance%20it%20is%20always%20migration%20to%20a%20higher%20version%20of%20SQL%20hence%20there%20are%20more%20available%20options.%20Currently%20Database%20Migration%20Service%20and%20Log%20Replay%20Service%20and%20probably%20most%20suitable%20for%20online%20migration.%20Transactional%20replication%20is%20also%20available.%20This%20article%20covers%20the%20topic%20in%20more%20details%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fazure-sql%2Fmigration-guides%2Fmanaged-instance%2Fsql-server-to-managed-instance-overview%23migration-tools%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3ESQL%20Server%20to%20SQL%20Managed%20Instance%3A%20Migration%20overview%20-%20Azure%20SQL%20%7C%20Microsoft%20Docs%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ELet%20me%20know%20if%20you%20have%20more%20questions!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2344070%22%20slang%3D%22en-US%22%3EDatabase%20migration%20from%20Managed%20Instance%20to%20SQL%20Server%20with%20transactional%20replication%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2344070%22%20slang%3D%22en-US%22%3E%3CH2%20id%3D%22toc-hId--466932906%22%20id%3D%22toc-hId--467890936%22%3EIntroduction%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhen%20we%20talk%20about%20large%20databases%20with%20hundreds%20of%20GBs%20and%20significant%20number%20of%20database%20objects%2C%20when%20transactional%20consistency%20is%20required%20and%20migration%20needs%20to%20be%20done%20in%20an%20online%20fashion%20with%20short%20down%20time%2C%20Transactional%20replication%20is%20currently%20the%20most%20robust%20and%20advised%20way%20to%20perform%20migration%20from%20Azure%20SQL%20Managed%20Instance%20to%20SQL%20Server%20whether%20it%E2%80%99s%20hosted%20on%20IaaS%20or%20on-premises.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETransactional%20replication%20has%20been%20around%20for%20many%20years%2C%20and%20there%20is%20lots%20of%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fazure-sql%2Fmanaged-instance%2Freplication-transactional-overview%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Edocumentation%3C%2FA%3E%20and%20other%20kind%20of%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fazure-sql%2Fmanaged-instance%2Freplication-two-instances-and-sql-server-configure-tutorial%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Eresources%3C%2FA%3E%20where%20you%20can%20learn%20more%20about%20it.%20This%20blog%20post%20will%20focus%20on%20using%20transactional%20replication%20to%20migrate%20a%20database%20from%20Managed%20Instance%20to%20SQL%20Server.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-2020579927%22%20id%3D%22toc-hId-2019621897%22%3ETransactional%20replication%20overview%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20haven%E2%80%99t%20had%20experience%20with%20Transactional%20replication%20so%20far%2C%20here%20is%20a%20brief%20overview%20of%20this%20technology%20from%20database%20migration%20point%20of%20view.%20There%20will%20be%20three%20subjects%20that%20will%20participate%20in%20the%20replication%20process%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EPublisher%20is%20the%3CSTRONG%3E%20source%3C%2FSTRONG%3E%20of%20the%20replication%2C%20and%20for%20us%20this%20will%20be%20Managed%20Instance.%3C%2FLI%3E%0A%3CLI%3EDistributor%20is%3CSTRONG%3E%20coordinating%3C%2FSTRONG%3E%20replication%2C%20and%20this%20can%20be%20either%20Managed%20Instance%20or%20SQL%20Server.%3C%2FLI%3E%0A%3CLI%3ESubscriber%20is%20replication%3CSTRONG%3E%20target%3C%2FSTRONG%3E%2C%20and%20this%20will%20be%20SQL%20Server%2C%20as%20we%20migrate%20to%20SQL%20Server.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22TranRepl%20-%20diagram.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F279903i8D4CF8118DCEC456%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22TranRepl%20-%20diagram.png%22%20alt%3D%22TranRepl%20-%20diagram.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3ETransactional%20replication%20is%20based%20on%20three%20SQL%20Agent%20jobs%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3ESnapshot%20Agent%20(gets%20the%20initial%20database%20snapshot).%3C%2FLI%3E%0A%3CLI%3ELog%20Reader%20Agent%20(tracks%20source%20database%20changes%20after%20the%20snapshot%20is%20taken).%3C%2FLI%3E%0A%3CLI%3EDistribution%20Agent%20(applies%20the%20database%20changes%20to%20target).%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EReplication%20can%20be%20done%20in%20Push%20or%20Pull%20model.%20Push%20means%20that%20distributor%20is%20on%20the%20Publisher%20side%2C%20pushing%20the%20replication%20towards%20Subscriber.%20In%20Pull%20model%2C%20distributor%20is%20on%20the%20Subscriber%20side%2C%20pulling%20the%20replication%20from%20the%20Publisher.%20Each%20approach%20has%20its%20pros%20and%20cons.%20Distributor%20needs%20some%20resources%20to%20run%2C%20so%20it%20will%20have%20some%20performance%20impact%20to%20the%20side%20where%20it%20is%20deployed.%20%3CSTRONG%3EHaving%20distributor%20on%20a%20Publisher%20side%20means%20that%20replication%20is%20delivered%20continuously.%3C%2FSTRONG%3E%20If%20it%20is%20on%20the%20Subscriber%20side%20then%20the%20changes%20are%20delivered%20periodically%2C%20per%20schedule.%20In%20rare%20cases%20when%20both%20source%20and%20target%20don%E2%80%99t%20have%20enough%20resources%20to%20run%20the%20distributor%2C%20third%20option%20is%20available%20%E2%80%93%20to%20host%20distributor%20on%20a%20third%20server%2C%20and%20it%20can%20be%20either%20Managed%20Instance%20or%20SQL%20Server.%20In%20this%20case%20changes%20are%20also%20delivered%20periodically.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-213125464%22%20id%3D%22toc-hId-212167434%22%3ETransactional%20replication%20setup%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20this%20section%20we%20will%20setup%20a%20transactional%20replication%20for%20the%20purpose%20of%20migrating%20database%20from%20Managed%20Instance%20to%20SQL%20Server%202019%20hosted%20on%20Azure%20VM.%20Managed%20Instance%20will%20be%20both%20Publisher%20and%20Distributor%2C%20while%20SQL%20Server%20will%20be%20Subscriber.%20This%20topology%20will%20enable%20us%20to%20perform%20online%20migration%2C%20as%20changes%20from%20publisher%20to%20subscriber%20are%20delivered%20continuously.%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-903686938%22%20id%3D%22toc-hId-902728908%22%3EPrerequisites%3C%2FH3%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFor%20replication%20to%20work%2C%20there%20must%20be%20a%20network%20connectivity%20between%20Managed%20Instance%20and%20SQL%20Server.%20In%20our%20case%20this%20is%20ensured%20by%20having%20both%20servers%20on%20the%20same%20Virtual%20Network.%20If%20that%20were%20not%20the%20case%20then%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fvirtual-network%2Fvirtual-network-manage-peering%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EVNet%20peering%20setup%3C%2FA%3E%20would%20be%20required.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOutbound%20TCP%20port%20445%20needs%20to%20be%20open%20for%20transactional%20replication%2C%20so%20in%20case%20you%20have%20NSG%20make%20sure%20this%20port%20is%20allowed.%20Allowing%20this%20port%20will%20enable%20Managed%20Instance%20to%20access%20Azure%20Storage%20account%2C%20which%20will%20be%20covered%20a%20bit%20later.%20To%20allow%20the%20port%2C%20go%20to%20the%20virtual%20network%20of%20your%20Managed%20Instance%20and%20identify%20the%20security%20group%20name.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22TranRepl%20-%20nsg%20name%2001%20.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F279905i41F37406DCDDDC3E%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22TranRepl%20-%20nsg%20name%2001%20.png%22%20alt%3D%22TranRepl%20-%20nsg%20name%2001%20.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThen%20find%20that%20Security%20group%20in%20the%20Azure%20portal%2C%20and%20in%20its%20Settings%20section%20open%20Outbound%20security%20rules.%20Click%20Add%20and%20add%20outbound%20security%20rule%20for%20port%20445.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22TranRepl%20-%2002%20port%20445.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F279908iCED43D3EA7C118B4%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22TranRepl%20-%2002%20port%20445.png%22%20alt%3D%22TranRepl%20-%2002%20port%20445.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETransactional%20replication%20will%20require%20a%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fstorage%2Fcommon%2Fstorage-introduction%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Estorage%20account%3C%2FA%3E%2C%20so%20if%20you%20don%E2%80%99t%20have%20one%20yet%2C%20use%20the%20Azure%20Portal%20to%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fstorage%2Fcommon%2Fstorage-account-create%3Ftabs%3Dazure-portal%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ecreate%20%3C%2FA%3E%3CSPAN%3Eit%3C%2FSPAN%3E.%20Alternatively%2C%20you%20can%20use%20one%20of%20your%20existing%20storage%20accounts.%26nbsp%3BWithin%20the%20Storage%20account%2C%20create%20a%20File%20Share%20with%20quota%20of%2020%20GiB.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EGo%20to%20the%20File%20share%20Properties%20and%20copy%20the%20storage%20%3CSTRONG%3EURL%3C%2FSTRONG%3E%20because%20this%20value%20will%20be%20needed%20in%20the%20following%20T-SQL%20script.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22TranRepl%20-%2003%20storage%20account%20file%20share.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F279910i536FDD42745BA723%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22TranRepl%20-%2003%20storage%20account%20file%20share.png%22%20alt%3D%22TranRepl%20-%2003%20storage%20account%20file%20share.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EAlso%2C%20go%20to%20the%20Settings%20of%20the%20Storage%20account%2C%20to%20Access%20keys%20section%20and%20%3CSTRONG%3Ecopy%20Connection%20string%3C%2FSTRONG%3E%2C%20that%20will%20also%20be%20needed%20for%20the%20T-SQL%20script.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22TranRepl%20-%2004%20storage%20account%20connection%20string.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F279911i48563A4226C89E09%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22TranRepl%20-%2004%20storage%20account%20connection%20string.png%22%20alt%3D%22TranRepl%20-%2004%20storage%20account%20connection%20string.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EOnce%20the%20prerequisites%20are%20met%2C%20we%20will%20setup%20the%20transactional%20replication%20by%20creating%20distribution%2C%20publication%20and%20finally%20a%20subscription.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--903767525%22%20id%3D%22toc-hId--904725555%22%3EConfigure%20replication%20distribution%3C%2FH3%3E%0A%3CP%3EStorage%20URL%20and%20connection%20string%20we%E2%80%99ve%20already%20copied%20will%20be%20needed%20in%20the%20following%20T-SQL%20script.%3C%2FP%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-markup%22%3E%3CCODE%3EDECLARE%20%40distribution_db_name%20NVARCHAR(50)%20%3D%20N'distribution'%0A%0A--%20Assign%20the%20storage%20connection%20string%20you%20got%20from%20the%20Azure%20Portal.%0ADECLARE%20%40storage_conn_string%20NVARCHAR(MAX)%20%3D%20N'DefaultEndpointsProtocol%3Dhttps%3BAccountName%3Drmstoragesp01%3BAccountKey%3Dasdf000000000000000000000000000000000000000000000000000000000000000000000000000000000a%3D%3D%3BEndpointSuffix%3Dcore.windows.net'%0A%0A--%20Assign%20the%20storage%20URL%20you%20got%20from%20the%20Azure%20Portal.%0ADECLARE%20%40storage_url%20NVARCHAR(MAX)%20%3D%20N'https%3A%2F%2Frmstoragesp01.file.core.windows.net%2Frm-transactinoal-replication-sp-01'%0A%0A--%20Adjust%20storage%20URL%20format.%0ADECLARE%20%40working_dir%20NVARCHAR(MAX)%20%3D%20SUBSTRING(%40storage_url%2C%209%2C%20LEN(%40storage_url)%20-%208)%0ASET%20%40working_dir%20%3D%20'%5C%5C'%20%2B%20REPLACE(%40working_dir%2C%20'%2F'%2C%20'%5C')%0APRINT%20%40working_dir%0A%0A--%20With%20following%20three%20commands%20you%20will%20set%20distributor%20server%2C%20distributor%20database%20name%20and%20configure%20publisher%20to%20use%20a%20specified%20distribution%20database.%0A--%0AEXEC%20sp_adddistributor%20%40distributor%20%3D%20%40%40SERVERNAME%0A%0AEXEC%20sp_adddistributiondb%20%40database%20%3D%20%40distribution_db_name%0A%0AEXEC%20sp_adddistpublisher%20%40publisher%20%3D%20%40%40SERVERNAME%2C%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%40distribution_db%20%3D%20%40distribution_db_name%2C%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%40security_mode%20%3D%200%2C%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%40login%20%3D%20N'login_name'%2C%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%40password%20%3D%20N'password'%2C%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%40working_directory%20%3D%20%40working_dir%2C%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%40storage_connection_string%20%3D%20%40storage_conn_string%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOnce%20this%20is%20set%20you%20can%20run%20following%20three%20commands%20to%20verify%20the%20settings.%26nbsp%3B%3C%2FP%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-markup%22%3E%3CCODE%3EEXEC%20sp_helpdistributor%0AGO%0AEXEC%20sp_helpdistributiondb%0AGO%0AEXEC%20sp_helpdistpublisher%20%0AGO%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%3EIf%20you%20want%20to%20drop%20any%20of%20these%20settings%20use%20stored%20procedures%20sp_dropdistpublisher%2C%20sp_dropdistributiondb%20and%20sp_dropdistributor%2C%20or%20in%20case%20you%20need%20to%20reset%20the%20settings%20entirely%20you%20can%20run%20EXEC%20sp_dropdistributor%20%40no_checks%20%3D%201%2C%20%40ignore_distributor%20%3D%201.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-1583745308%22%20id%3D%22toc-hId-1582787278%22%3EConfigure%20replication%20publication%3C%2FH3%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETo%20create%20publication%2C%20use%20SSMS%2C%20connect%20to%20the%20Managed%20Instance%20with%20the%20%3CSTRONG%3Eprivate%3C%2FSTRONG%3E%20endpoint%20(with%20public%20endpoint%20publication%20and%20replication%20will%20not%20work).%20In%20the%20Object%20Explorer%20go%20to%20Replication%2C%20Local%20Publications%20and%20finally%20New%20Publication%20as%20on%20the%20screen%20shoot%20below.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22TranRepl%20-%2005%20new%20pub.png%22%20style%3D%22width%3A%20298px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F279958i70C42A8190F17A4A%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22TranRepl%20-%2005%20new%20pub.png%22%20alt%3D%22TranRepl%20-%2005%20new%20pub.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20will%20open%20a%20New%20Publication%20Wizard.%20Click%20Next%2C%20select%20the%20database%20you%20want%20to%20publish%20and%20again%20click%20Next.%3C%2FP%3E%0A%3CP%3EAs%20on%20the%20screenshot%20below%2C%20for%20Publication%20Type%20chose%20Transactional%20publication%20and%20click%20Next.%20Then%20on%20the%20Articles%20window%2C%20choose%20objects%20you%20want%20to%20replicate.%20In%20this%20example%20we%20will%20chose%20all%20Tables%2C%20Stored%20Procedures%2C%20Views%2C%20Indexed%20Views%20and%20only%20ufnLeadingZeros%20from%20User%20Defined%20Functions.%20Once%20this%20is%20selected%2C%20click%20on%20the%20Article%20properties%20button.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22TranRepl%20-%2006%20pub%20type%20and%20articles.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F279961iE88724F88C7DC899%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22TranRepl%20-%2006%20pub%20type%20and%20articles.png%22%20alt%3D%22TranRepl%20-%2006%20pub%20type%20and%20articles.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EOn%20Article%20Properties%2C%20select%20Set%20Properties%20of%20All%20Table%20Articles%2C%20and%20then%20in%20the%20menu%20find%20properties%20Copy%20full%20text%20indexes%20and%20Copy%20XML%20indexes%20and%20set%20their%20values%20to%20True.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22TranRepl%20-%2007%20article%20properties.png%22%20style%3D%22width%3A%20939px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F279962iBA930A6ACB061F91%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22TranRepl%20-%2007%20article%20properties.png%22%20alt%3D%22TranRepl%20-%2007%20article%20properties.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWizard%20will%20warn%20about%20potential%20problems%20on%20the%20%3CSTRONG%3EArticle%20Issues%3C%2FSTRONG%3E%20window.%20We%20will%20ignore%20these%20and%20click%20Next.%20On%20the%20%3CSTRONG%3EFilter%20Table%20Rows%3C%2FSTRONG%3E%20window%20we%20don%E2%80%99t%20add%20any%20filters%2C%20just%20click%20Next.%3C%2FP%3E%0A%3CP%3EOn%20%3CSTRONG%3ESnapshot%20Agent%3C%2FSTRONG%3E%20windows%20check%20%E2%80%9CCreate%20a%20snapshot%20immediately%E2%80%A6%E2%80%9D%20and%20click%20Next.%20On%20%3CSTRONG%3EAgent%20Security%3C%2FSTRONG%3E%20windows%20click%20on%20Security%20Settings%20to%20provide%20credentials%20for%20both%20Snapshot%20Agent%20and%20connection%20to%20the%20Publisher.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22TranRepl%20-%2008%20securitypng.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F279967iD2946881F7FD502F%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22TranRepl%20-%2008%20securitypng.png%22%20alt%3D%22TranRepl%20-%2008%20securitypng.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOn%20the%20%3CSTRONG%3EWizard%20Actions%3C%2FSTRONG%3E%20window%20check%20%3CSTRONG%3ECreate%20the%20Publication%20%3C%2FSTRONG%3Eand%20click%20Next.%3C%2FP%3E%0A%3CP%3EFinally%20in%20the%20%3CSTRONG%3EComplete%20the%20Wizard%3C%2FSTRONG%3E%2C%20provide%20the%20name%20for%20the%20publication%20and%20click%20Finish.%20Wizard%20will%20show%20progress%20and%20once%20the%20process%20is%20done%20you%20should%20see%20a%20Success%20sign%20with%200%20Errors%20and%200%20Warnings.%26nbsp%3BClick%20the%20Close%20button.%20With%20this%20the%20publication%20is%20successfully%20created.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22TranRepl%20-%2009%20success.png%22%20style%3D%22width%3A%20944px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F279970iD1E8D8564C187D6A%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22TranRepl%20-%2009%20success.png%22%20alt%3D%22TranRepl%20-%2009%20success.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETo%20check%20the%20status%20of%20the%20publication%2C%20refresh%20the%20Local%20Publications%20in%20SSMS%20and%20you%20will%20find%20newly%20created%20publication.%20From%20the%20context%20menu%20of%20the%20newly%20created%20Publication%2C%20click%20Launch%20Replication%20Monitor%20and%20find%20the%20publisher%20that%20has%20been%20just%20created.%20On%20the%20Agents%20tab%20you%20can%20monitor%20the%20progress%20of%20the%20Snapshot%20Agent%20and%20Log%20Reader%20Agent.%20Time%20needed%20for%20a%20snapshot%20to%20be%20created%20varies%20and%20depends%20on%20the%20size%20of%20data%20that%E2%80%99s%20participating%20in%20the%20replication.%26nbsp%3BOnce%20Snapshot%20Agent%E2%80%99s%20Last%20Action%20is%20%E2%80%9C%5B100%25%5D%20A%20snapshot%20of%20x%20article(s)%20was%20generated.%E2%80%9D%20the%20publication%20is%20ready.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22TranRepl%20-%2010%20monitor.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F279973i4AD526A890F77132%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22TranRepl%20-%2010%20monitor.png%22%20alt%3D%22TranRepl%20-%2010%20monitor.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--223709155%22%20id%3D%22toc-hId--224667185%22%3EConfigure%20replication%20subscription%3C%2FH3%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENow%20when%20distribution%20and%20publication%20are%20configured%2C%20we%20need%20to%20create%20a%20subscription%20as%20the%20last%20piece%20of%20transactional%20replication%20setup.%20In%20the%20context%20menu%20of%20the%20Publication%20we%E2%80%99ve%20created%2C%20we%20are%20going%20to%20click%20on%20New%20Subscriptions.%20New%20Subscription%20Wizard%20will%20open.%20Let%E2%80%99s%20follow%20its%20steps.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Tran%20repl%20-%20200%20Sub.png%22%20style%3D%22width%3A%20365px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F280128i329C7238774E0E8D%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Tran%20repl%20-%20200%20Sub.png%22%20alt%3D%22Tran%20repl%20-%20200%20Sub.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOn%20the%20%3CSTRONG%3EPublication%3C%2FSTRONG%3E%20window%2C%20select%20the%20%3CSTRONG%3EPublisher%3C%2FSTRONG%3E%2C%20database%20and%20the%20publication%20and%20click%20Next.%20On%20the%20%3CSTRONG%3EDistribution%20Agent%20Location%3C%2FSTRONG%3E%20select%20option%20to%20%3CSTRONG%3ERun%20all%20agents%20at%20the%20Distributor%3C%2FSTRONG%3E%20and%20click%20Next.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Tran%20repl%20-%20201%20select%20publication.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F280252iDD42380044755496%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Tran%20repl%20-%20201%20select%20publication.png%22%20alt%3D%22Tran%20repl%20-%20201%20select%20publication.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOn%20the%20Subscriber%20window%2C%20click%20on%20%3CSTRONG%3EAdd%20Subscriber%3C%2FSTRONG%3E%20and%20then%20%3CSTRONG%3EAdd%20SQL%20Server%20Subscriber%3C%2FSTRONG%3E.%20Then%20connect%20to%20the%20SQL%20Server%20that%20will%20be%20the%20Subscriber.%20This%20SQL%20Server%20will%20be%20the%20target%20for%20the%20database%20migration.%20Use%20the%20server%E2%80%99s%20local%20IP%20address%20for%20this%20connection.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Tran%20repl%20-%20202%20Subscribers.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F280130iADF5C16244E23227%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Tran%20repl%20-%20202%20Subscribers.png%22%20alt%3D%22Tran%20repl%20-%20202%20Subscribers.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFor%20the%20newly%20added%20%3CSTRONG%3ESubscriber%3C%2FSTRONG%3E%2C%20for%20the%20%3CSTRONG%3ESubscription%20Database%3C%2FSTRONG%3E%20chose%20%3CSTRONG%3ENew%20database%3C%2FSTRONG%3E%20option%20from%20the%20drop%20down%20menu%2C%20and%20in%20the%20%3CSTRONG%3ENew%20Database%3C%2FSTRONG%3E%20window%2C%20provide%20the%20Database%20name.%20This%20will%20be%20the%20name%20of%20the%20target%20database%20for%20the%20migration.%20Then%20click%20OK%20and%20then%20Next.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Tran%20repl%20-%20203%20new%20database.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F280131iB5ED99467038DE2F%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Tran%20repl%20-%20203%20new%20database.png%22%20alt%3D%22Tran%20repl%20-%20203%20new%20database.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOn%20the%20%3CSTRONG%3EDistribution%20Agent%20Security%3C%2FSTRONG%3E%20window%2C%20click%20on%20the%20button%20with%20three%20dots%2C%20and%20in%20%3CSTRONG%3EDistribution%20Agent%20Security%3C%2FSTRONG%3E%20window%20provide%20login%20and%20password%20for%20Distributor%20and%20Subscriber.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Tran%20repl%20-%20204%20dist%20agent%20sec.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F280133i43E057FFD487359B%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Tran%20repl%20-%20204%20dist%20agent%20sec.png%22%20alt%3D%22Tran%20repl%20-%20204%20dist%20agent%20sec.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFollow%20through%20the%20wizard.%20On%20%3CSTRONG%3ESynchronization%20Schedule%3C%2FSTRONG%3E%20leave%20the%20%3CSTRONG%3EAgent%20Schedule%3C%2FSTRONG%3E%20set%20to%20%3CSTRONG%3ERun%20continuously%3C%2FSTRONG%3E.%20This%20will%20enable%20continuous%20data%20flow%20from%20the%20source%20database%20to%20the%20destination%20and%20help%20with%20the%20online%20migration.%20On%20the%20%3CSTRONG%3EInitialize%20Subscription%3C%2FSTRONG%3E%20window%20leave%20%3CSTRONG%3EInitialize%20When%3C%2FSTRONG%3E%20set%20to%20%3CSTRONG%3EImmediately%3C%2FSTRONG%3E.%20Then%20on%20the%20next%20window%2C%20%3CSTRONG%3EWizard%20Actions%3C%2FSTRONG%3E%2C%20leave%20Create%20the%20subscription(s)%20checked%20and%20click%20Next.%20On%20the%20Complete%20the%20Wizard%20click%20Next%20and%20wait%20for%20the%20Success%20status%20on%20the%20final%20%3CSTRONG%3ECreating%20Subscription(s)%3C%2FSTRONG%3E%20step.%3C%2FP%3E%0A%3CP%3EOnce%20this%20is%20done%2C%20from%20the%20context%20menu%20of%20the%20newly%20created%20subscription%2C%20open%20the%20%3CSTRONG%3EView%20Synchronization%20Status%3C%2FSTRONG%3E.%20You%20will%20see%20its%20progress%20and%20eventually%20all%20transactions%20will%20be%20replicated.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Tran%20repl%20-%20205%20view%20sync%20stat.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F280137iD7267696A119E8FA%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Tran%20repl%20-%20205%20view%20sync%20stat.png%22%20alt%3D%22Tran%20repl%20-%20205%20view%20sync%20stat.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFrom%20the%20context%20menu%20of%20the%20Publication%20click%20Launch%20Replication%20Monitor.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Tran%20repl%20-%20206%20Launch%20replication%20monitor.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F280138i551E6BD76A23EC3E%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Tran%20repl%20-%20206%20Launch%20replication%20monitor.png%22%20alt%3D%22Tran%20repl%20-%20206%20Launch%20replication%20monitor.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHere%20in%20the%20Replication%20Monitor%2C%20in%20Agents%20tab%20you%20will%20see%20the%20progress%20of%20the%20Snapshot%20Agent%20and%20Log%20Reader%20Agent.%20On%20Snapshot%20agent%20reaches%20100%25%2C%20database%20is%20replicated%2C%20and%20ongoing%20transactions%20will%20be%20replicated%20as%20well.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Tran%20repl%20-%20207%20replication%20monitor.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F280139iD10ADAB24C8DD292%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Tran%20repl%20-%20207%20replication%20monitor.png%22%20alt%3D%22Tran%20repl%20-%20207%20replication%20monitor.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFinally%2C%20connect%20to%20the%20SQL%20Server%20that%20is%20Subscriber%20and%20you%20will%20see%20that%20database%20is%20replicated.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Tran%20repl%20-%20208%20target%20database.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F280140iAA22A96FEE252A97%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Tran%20repl%20-%20208%20target%20database.png%22%20alt%3D%22Tran%20repl%20-%20208%20target%20database.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWith%20this%20you%20source%20database%20is%20migrated%20from%20Managed%20Instance%20to%20SQL%20Server.%20If%20the%20workload%20on%20the%20source%20database%20is%20still%20running%2C%20changes%20it%20might%20make%20will%20be%20replicated%20to%20the%20target%20database.%20Once%20you%20want%20to%20finalize%20the%20migration%2C%20you%20can%20set%20the%20source%20database%20to%20read-only%20mode%2C%20wait%20for%20the%20replication%20to%20complete%20(in%20the%20Replication%20monitor%2C%20Log%20Reader%20Agent's%20last%20action%20will%20be%20%22No%20replicated%20transactions%20are%20available%22)%20and%20stop%20the%20transactional%20replication.%20This%20is%20done%20by%20disabling%20the%20corresponding%20SQL%20Agent%20jobs%20and%20deleting%20subscriber%2C%20distributor%20and%20publisher.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--234212259%22%20id%3D%22toc-hId--235170289%22%3ETransactional%20replication%20limitations%20and%20workarounds%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EManaged%20Instance%20documentation%20contains%20list%20of%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fazure-sql%2Fmanaged-instance%2Freplication-two-instances-and-sql-server-configure-tutorial%23known-errors%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Eknow%20errors%3C%2FA%3E%20related%20to%20transactional%20replication.%3C%2FP%3E%0A%3CP%3EIn%20case%20you%20want%20to%20know%20more%2C%20take%20a%20look%20at%20the%20official%20Managed%20Instance%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fazure-sql%2Fmanaged-instance%2Freplication-transactional-overview%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Etransactional%20replication%20documentation.%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-456349215%22%20id%3D%22toc-hId-455391185%22%3EPrimary%20key%20requirement%3C%2FH3%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAll%20tables%20that%20participate%20in%20transactional%20replication%20need%20to%20have%20primary%20key.%20If%20a%20table%20does%20not%20have%20one%2C%20you%20will%20have%20to%20create%20it.%20Alternatively%2C%20you%20can%20create%20materialized%20view%20over%20the%20table%20that's%20missing%20primary%20key%2C%20and%20replicate%20that%20materialized%20view.%20Once%20the%20data%20is%20in%20the%20target%20database%2C%20you%20can%20create%20the%20missing%20table%20and%20insert%20data%20from%20the%20replicated%20materialized%20view%20to%20the%20newly%20created%20table.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-445846111%22%20id%3D%22toc-hId-444888081%22%3EConclusion%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETransactional%20replication%20offers%20performant%20and%20robust%20way%20to%20migrate%20database%20from%20Managed%20Instance%20to%20SQL%20Server%2C%20with%20some%20limitations%20mentioned%20in%20this%20blog.%20For%20more%20information%20on%20the%20migration%20options%2C%20see%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Faka.ms%2Fsqlmi-to-sqlserver-blog%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3EMoving%20databases%20from%20Azure%20SQL%20Managed%20Instance%20to%20SQL%20Server.%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-2344070%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22000%20-%20Tran%20repl%20teaser.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F280147i4976AE0815572DBE%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22000%20-%20Tran%20repl%20teaser.png%22%20alt%3D%22000%20-%20Tran%20repl%20teaser.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3ENeed%20to%20migrate%20large%2C%20complex%20database%20from%20Managed%20Instance%20to%20SQL%20Server%3F%20Transactional%20replication%20is%20a%20technology%20that%20can%20do%20this.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2344070%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%20SQL%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EAzure%20SQL%20Managed%20Instance%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Version history
Last update:
‎Jun 03 2021 06:58 AM
Updated by: