Replication to Azure SQL Database
Applies to: Azure SQL Database SQL database in Fabric
You can configure Azure SQL Database or Fabric SQL database as the push subscriber in a one-way transactional or snapshot replication topology from SQL Server and Azure SQL Managed Instance.
Note
This article describes the use of transactional replication to push data to Azure SQL Database or Fabric SQL database. This article applies equally to Azure SQL Database and Fabric SQL database unless otherwise noted.
It is unrelated to active geo-replication, an Azure SQL Database feature that allows you to create complete readable replicas of individual databases.
Supported configurations
- Azure SQL Database or Fabric SQL database can only be the push subscriber of a SQL Server publisher and distributor.
- The SQL Server instance acting as publisher and/or distributor can be an instance of SQL Server running on-premises, an Azure SQL Managed Instance, or an instance of SQL Server running on an Azure virtual machine in the cloud.
- The distribution database and the replication agents cannot be placed on a database in Azure SQL Database.
- Snapshot and one-way transactional replication are supported. Peer-to-peer transactional replication and merge replication are not supported.
Versions
To successfully replicate to a database in Azure SQL Database, SQL Server publishers and distributors must be using (at least) one of the following versions:
Publishing to any Azure SQL Database from a SQL Server database is supported by the following versions of SQL Server:
- 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)
Note
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.).
To use all the features of Azure SQL Database, you must be using the latest versions of SQL Server Management Studio (SSMS) and SQL Server Data Tools.
Types of replication
There are different types of replication:
Replication | Azure SQL Database | Azure SQL Managed Instance |
---|---|---|
Standard Transactional | Yes (only as subscriber) | Yes |
Snapshot | Yes (only as subscriber) | Yes |
Merge replication | No | No |
Peer-to-peer | No | No |
Bidirectional | No | Yes |
Updatable subscriptions | No | No |
Remarks
- Only push subscriptions to Azure SQL Database are supported.
- 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.
- To authenticate:
- Replication can only use SQL Server authentication logins to connect to Azure SQL Database.
- Replication can only use Microsoft Entra ID authentication with a service principalto connect to Fabric 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 SQL Server rather than Azure SQL Database.
- Only
@subscriber_type = 0
is supported insp_addsubscription
for SQL Database. - Azure SQL Database does not support bi-directional, immediate, updatable, or peer-to-peer replication.
Replication Architecture
Scenarios
Typical Replication Scenario
- Create a transactional replication publication on a SQL Server database.
- On 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 SQL Managed Instance publisher, you can also use a database backup to seed the Azure SQL Database subscriber.
Data migration scenario
- Use transactional replication to replicate data from a SQL Server database to Azure SQL Database.
- Redirect the client or middle-tier applications to update the database copy.
- Stop updating the SQL Server version of the table and remove the publication.
Limitations
Replication with the following options are not supported by Azure SQL Database:
- 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
Limitations to be determined
- Copy collation
- Execution in a serialized transaction of the SP
Examples
Create a publication and a push subscription. For more information, see:
- Create a Publication
- Create a Push Subscription by using the 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).