1

I have the Azure Servicebus emulator running locally and now I want to connect to it from a durable function inside a different container, using a ServiceBus trigger.
But I get the following error:

Azure.Messaging.ServiceBus.ServiceBusException: Name or service not known ErrorCode: HostNotFound (ServiceCommunicationProblem)

The servicebus emulator is running fine. When I run a function app locally and use the following connection string to create a ServiceBusClient:

Endpoint=sb://localhost:5672;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=SAS_KEY_VALUE;UseDevelopmentEmulator=true;

I can successfully send a ServiceBusMessage to a queue.1 (as defined in the emulator config). So the emulator is running and I can send something to a queue from my own machine.

My .NET 9.0 (isolated) function app running inside a container is setup a bit different. It uses the following trigger setups:

[ServiceBusTrigger("%ServiceBusTopic%", "%ServiceBusSubscription%", Connection = "AzureServiceBusConnection")]
[ServiceBusTrigger("%ServiceBusIncomingQueue%", Connection = "AzureServiceBusConnection", IsBatched = true)]

And I add the following environment variables to the container when it's created: (see connection options)

-e AzureServiceBusConnection__fullyQualifiedNamespace="sbemulatorns" 
-e ServiceBus="Endpoint=sb://sb-emulator;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=SAS_KEY_VALUE;UseDevelopmentEmulator=true;"
-e ServiceBusSubscription="subscription.1"
-e ServiceBusTopic="sb-topic-dev"
-e ServiceBusIncomingQueue="queue-local4-dev"

(I have defined a queue queue-local4-dev and topic sb-topic-dev and subscription subscription.1 in the emulator Config.json and then ran the LaunchEmulator.ps1 script again)

Do I somehow have to make both the function app container and the emulator container use the same docker network? I now start the function app container using --network=mynetwork, which is the same as the network my storage container is using... should I somehow make the emulator part of the same network? I don't know how to do this, there is already a section defined inside the docker-compose-default.yml file in the emulator project, which seems to relate to the sql-edge container as well...
I'm basically looking for the correct configuration of the connection settings when a function app inside a container uses a ServiceBusTrigger.

4
  • Can you share your complete function code? Commented Jan 23 at 14:07
  • What is the .net version you are using? Commented Jan 23 at 14:15
  • @RithwikBojja Function app running in container is .NET 9.0, isolated Commented Jan 23 at 14:46
  • @IkhtesamAfrin I'll see if I can create a basic stripped down version for this issue, codebase is much too big Commented Jan 23 at 14:58

1 Answer 1

0

TLDR

Assuming that DNS can resolve the name sb-emulator and the AMQP ports are open, if you change the environment variable assignments, it should resolve your issue:

-e AzureServiceBusConnection="Endpoint=sb://sb-emulator;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=SAS_KEY_VALUE;UseDevelopmentEmulator=true;"
-e ServiceBusSubscription="subscription.1"
-e ServiceBusTopic="sb-topic-dev"
-e ServiceBusIncomingQueue="queue-local4-dev"

Context

Your trigger is configured to use the connection named AzureServiceBusConnection:

[ServiceBusTrigger(
    "%ServiceBusTopic%", 
    "%ServiceBusSubscription%", 
    Connection = "AzureServiceBusConnection")
]

In your configuration, you're setting the fully qualified namespace name for that connection:

-e AzureServiceBusConnection__fullyQualifiedNamespace="sbemulatorns" 

This causes the trigger to resolve that connection as a request to use identity-based auth. (src)

The bindings don't see your connection string at all, because you're assigning it to an item named "ServiceBus" that the trigger knows nothing about. To use the connection string, you'll need to remove the __fullyQualifiedNamespace and assign the connection string directly to AzureServiceBusConnection:

-e AzureServiceBusConnection="Endpoint=sb://sb-emulator;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=SAS_KEY_VALUE;UseDevelopmentEmulator=true;"

More discussion and context can be found in:

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

Comments

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.