2017-07-24 49 views
0

我试图从Azure的功能中写入以下文件DocumentDb:Text属性没有序列号

dynamic doc = new { 
    customer = "mycust", 
    version = "version2", 
    document = JObject.Parse("{\"prop1\": \"Some text.\"}") 
} 

await 
_client.CreateDocumentAsync(UriFactory.CreateDocumentCollectionUri("db", "coll"),doc); 

当保存到documentdb我得到:

{ 
    "customer": "mycust", 
    "version": "version2", 
    "document": { 
    "prop1": [] 
    }, 
    "id": "93ccb6d6-8829-4179-beba-606078f63dea" 
} 

“一些文本”是失踪。在调试器中,它被正确解析。

回答

0

根据你的描述,我检查这个问题,并通过以下方法进行了测试,你可以参考他们:

#r "Newtonsoft.Json" 
using System.Net; 
using System; 
using Newtonsoft.Json; 
using Newtonsoft.Json.Linq; 

public static HttpResponseMessage Run(HttpRequestMessage req,out object outputDocument,TraceWriter log) 
{ 
    dynamic doc = new 
    { 
     customer = "mycust", 
     version = "version2", 
     document = JObject.Parse("{\"prop1\": \"Some text.\"}") 
    }; 
    outputDocument=doc; 
    return req.CreateResponse(HttpStatusCode.OK, "success"); 
} 

或指Azure WebJobs SDK Extensions for DocumentDB和配置如下:

#r "Newtonsoft.Json" 
using System.Net; 
using System; 
using Newtonsoft.Json; 
using Newtonsoft.Json.Linq; 
using Microsoft.Azure.WebJobs.Extensions.DocumentDB; 

public static HttpResponseMessage Run(HttpRequestMessage req,[DocumentDB("brucedb-2", "todoitem",ConnectionStringSetting = "brucedocumentdb-01_DOCUMENTDB")] out object outputDocument,TraceWriter log) 
{ 
    dynamic doc = new 
    { 
     customer = "mycust", 
     version = "version2", 
     document = JObject.Parse("{\"prop1\": \"Some text.\"}") 
    }; 
    outputDocument=doc; 
    return req.CreateResponse(HttpStatusCode.OK, "success"); 
} 

此外,您还可以利用Microsoft Azure DocumentDB Client Library并参考此类似的issue添加新文件向Azure DocumentDB提供支持。