gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 04:24:05 25 4
gpt4 key购买 nike

主要方法如下所示,

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 新手。不明白我做错了什么。查阅了之前的解决方案,但没有得到任何正确的答案。

最佳答案

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

"AzureWebJobs": { "extensions": { "ServiceBus": { "ConnectionStrings": { "Primary": "[your connection string here]" } } } }

关于azure - Microsoft Azure WebJobs SDK ServiceBus 连接字符串 'ServiceBusSettings.ConnectionString' 丢失或为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58254606/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com