当CosmosDB集合文档具有不同的属性时,如何使用Azure数据工厂将旧的CosmosDB数据存档到Azure表?

问题描述 投票:1回答:1

我正在尝试将来自CosmosDB的旧数据存档到Azure表中,但是我对Azure Data Factory还是陌生的,因此我不确定哪种方法是一个好方法。最初,我认为可以使用“复制活动”来完成此操作,但是由于存储在CosmosDB源文件中的文档的属性各不相同,因此出现了映射问题。有什么想法可以解决该归档过程吗?

[基本上,我要存储数据的方式是照原样复制文档根属性,并将嵌套的JSON存储为序列化的字符串。

例如,如果我要存档这两个文档:

[
  {
    "identifier": "1st Guid here",
    "Contact": {
      "Name":  "John Doe",
      "Age": 99
    }
  },
  { 
    "identifier": "2nd Guid here",
    "Distributor": {
       "Name": "Jane Doe",
       "Phone": {
         "Number": "12345",
         "IsVerified": true
       }
    }
  }
]

我希望这些文档像这样存储在Azure表中:

identifier      | Contact                                   | Distributor 
"Ist Guid here" | "{ \"Name\": \"John Doe\", \"Age\": 99 }" | null
"2nd Guid here" |  null                                     | "{\"Name\":\"Jane Doe\",\"Phone\":{\"Number\":\"12345\",\"IsVerified\":true}}"

复制活动有可能吗?

[我尝试使用CopyActivity中的映射选项卡,但是当我尝试运行它时,我收到一条错误消息,指出无法推断第一行中不存在的嵌套JSON列之一的数据类型。

azure azure-cosmosdb azure-data-factory azure-table-storage backup-strategies
1个回答
1
投票

请按照我在映射标记中的配置。

enter image description here

使用示例数据测试输出:

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.