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.