azureservicebus - Function App ServiceBusTrigger with Service Bus Emulator locally - Stack Overflow

I have the service bus emulator running in a docker container. I'm able to send messages to this s

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

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/en-us/azure/service-bus-messaging/test-locally-with-service-bus-emulator?tabs=automated-script

Share Improve this question asked Mar 11 at 15:20 Branden BarberBranden Barber 1,8682 gold badges18 silver badges17 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744785145a4593578.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信