Azure Service Bus Bindings
Post by: syed hussain in All Integration Design Patterns Tips
Summary
Here is a quick tip for anyone trying to create an Azure Function Service Bus binding. When copying the Service Bus SAS key, the Visual Studio compiler may complain that the endpoint connection hasn’t been specified. This post documents what you should do when working with SAS keys.
Azure Service Bus Settings
Edit the local.settings.json as follows:
Notice below that I have removed the Entitypath from the Endpoint Connection String.
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"SBConnection": "Endpoint=sb://eaxservbus.servicebus.windows.net/;SharedAccessKeyName=root;SharedAccessKey=+jawfQQOBNhbsdgjsgjsadghgjo8r7do6fwi3hrk3we;"
}
}
using System;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Extensions.Logging;
namespace EIP_PointtoPoint_Messaging
{
public class Function1
{
[FunctionName("Function1")]
public void Run([ServiceBusTrigger("eax01", Connection = "SBConnection")] string myQueueItem, ILogger log)
{
log.LogInformation($"C# ServiceBus queue trigger function processed message: {myQueueItem}");
}
}
}