我正在为服务总线触发器的Azure函数开发一个示例应用程序,但是在本地运行它时遇到以下问题。
A host error has occurred during startup operation 'c283f2ad-3bf2-4efe-99f9-73cef19ca6ae'.
[08-06-2020 12:29:59] Microsoft.Azure.WebJobs.ServiceBus: Microsoft Azure WebJobs SDK ServiceBus connection string 'Endpoint=sb://ntestsb1.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;[Hidden Credential]' is missing or empty
请在代码下方找到。
public static class Function1
{
[FunctionName("Function1")]
public static void Run([ServiceBusTrigger("sb-fun-transactional-dev", Connection = "Endpoint=sb://sb-fun-dev.servicebus.windows.net/;SharedAccessKeyName=<accessKeyName>;SharedAccessKey=<accessKey>")]string myQueueItem, ILogger log)
{
log.LogInformation($"C# ServiceBus queue trigger function processed message: {myQueueItem}");
}
}
答案 0 :(得分:3)
您不应将连接字符串放在Connection
参数中,而应将Azure函数应用程序配置中连接字符串设置的名称。 >
您收到的错误指出它找不到名称为<your-entire-connection-string>
的设置。
您的代码将变成类似
public static class Function1
{
[FunctionName("Function1")]
public static void Run([ServiceBusTrigger("sb-fun-transactional-dev", Connection = "sbConnString")]string myQueueItem, ILogger log)
{
log.LogInformation($"C# ServiceBus queue trigger function processed message: {myQueueItem}");
}
}
,您将在Function App Configuration - Application Settings下设置sbConnString
。
答案 1 :(得分:0)