以我自己的进步编辑。
我正在尝试在Azure函数中使用DocumentDb,我正在使用新的Visual Studio工具编写,这允许我构建和部署dll。我的function.json文件是由工具创建的,所以我不认为我可以在function.json中创建我的绑定。我必须使用属性。
我已将Microsoft.Azure.Webjobs.Extensions.DocumentDB包添加到我的解决方案中。然后我有一个函数签名:
public static async Task<HttpResponseMessage> Run(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)]
HttpRequestMessage req,
[DocumentDB("database", "collection"ConnectionStringSetting = "conn", Id = "w", PartitionKey = "customer")) DocumentClient docdbcli,
TraceWriter log)
在方法体中我有:
await docdbcli.CreateDocumentAsync(UriFactory.CreateDocumentCollectionUri("customerdocumentversionsdb", "snapshots"), new
{
id = "edse",
customer = "expedia",
document = Converter.Serialize(jliff),
version = "sourceedited"
});
工具编译的function.json是:
{
"bindings": [
{
"type": "httpTrigger",
"methods": [
"get",
"post"
],
"authLevel": "function",
"direction": "in",
"name": "req"
},
{
"type": "documentDB",
"databaseName": "customerdocumentversionsdb",
"collectionName": "snapshots",
"createIfNotExists": false,
"connection": "conn",
"id": "w",
"partitionKey": "customer",
"direction": "out",
"name": "docdbcli"
},
{
"name": "$return",
"type": "http",
"direction": "out"
}
],
"disabled": false,
"scriptFile": "..\\MtWithRulesFunctionApp.dll",
"entryPoint": "MtWithRulesFunctionApp.PreEditSource.Run"
}
我的文档不会写入db,可能是因为绑定about指定为out。
答案 0 :(得分:3)
您需要引用$settings = get_option( 'repeatable-news-options.php', array() );
if ( ! empty( $settings['news-section'] ) ) {
foreach ( $settings['news-section'] as $section ) {
echo $section['title'] . '<br/>';
}
}
NuGet包,使用命名空间
Microsoft.Azure.WebJobs.Extensions.DocumentDB
然后用using Microsoft.Azure.WebJobs.Extensions.DocumentDB;
属性装饰你的函数参数。
答案 1 :(得分:0)
原来是图书馆v1.5的问题。使用1.4作品。
答案 2 :(得分:0)
看起来DocumentDb发生了重大变化。它是在次要版本中完成的,因此它违反了语义版本控制。 https://github.com/Azure/azure-webjobs-sdk-script/issues/1679