如何解决 "connection string is not formatted correctly"?
How do I resolve "connection string is not formatted correctly"?
我正在尝试创建一些 Azure Functions。我开始学习教程 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}");
}
}
}
这是本地控制台的输出 window:
[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,但仍然无法正常工作。
我错过了什么?
看起来它希望在设置中有完整的存储连接字符串,而不仅仅是队列的 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/;"
}
}
正如 juunas 所说,我们需要 Connection
应用程序设置的完整连接字符串。
如果此连接与 AzureWebJobsStorage
重复,您只需将属性更改为 [QueueTrigger("my-queue-items")]
(如果未指定其他连接,则默认为 AzureWebJobsStorage
)。
我正在尝试创建一些 Azure Functions。我开始学习教程 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}");
}
}
}
这是本地控制台的输出 window:
[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,但仍然无法正常工作。
我错过了什么?
看起来它希望在设置中有完整的存储连接字符串,而不仅仅是队列的 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/;"
}
}
正如 juunas 所说,我们需要 Connection
应用程序设置的完整连接字符串。
如果此连接与 AzureWebJobsStorage
重复,您只需将属性更改为 [QueueTrigger("my-queue-items")]
(如果未指定其他连接,则默认为 AzureWebJobsStorage
)。