将数据从 MySQL(本地)复制到 Cosmos DB

Copy Data from MySQL (on-premises) to Cosmos DB

我有几个问题如下:

  1. 我想知道如何将数据从 MySQL 传输到 Cosmos DB 使用 Python 或 Data Azure Factory 或其他任何方式。
  2. 如果我理解正确,table 中的一行将被转换 到文档中,是否正确?
  3. 有什么方法可以在复制过程中为文档多创建一行activity?
  4. 如果MySQL中的数据发生变化,Cosmos DB中复制的数据是否也会自动变化?如果没有,如何做这样的触发器?

我明白有些题是可以简单做的;但是,我对此很陌生。请多多包涵。

1.I was wondering how I could transfer data from MySQL to Cosmos DB using either Python or Data Azure Factory, or anything else.

是的,您可以使用 Azure Data Factory Copy Activity.

将数据从 mysql 传输到 cosmos db

If I understand correctly, a row from the table will be transformed into a document, is it correct?

是的。

Is there any way to create one more row for a doc during the copy activity?

如果你想为一个文档合并多行,那么副本activity可能不能直接使用。您可以在 Azure Function Http Trigger 中编写自己的逻辑代码(例如 Python 代码)。

If data in MySQL are changed, will the copied data in Cosmos DB be automatically changed too? If not, how to do such triggers?

所以,你可以容忍延迟同步,你可以使用 Copy Activity between sql 和 schedule 中的 cosmos db 同步数据。如果您需要及时同步,据我所知,azure 函数确实支持 sql 服务器 trigger.But 您可以从这个 document.

中获得一些解决方案
  1. 在 Azure 函数中定义自定义绑定

  2. 如果不是 Azure Functions 端的绑定,那么它可以是一个 SQL 触发器调用 Azure Functions HTTP 触发器。