azure - 有条件地将数据从一个 SQL 实例同步到另一实例

标签 azure azure-sql-database azure-data-factory databricks azure-synapse

我一直在尝试将 Azure 上的 SQL 表中的数百万条记录有条件/选择性地同步到 Azure 中的另一个 SQL 数据库。

Is there any way to configure Azure Data Sync or replication not to sync all records of table, rather sync only few rows as specified in where clause?

Or Is there any way to sync data generated by SQL View into another database table?

附注我进行了研究,默认情况下它在 Azure 门户中不可用。所以期待专家对此的意见。感谢您尝试提供帮助!

最佳答案

在 Azure 中同步 SQL 数据库的常见方法是激活复制。这将使数据库保持同步,以实现高可用性或冗余。对于您的用例,这不是一个选项,因为您只想同步特定行。

此处推荐使用的工具是 Azure 数据工厂,它具有内置的复制事件。这允许您将数据从源复制到接收器。在您的情况下,源和接收器都是 SQL 数据库。要开始复制事件,请按照 this 中的说明进行操作。教程。您还应该利用滚动窗口触发器以特定的时间间隔运行管道。

下面您将找到一个非常简单的复制事件示例,以供您引用。 sqlReaderQuery 属性为您提供了很大的灵 active ,因为它使您能够选择要同步的特定数据。要增量同步数据,您必须利用数据集中的现有字段,例如 LastUpdated。这样您就可以有条件地加载上次管道运行后创建的数据。

"activities":[
    {
        "name": "CopyFromSQLServer",
        "type": "Copy",
        "inputs": [
            {
                "referenceName": "<SQL Server input dataset name>",
                "type": "DatasetReference"
            }
        ],
        "outputs": [
            {
                "referenceName": "<output dataset name>",
                "type": "DatasetReference"
            }
        ],
        "typeProperties": {
            "source": {
                "type": "SqlSource",
                "sqlReaderQuery": "SELECT * FROM Customers WHERE LastUpdated BETWEEN @{pipeline().parameters.LastModified_From} AND @{pipeline().parameters.LastModified_To}"
            },
            "sink": {
                "type": "SqlSink"
            }
        }
    }
]

这个想法是基于this azure 教程,使用 LastModifiedDate 在两个存储容器之间复制 blob 文件。在 this您将在 GitHub 存储库中找到 terraform 实现。

关于azure - 有条件地将数据从一个 SQL 实例同步到另一实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73726010/

相关文章:

sql-server - 为什么我们只需要为标量函数使用架构名称

azure - Dynamics cloud RetrieveRecordChangeHistory 数据工厂

azure - "Failed to delete integration runtime."Azure 数据工厂

json - Arm 模板中的 copyindex() 错误

在删除 cookie 之前,Asp.Net 页面不会响应

Azure 事件网格多次触发 Azure Function App,而不是一次

azure-data-factory - 在 Azure 数据流中将 1 行转换为多行

azure - 多次传递的持久功能的队列触发消息

azure - 使用 Azure PowerShell 进行数据库迁移

c# - Azure SQL - 单个或多个数据库连接?