Reputation: 41
I am developing a sample application for Azure Function for Service Bus Trigger but Facing the below issue while running it locally.
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
Please find below the code.
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}");
}
}
Upvotes: 1
Views: 2742
Reputation: 33
do like this It worked for me.(This is for running Azure function locally) First add a new key in Values in local.settings.json file. Then use that name instead of connection String as displayed in screenshot.
Upvotes: 1
Reputation: 15551
You shouldn't put the connection string in the Connection
parameter, but the name of the connection string setting in Azure Function App Configuration.
The error you get states it cannot find the setting with the name <your-entire-connection-string>
.
Your code would become something like
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}");
}
}
and you would have a setting sbConnString
under the Function App Configuration - Application Settings.
Upvotes: 3