Replication to SQL Database single and pooled databases
SQL Server replication can be configured to single and pooled databases on a SQL Database server in Azure SQL Database.
This article describes the use of transactional replication in Azure SQL Database. It is unrelated to active geo-replication, an Azure SQL Database feature that allows you to create complete readable replicas of individual databases.
- The SQL Server can be an instance of SQL Server running on-premises or an instance of SQL Server running in an Azure virtual machine in the cloud. For more information, see SQL Server on Azure Virtual Machines overview.
- The Azure SQL database must be a push subscriber of a SQL Server publisher.
- The distribution database and the replication agents cannot be placed on an Azure SQL database.
- Snapshot and one-way transactional replication are supported. Peer-to-peer transactional replication and merge replication are not supported.
- Replication is available for public preview on Azure SQL Database Managed Instance. Managed Instance can host publisher, distributor, and subscriber databases. For more information, see Replication with SQL Database Managed Instance.
On-premises SQL Server publishers and distributors must be using (at least) one of the following versions:
- SQL Server 2016 and greater
- SQL Server 2014 RTM CU10 (12.0.4427.24) or SP1 CU3 (12.0.2556.4)
- SQL Server 2012 SP2 CU8 (11.0.5634.1) or SP3 (11.0.6020.0)
Attempting to configure replication using an unsupported version can result in error number MSSQL_REPL20084 (The process could not connect to Subscriber.) and MSSQL_REPL40532 (Cannot open server <name> requested by the login. The login failed.).
- Replication can be configured by using SQL Server Management Studio or by executing Transact-SQL statements on the publisher. You cannot configure replication by using the Azure portal.
- Replication can only use SQL Server authentication logins to connect to an Azure SQL database.
- Replicated tables must have a primary key.
- You must have an existing Azure subscription.
- The Azure SQL database subscriber can be in any region.
- A single publication on SQL Server can support both Azure SQL Database and SQL Server (on-premises and SQL Server in an Azure virtual machine) subscribers.
- Replication management, monitoring, and troubleshooting must be performed from the on-premises SQL Server.
- Only push subscriptions to Azure SQL Database are supported.
@subscriber_type = 0is supported in sp_addsubscription for SQL Database.
- Azure SQL Database does not support bi-directional, immediate, updatable, or peer to peer replication.
Typical Replication Scenario
- Create a transactional replication publication on an on-premises SQL Server database.
- On the on-premises SQL Server use the New Subscription Wizard or Transact-SQL statements to create a push to subscription to Azure SQL Database.
- With single and pooled databases in Azure SQL Database, the initial data set is a snapshot that is created by the Snapshot Agent and distributed and applied by the Distribution Agent. With a managed instance database, you can also use a database backup to seed the subscriber database.
Data Migration Scenario
- Use transactional replication to replicate data from an on-premises SQL Server database to Azure SQL Database.
- Redirect the client or middle-tier applications to update the Azure SQL database copy.
- Stop updating the SQL Server version of the table and remove the publication.
The following options are not supported for Azure SQL Database subscriptions:
- Copy file groups association
- Copy table partitioning schemes
- Copy index partitioning schemes
- Copy user defined statistics
- Copy default bindings
- Copy rule bindings
- Copy fulltext indexes
- Copy XML XSD
- Copy XML indexes
- Copy permissions
- Copy spatial indexes
- Copy filtered indexes
- Copy data compression attribute
- Copy sparse column attribute
- Convert filestream to MAX data types
- Convert hierarchyid to MAX data types
- Convert spatial to MAX data types
- Copy extended properties
- Copy permissions
Limitations to be determined
- Copy collation
- Execution in a serialized transaction of the SP
Create a publication and a push subscription. For more information, see:
- Create a Publication
- Create a Push Subscription by using the Azure SQL Database server name as the subscriber (for example N'azuresqldbdns.database.windows.net') and the Azure SQL database name as the destination database (for example AdventureWorks).