4

I have the service bus emulator running in a docker container. I'm able to send messages to this service bus successfully using code, but I'm unable to get function app service bus triggers to work. Specifically - I can't find the correct connection name in my config

// local.settings.json

{
  "Values": {
    "ServiceBusConnection__fullyQualifiedNamespace": "sb://localhost:5672"
  }
}
// Function1.cs

[Function(nameof(ServiceBusTest))]
public async Task ServiceBusTest(
    [ServiceBusTrigger(queueName: Queues.SmokeTest, Connection = "ServiceBusConnection")]
    RequestBase @event)
{
    await Task.CompletedTask;
}

This results in the following error

Exception: Azure.Messaging.ServiceBus.ServiceBusException: Connection refused ErrorCode: ConnectionRefused (ServiceCommunicationProblem)

I've tried a few values for my service bus connection config, but I've been getting this same error.

Here's some of the documentation for testing locally with the emulator https://learn.microsoft.com/en-us/azure/service-bus-messaging/test-locally-with-service-bus-emulator?tabs=automated-script

1 Answer 1

3

By specifying __fullqQualifiedNamespace you are directing the trigger to use Entra-based credentials for authorization with the emulator and a TLS-based connection, neither of which is supported. As a result, the emulator is refusing the connection.

To work with the emulator, you must use a connection string. Adapting your example, the updated appsettings would look like:

{
  "Values": {
    "ServiceBusConnection": "Endpoint=sb://localhost;SharedAccessKeyName=FakeKey;SharedAccessKey=FakeValue;UseDevelopmentEmulator=true;"
  }
}

The shared access key name and value are arbitrary, as they must be present but don't truly matter. The important part is ensuring the UseDevelopmentEmulator=true slug, which causes the connection to initiate without TLS for the emulator.

Sign up to request clarification or add additional context in comments.

2 Comments

This works great, but I'm struggling to find any docs that say you can do this. I don't suppose this is documented anywhere that you're aware of?
@tarrball: The only emulator docs that I'm aware of is the official overview page (learn.microsoft.com/azure/service-bus-messaging/…), which really should mention this in the known limitations, but does not. I'll pass that along to the folks who own the emulator and make them aware of the confusion.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.