【发布时间】:2019-02-26 06:45:17
【问题描述】:
美好的一天,
我正在 Visual Studio 中使用 .net framework/V1 开发一个 azure 函数,我想从 Azure Function 上的 TestData 集合中检索 clientDetails 数据,我的函数是HttpTrigger。
我尝试了此链接中的示例:Azure Cosmos DB bindings for Azure Functions 1.x
我创建了两个属性类:
public class DocumentClient
{
[JsonProperty("clientDetails")]
public List<ClientDetails> clientDetails { get; set; }
}
public class ClientDetails
{
public string domain { get; set; }
public string channel { get; set; }
public string retailer { get; set; }
public string store { get; set; }
public string auth { get; set; }
}
这里是构造函数:
public static async Task<HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Function), Disable()]HttpRequestMessage req, [DocumentDB(
databaseName: "Client",
collectionName: "TestData",
ConnectionStringSetting = "CosmosDBConnection"
)] DocumentClient client, TraceWriter log)
但我在运行该函数时遇到错误Id is required,但每当我尝试添加时
Id ="{Hardcoded - the TestData's Id}"
触发函数时出现错误“必须为此操作提供PartitionKey值”
我在我的 local.settings.json 中添加了这个:
"CosmosDBConnection": "AccountEndpoint=https://test.com:443/;AccountKey=testkey==;"
问候
【问题讨论】:
-
你是如何定义你的 cosmo db 架构的 >???
标签: c# azure azure-functions azure-cosmosdb