ARTICLE AD BOX
I'm using .NET Aspire with an ASP.NET api server, Azure service bus and Azure functions (isolated worker model), all running locally.
However, the problem is that I can't seem to connect to service bus from function, even though I have checked that the connection string provided is the same. It can neither consume or write to the queue, and it hangs indefinitely.
string? connectionString = Environment.GetEnvironmentVariable( "SERVICE_BUS_CONNECTION_STRING"); await using var client = new ServiceBusClient(connectionString); string queueName = "tasksQueue"; ServiceBusSender sender = client.CreateSender(queueName); ServiceBusMessage message = new ServiceBusMessage("Health check message"); await sender.SendMessageAsync(message);My code to send, and in debugger, it's stuck at last line. After a while, it returns "No connection could be made because the target machine actively refused it."
A few checks I have done:
Connection string is there during runtime in debugger and this same string works for api server to the service bus. The connection string is passed by Aspire and it isEndpoint=sb://localhost:34628;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=SAS_KEY_VALUE;UseDevelopmentEmulator=true;
And I have attached a photo of the Aspire resources page and all seems to be running without any errors. The queue specific with name tasksQueue already exist in service bus.

I couldn't find any solution to this online and I have been stuck for a while so I appreciate any help. Maybe there is some firewall blocking the access, but this is all running locally, so I couldn't find anything that would block it.
