azure - 如何解析 "connection string is not formatted correctly"?

标签 azure azure-functions

我正在尝试创建一些 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}");
        }
    }
}

这是本地控制台窗口的输出:

[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/;"
  }
}

关于azure - 如何解析 "connection string is not formatted correctly"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45945714/

相关文章:

azure - 将图形引擎服务器部署到 Azure API 应用程序时,出现以下错误

c# - cmd批处理监听控制台应用程序的输出

c# - 将函数定义作为 CI 流程的一部分导入 API 管理

Wordpress 应用程序服务的路径映射非常慢

azure - 在 Azure 函数中执行导入模块时已加载同名程序集的错误

azure - Windows Azure 中 ServiceConfiguration.cscfg 文件的标准编码是什么?

c# - 使用动态 DocumentId 从 Azure Functions 访问 DocumentDb

azure - 如何重新触发 Azure Cosmos DB 中的 CosmosDBTrigger 事件或在处理事件时出现异常时获取触发的事件

c# - 根据输入从 Azure 函数启动和停止 Docker 容器

azure - Terraform Azure 函数应用程序 - 未正确启动函数的简单示例