我正在尝试创建一些Azure功能。我开始学习教程here。问题是,当我尝试在本地调试时,我不断收到错误。
这是我的local.settings.json
:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=XYZ;AccountKey=<removed>;BlobEndpoint=https://XXX.blob.core.windows.net/;QueueEndpoint=https://XXX.queue.core.windows.net/;TableEndpoint=https://XXX.table.core.windows.net/;FileEndpoint=https://XXX.file.core.windows.net/;",
"AzureWebJobsDashboard": "",
"QueueStorage": "https://XXX.queue.core.windows.net/myqueue-items"
}
}
以下是代码(实际上只是Azure Functions中包含的模板化代码)
using System;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
namespace FunctionApp3
{
public static class SampleFunction
{
[FunctionName("SampleFunction")]
public static void Run([QueueTrigger("myqueue-items", Connection = "QueueStorage")]string myQueueItem, TraceWriter log)
{
log.Info($"C# Queue trigger function processed: {myQueueItem}");
}
}
}
以下是本地控制台窗口的输出:
[8/29/2017 5:53:01 PM] Microsoft.Azure.WebJobs.Host: Error indexing method 'SampleFunction.Run'. Microsoft.Azure.WebJobs.Host: Failed to validate Microsoft Azure WebJobs SDK QueueStorage connection string. The Microsoft Azure Storage account connection string is not formatted correctly. Please visit https://go.microsoft.com/fwlink/?linkid=841340 for details about configuring Microsoft Azure Storage connection strings.
[8/29/2017 5:53:01 PM] Error indexing method 'SampleFunction.Run'
[8/29/2017 5:53:01 PM] Microsoft.Azure.WebJobs.Host: Error indexing method 'SampleFunction.Run'. Microsoft.Azure.WebJobs.Host: Failed to validate Microsoft Azure WebJobs SDK QueueStorage connection string. The Microsoft Azure Storage account connection string is not formatted correctly. Please visit https://go.microsoft.com/fwlink/?linkid=841340 for details about configuring Microsoft Azure Storage connection strings.
我尝试重写连接字符串几次,但似乎无法摆脱错误。我查看了信息here,但仍然无法使其发挥作用。
我错过了什么?
答案 0 :(得分:4)
看起来它需要在设置中存在完整的存储连接字符串,而不仅仅是队列的URL。
类似的东西:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=XYZ;AccountKey=<removed>;BlobEndpoint=https://XXX.blob.core.windows.net/;QueueEndpoint=https://XXX.queue.core.windows.net/;TableEndpoint=https://XXX.table.core.windows.net/;FileEndpoint=https://XXX.file.core.windows.net/;",
"AzureWebJobsDashboard": "",
"QueueStorage": "DefaultEndpointsProtocol=https;AccountName=XYZ;AccountKey=<removed>;BlobEndpoint=https://XXX.blob.core.windows.net/;QueueEndpoint=https://XXX.queue.core.windows.net/;TableEndpoint=https://XXX.table.core.windows.net/;FileEndpoint=https://XXX.file.core.windows.net/;"
}
}
答案 1 :(得分:1)
正如juunas所说,我们需要Connection
应用设置的完整连接字符串。
如果此连接与AzureWebJobsStorage
重复,您只需将属性更改为[QueueTrigger("my-queue-items")]
(如果未指定其他连接,则AzureWebJobsStorage
为默认值。)