Reputation: 1078
The Main Method is as shown below,
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();
}
}
}
And the local.settings.json file is like,
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"ServiceBusSettings.ConnectionString": "Endpoint=***",
"SQLConnectionString": "Server=.;Database=***;Trusted_Connection=True"
}
}
And am Consuming ServiceBusTrigger as shown below,
public static class RegisterSK
{
[FunctionName("RegisterSK")]
public static void ProcessQueueMessage([ServiceBusTrigger("topicname", "S2", Connection = "ServiceBusSettings.ConnectionString")]string topicItem, ILogger log)
{
//logger.LogInformation(message);
}
}
While running the program am getting error like,
Microsoft Azure WebJobs SDK ServiceBus connection string 'ServiceBusSettings.ConnectionString' is missing or empty.
Am new to Azure WebJobs. Not getting what wrong am doing. Refereed previous solutions but didn't got any proper answer.
Upvotes: 3
Views: 3598
Reputation: 222582
You need to use AppSettings.json and keep the connection string as
"AzureWebJobs": { "extensions": { "ServiceBus": { "ConnectionStrings": { "Primary": "[your connection string here]" } } } }
Upvotes: 1