无法解析属性“CosmosDBAttribute.ConnectionStringSetting”的值

Ken*_*y_I 3 c# azure azure-functions

我使用 Visual Studio 开发了带有 CosmosDB 输出的简单服务总线触发器。Service Bus 和 CosmosDB 的连接字符串在 local.settings.json 中定义。代码在本地完全发挥作用。现在我有 Zip 发布函数(C#)到 Azure。

我收到错误:

Microsoft.Azure.WebJobs.Host: Error indexing method 'Function1'. 
Microsoft.Azure.WebJobs.Host: Unable to resolve the value for property 
'CosmosDBAttribute.ConnectionStringSetting'. 
Run Code Online (Sandbox Code Playgroud)

我该怎么办?

在此处输入图片说明

1_1*_*1_1 5

该错误告诉您需要在 Azure 上添加设置。

azure 上的 azure 函数与本地上的 azure 函数不同。在本地,设置在 local.settings.json 中。但是在 azure 上它在配置中。(即使你部署了 local.settings.json,该函数也会从配置中读取环境设置)

在此处输入图片说明

在此处输入图片说明

并且不要忘记保存您的编辑。