Microsoft Azure WebJobs SDK ServiceBus连接字符串'ServiceBusSettings.ConnectionString'丢失或为空

时间:2019-10-06 05:55:38

标签: azure azureservicebus azure-webjobs azure-servicebus-queues azure-servicebus-topics

主要方法如下所示,

class Program
{
    static void Main(string[] args)
    {
        var builder = new HostBuilder();
        builder.ConfigureWebJobs(b =>
        {
            b.AddAzureStorageCoreServices();
            b.AddServiceBus(sbOptions =>
            {
                sbOptions.MessageHandlerOptions.AutoComplete = true;
                sbOptions.MessageHandlerOptions.MaxConcurrentCalls = 16;
            });
        });
        builder.ConfigureLogging((context, b) =>
        {
            b.AddConsole();
        });

        var host = builder.Build();

        using (host)
        {
            host.Run();
        }
    }
}

local.settings.json 文件就像

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet",
    "ServiceBusSettings.ConnectionString": "Endpoint=***",
    "SQLConnectionString": "Server=.;Database=***;Trusted_Connection=True"
  }
}

并且正在消耗 ServiceBusTrigger ,如下所示,

public static class RegisterSK
{
    [FunctionName("RegisterSK")]
    public static void ProcessQueueMessage([ServiceBusTrigger("topicname", "S2", Connection = "ServiceBusSettings.ConnectionString")]string topicItem, ILogger log)
    {
        //logger.LogInformation(message);
    }
}

在运行程序时出现类似

的错误

Microsoft Azure WebJobs SDK ServiceBus连接字符串'ServiceBusSettings.ConnectionString'丢失或为空。

Azure WebJobs的新手。没有做错什么。参考了先前的解决方案,但没有任何适当的答案。

1 个答案:

答案 0 :(得分:1)

您需要使用AppSettings.json并将连接字符串保留为

    path.addArc(rect, 0f, -180f)