我从C# HTTP模板创建了Azure函数(2.0v)。然后,我在基于CosmosDB docs的CosmosDB中添加了输出绑定
public static class AddEvent
{
[FunctionName("AddEvent")]
public static void Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)]
HttpRequest req,
[CosmosDB("SomeDatabase", "SomeCollection", Id = "id",
ConnectionStringSetting = "myCosmosDB", CreateIfNotExists = true)]
out dynamic document)
{
document = new { Text = "something", id = Guid.NewGuid() };
}
}
我使用的包(csproj文件):
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.CosmosDB" Version="3.0.0-beta7" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.11" />
这是我的local.settings.json。我基于来自CosmosDB仿真器的值:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"AzureWebJobsDashboard": "",
"myCosmosDB": "AccountEndpoint=https://localhost:8081/;AccountKey=C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw=="
}
}
不幸的是,当我点击HTTP触发器时,我得到:
System.Private.CoreLib: Exception while executing function: AddEvent.
Microsoft.Azure.WebJobs.Host: Exception binding parameter 'document'.
Microsoft.Azure.DocumentDB.Core: The type initializer for 'Microsoft.Azure.Documents.UserAgentContainer' threw an exception.
Object reference not set to an instance of an object.
这个异常是什么意思?我找不到任何有关它的相关信息,它完全停止了我在当地的工作。函数在没有CosmosDB属性的情况下工作得很好。
发布于 2018-06-08 09:08:21
这是主机的最新版本(2.0.11776)的回归。这个问题已经解决了,目前正在发布中。
https://stackoverflow.com/questions/50681158
复制相似问题