Azure cosmosdb 从Azure数据工厂副本导入CosmosDB中的JSON数据时出现问题

Azure cosmosdb 从Azure数据工厂副本导入CosmosDB中的JSON数据时出现问题,azure-cosmosdb,azure-data-factory,azure-data-factory-2,Azure Cosmosdb,Azure Data Factory,Azure Data Factory 2,My Azure data Factory管道具有将数据从CSV复制到CosmosDB的复制操作 CSV文件在CosmosDB中有3列要导入 CosmosDB系列将收到: Column1 in Partition Key Column2 in Id Column3 whole JSON Value 当我运行COPY时,它会将所有3列的数据以字符串格式复制到CosmosDB中。因为当我们指定ColumnType时,没有可用的JSON或映射类型 我应该如何在值字段中导入JSON,而不是字符串或文

My Azure data Factory管道具有将数据从CSV复制到CosmosDB的复制操作
CSV文件在CosmosDB中有3列要导入

CosmosDB系列将收到:

Column1 in Partition Key
Column2 in Id
Column3 whole JSON Value
当我运行COPY时,它会将所有3列的数据以字符串格式复制到CosmosDB中。因为当我们指定ColumnType时,没有可用的JSON或映射类型

我应该如何在值字段中导入JSON,而不是字符串或文本。下面是我在CosmosDB中获得的示例:

据我所知,在adf cosmos db配置中,没有任何此类功能可以帮助您将字符串数据转换为对象格式

所以,作为解决方法,我建议您在将每个文档导入数据库时使用。请参阅我的功能代码:

using System.Collections.Generic;
using Microsoft.Azure.Documents;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Newtonsoft.Json.Linq;
using System;
using Microsoft.Azure.Documents.Client;

namespace TestADF
{
    public static class Function1
    {
        [FunctionName("Function1")]
        public static void Run([CosmosDBTrigger(
            databaseName: "db",
            collectionName: "item",
            ConnectionStringSetting = "documentdbstring",
            LeaseCollectionName = "leases")]IReadOnlyList<Document> input, TraceWriter log)
        {
            if (input != null && input.Count > 0)
            {
                log.Verbose("Start.........");
                String endpointUrl = "https://***.documents.azure.com:443/";
                String authorizationKey = "key";
                String databaseId = "db";
                String collectionId = "item";

                DocumentClient client = new DocumentClient(new Uri(endpointUrl), authorizationKey);

                for (int i = 0; i < input.Count; i++)
                {
                    Document doc = input[i];
                    if ((doc.GetPropertyValue<String>("Value") == null) || (!doc.GetPropertyValue<String>("Value")))
                    {                       
                        String V= doc.GetPropertyValue<String>("Value");
                        JObject obj = JObject.Parse(V);

                        doc.SetPropertyValue("Value", obj );

                        client.ReplaceDocumentAsync(UriFactory.CreateDocumentUri(databaseId, collectionId, doc.Id), doc);

                        log.Verbose("Update document Id " + doc.Id);
                    }

                }
            }
        }
    }
}
使用System.Collections.Generic;
使用Microsoft.Azure.Documents;
使用Microsoft.Azure.WebJobs;
使用Microsoft.Azure.WebJobs.Host;
使用Newtonsoft.Json.Linq;
使用制度;
使用Microsoft.Azure.Documents.Client;
命名空间TestADF
{
公共静态类函数1
{
[功能名称(“功能1”)]
公共静态无效运行([CosmosDBTrigger(
数据库名称:“db”,
收藏名称:“物品”,
ConnectionStringSetting=“DocumentDstring”,
LeaseCollectionName=“leases”)]IReadOnlyList输入,TraceWriter日志)
{
if(输入!=null&&input.Count>0)
{
详细记录(“开始……);
String endpointUrl=“https://***.documents.azure.com:443/”;
字符串authorizationKey=“key”;
字符串databaseId=“db”;
字符串collectionId=“item”;
DocumentClient client=new DocumentClient(新Uri(endpointUrl),authorizationKey);
for(int i=0;i
还有其他回复吗。。?或者,如果我们可以将JSON数据直接从笔记本推送到CosmosDB?嗨,我的回答对你有帮助吗?@JayGong我还不允许在我们的产品中使用Azure函数。