|
| 1 | +--- |
| 2 | +title: SQL Server replication to Azure SQL Database |
| 3 | +description: You can configure an Azure SQL Database as the push subscriber in a one-way transactional or snapshot replication topology. |
| 4 | +services: sql-database |
| 5 | +ms.service: sql-database |
| 6 | +ms.subservice: data-movement |
| 7 | +ms.custom: seo-lt-2019, sqldbrb=1 |
| 8 | +ms.devlang: |
| 9 | +ms.topic: conceptual |
| 10 | +author: stevestein |
| 11 | +ms.author: sstein |
| 12 | +ms.reviewer: mathoma |
| 13 | +ms.date: 04/28/2020 |
| 14 | +--- |
| 15 | +# Replication to Azure SQL Database |
| 16 | + |
| 17 | +You can configure an Azure SQL Database as the push subscriber in a one-way transactional or snapshot replication topology. |
| 18 | + |
| 19 | +> [!NOTE] |
| 20 | +> This article describes the use of [transactional replication](https://docs.microsoft.com/sql/relational-databases/replication/transactional/transactional-replication) in Azure SQL Database. It is unrelated to [active geo-replication](https://docs.microsoft.com/azure/sql-database/sql-database-active-geo-replication), an Azure SQL Database feature that allows you to create complete readable replicas of individual databases. |
| 21 | +
|
| 22 | +## Supported Configurations |
| 23 | + |
| 24 | +- Azure SQL Database can only be the push subscriber of a SQL Server publisher and distributor. |
| 25 | +- The SQL Server acting as publisher and/or distributor can be an instance of [SQL Server running on-premises](https://www.microsoft.com/sql-server/sql-server-downloads), an [Azure SQL Managed Instance](../azure-sql/managed-instance/instance-create-quickstart.md), or an instance of [SQL Server running on an Azure virtual machine in the cloud](../virtual-machines/windows/sql-vm-create-portal-quickstart.md). |
| 26 | +- The distribution database and the replication agents cannot be placed on an Azure SQL database. |
| 27 | +- [Snapshot](/sql/relational-databases/replication/snapshot-replication) and [one-way transactional](/sql/relational-databases/replication/transactional/transactional-replication) replication are supported. Peer-to-peer transactional replication and merge replication are not supported. |
| 28 | + |
| 29 | + |
| 30 | +### Versions |
| 31 | + |
| 32 | +To successfully replicate to an Azure SQL Database, SQL Server publishers and distributors must be using (at least) one of the following versions: |
| 33 | + |
| 34 | +Publishing to any Azure SQL Database from an on-premises SQL Server is supported by the following versions of SQL Server: |
| 35 | + |
| 36 | +- SQL Server 2016 and greater |
| 37 | +- SQL Server 2014 [RTM CU10 (12.0.4427.24)](https://support.microsoft.com/help/3094220/cumulative-update-10-for-sql-server-2014) or [SP1 CU3 (12.0.2556.4)](https://support.microsoft.com/help/3094221/cumulative-update-3-for-sql-server-2014-service-pack-1) |
| 38 | +- SQL Server 2012 [SP2 CU8 (11.0.5634.1)](https://support.microsoft.com/help/3082561/cumulative-update-8-for-sql-server-2012-sp2) or [SP3 (11.0.6020.0)](https://www.microsoft.com/download/details.aspx?id=49996) |
| 39 | + |
| 40 | +> [!NOTE] |
| 41 | +> 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.). |
| 42 | +
|
| 43 | +To use all the features of Azure SQL Database, you must be using the latest versions of [SQL Server Management Studio](/sql/ssms/download-sql-server-management-studio-ssms) and [SQL Server Data Tools](/sql/ssdt/download-sql-server-data-tools-ssdt). |
| 44 | + |
| 45 | +### Types of replication |
| 46 | + |
| 47 | +There are different [types of replication](https://docs.microsoft.com/sql/relational-databases/replication/types-of-replication): |
| 48 | + |
| 49 | +| Replication | Azure SQL Database | Azure SQL Managed Instance | |
| 50 | +| :----| :------------- | :--------------- | |
| 51 | +| [**Standard Transactional**](https://docs.microsoft.com/sql/relational-databases/replication/transactional/transactional-replication) | Yes (only as subscriber) | Yes | |
| 52 | +| [**Snapshot**](https://docs.microsoft.com/sql/relational-databases/replication/snapshot-replication) | Yes (only as subscriber) | Yes| |
| 53 | +| [**Merge replication**](https://docs.microsoft.com/sql/relational-databases/replication/merge/merge-replication) | No | No| |
| 54 | +| [**Peer-to-peer**](https://docs.microsoft.com/sql/relational-databases/replication/transactional/peer-to-peer-transactional-replication) | No | No| |
| 55 | +| [**Bidirectional**](https://docs.microsoft.com/sql/relational-databases/replication/transactional/bidirectional-transactional-replication) | No | Yes| |
| 56 | +| [**Updatable subscriptions**](https://docs.microsoft.com/sql/relational-databases/replication/transactional/updatable-subscriptions-for-transactional-replication) | No | No| |
| 57 | +| | | | |
| 58 | + |
| 59 | + |
| 60 | +## Remarks |
| 61 | + |
| 62 | +- Only push subscriptions to Azure SQL Database are supported. |
| 63 | +- Replication can be configured by using [SQL Server Management Studio](/sql/ssms/download-sql-server-management-studio-ssms) or by executing Transact-SQL statements on the publisher. You cannot configure replication by using the Azure portal. |
| 64 | +- Replication can only use SQL Server authentication logins to connect to Azure SQL Database. |
| 65 | +- Replicated tables must have a primary key. |
| 66 | +- You must have an existing Azure subscription. |
| 67 | +- The Azure SQL Database subscriber can be in any region. |
| 68 | +- 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. |
| 69 | +- Replication management, monitoring, and troubleshooting must be performed from SQL Server rather than Azure SQL Database. |
| 70 | +- Only `@subscriber_type = 0` is supported in **sp_addsubscription** for SQL Database. |
| 71 | +- Azure SQL Database does not support bi-directional, immediate, updatable, or peer-to-peer replication. |
| 72 | + |
| 73 | +## Replication Architecture |
| 74 | + |
| 75 | + |
| 76 | + |
| 77 | +## Scenarios |
| 78 | + |
| 79 | +### Typical Replication Scenario |
| 80 | + |
| 81 | +1. Create a transactional replication publication on an on-premises SQL Server database. |
| 82 | +2. 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. |
| 83 | +3. 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. |
| 84 | + |
| 85 | +### Data Migration Scenario |
| 86 | + |
| 87 | +1. Use transactional replication to replicate data from an on-premises SQL Server database to Azure SQL Database. |
| 88 | +2. Redirect the client or middle-tier applications to update the Azure SQL database copy. |
| 89 | +3. Stop updating the SQL Server version of the table and remove the publication. |
| 90 | + |
| 91 | +## Limitations |
| 92 | + |
| 93 | +The following options are not supported for Azure SQL Database subscriptions: |
| 94 | + |
| 95 | +- Copy file groups association |
| 96 | +- Copy table partitioning schemes |
| 97 | +- Copy index partitioning schemes |
| 98 | +- Copy user defined statistics |
| 99 | +- Copy default bindings |
| 100 | +- Copy rule bindings |
| 101 | +- Copy fulltext indexes |
| 102 | +- Copy XML XSD |
| 103 | +- Copy XML indexes |
| 104 | +- Copy permissions |
| 105 | +- Copy spatial indexes |
| 106 | +- Copy filtered indexes |
| 107 | +- Copy data compression attribute |
| 108 | +- Copy sparse column attribute |
| 109 | +- Convert filestream to MAX data types |
| 110 | +- Convert hierarchyid to MAX data types |
| 111 | +- Convert spatial to MAX data types |
| 112 | +- Copy extended properties |
| 113 | +- Copy permissions |
| 114 | + |
| 115 | +### Limitations to be determined |
| 116 | + |
| 117 | +- Copy collation |
| 118 | +- Execution in a serialized transaction of the SP |
| 119 | + |
| 120 | +## Examples |
| 121 | + |
| 122 | +Create a publication and a push subscription. For more information, see: |
| 123 | + |
| 124 | +- [Create a Publication](https://docs.microsoft.com/sql/relational-databases/replication/publish/create-a-publication) |
| 125 | +- [Create a Push Subscription](https://docs.microsoft.com/sql/relational-databases/replication/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**). |
| 126 | + |
| 127 | +## See Also |
| 128 | + |
| 129 | +- [Transactional replication](../managed-instance/replication-transactional-overview.md) |
| 130 | +- [Create a Publication](https://docs.microsoft.com/sql/relational-databases/replication/publish/create-a-publication) |
| 131 | +- [Create a Push Subscription](https://docs.microsoft.com/sql/relational-databases/replication/create-a-push-subscription/) |
| 132 | +- [Types of Replication](https://docs.microsoft.com/sql/relational-databases/replication/types-of-replication) |
| 133 | +- [Monitoring (Replication)](https://docs.microsoft.com/sql/relational-databases/replication/monitor/monitoring-replication) |
| 134 | +- [Initialize a Subscription](https://docs.microsoft.com/sql/relational-databases/replication/initialize-a-subscription) |
0 commit comments