web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :

D365: Service Bus Triggered Function error: Connection string 'AzureWebJobsServiceBus' is missing or empty

AjitPatra Profile Picture AjitPatra 469

Recently, while working on Service Bus triggered Azure Durable Function, we got an error saying “The function runtime is unable to start. Microsoft.Azure.WebJobs.ServiceBus: Microsoft Azure WebJobs SDK ServiceBus connection string ‘AzureWebJobsServiceBus’ is missing or empty”.

Below is the code that we were using:

 [FunctionName("UpdateGlobalRatesOnRSLs")]
        public static async Task Run([ServiceBusTrigger("%QueueName%")] Message message, MessageReceiver messageReceiver, string lockToken, [OrchestrationClient]DurableOrchestrationClient starter, ILogger log)
        {
            string inputMessage = Encoding.UTF8.GetString(message.Body);
            log.LogInformation($"message - " + inputMessage);
            MessageReceiver receiver = messageReceiver;
            string token = lockToken;
}

NOTE: QueueName used above is defined in localsettings.json as a key/value pair to make it configurable.

We can fix this issue in couple of ways:

  • We can provide a Connection String name in the Service Bus Trigger attribute which will be defined in localsettings.json as shown below:
  [FunctionName("UpdateGlobalRatesOnRSLs")]
        public static async Task Run([ServiceBusTrigger("%QueueName%", Connection = "ServiceBusConnectionString")] Message message, MessageReceiver messageReceiver, string lockToken, [OrchestrationClient]DurableOrchestrationClient starter, ILogger log)
        {
            string inputMessage = Encoding.UTF8.GetString(message.Body);
            log.LogInformation($"message - " + inputMessage);
            MessageReceiver receiver = messageReceiver;
            string token = lockToken;
}

In localsettings.json:

{
  "IsEncrypted": false,
  "Values": {   
    "QueueName": "devglobalrateupdatequeue",
    "ServiceBusConnectionString": "[PrimaryConnectionStringOfSharedAccessPolicy]"
  }
}
  • It can be left blank in the Service Bus Trigger attribute and in localsettings.json file define a key/value pair with name AzureWebJobsServiceBus
[FunctionName("UpdateGlobalRatesOnRSLs")]
        public static async Task Run([ServiceBusTrigger("%QueueName%")] Message message, MessageReceiver messageReceiver, string lockToken, [OrchestrationClient]DurableOrchestrationClient starter, ILogger log)
        {
            string inputMessage = Encoding.UTF8.GetString(message.Body);
            log.LogInformation($"message - " + inputMessage);
            MessageReceiver receiver = messageReceiver;
            string token = lockToken;
}

In localsettings.json:

{
  "IsEncrypted": false,
  "Values": {   
    "QueueName": "devglobalrateupdatequeue",
    "AzureWebJobsServiceBus": "[PrimaryConnectionStringOfSharedAccessPolicy]"
  }
}

NOTE: During deployment of the Durable Function to Azure, create the above key/value pair application settings in Function App –> Function App Settings –> Manage Application Settings –> New Application Setting and Save them.

Hope it helps !!


This was originally posted here.

Comments

*This post is locked for comments