Service Bus: Ip has been prevented to connect to the endpoint

Schneider, Michael 65 Reputation points
2025-03-28T12:16:17.86+00:00

Since some days we are facing issues with our Azure Functions (ASP) connecting to the Azure Sevice Bus (Standard, not in VNET). This was working before without any issues and since some daiys it is not working anymore on all our environments so I wonder if there is any general issue.

 

Message: Put token failed. status-code: 401, status-description: Ip has been prevented to connect to the endpoint.For more information see:Virtual Network service endpoints

 

The Azure Functions are communication via Nat Gatway and the public Ip address is set in the IP Filter List of the SBN.  The Vnet NSG allwos traffic form Function Vnet to the Subnet, used for the NAT Gateway.

I can see the blocked requests in the SBN Logs. As far as I deactivate the IP filter to allow any traffic, it is working again. I also can see, that the used outbound Ip is exactly the same which is set in the ip filter list. We are susing the AMQP protocol.

Also without Nat and with standard Function Outbound Ips it ist not working

 

[Error] An unhandled exception occurred in the message batch receive loop (namespace='....servicebus.windows.net', entityPath='.../Subscriptions/...', singleDispatch='False', isSessionsEnabled='False', functionId='Host.Functions.ProcessTripsBc').System.UnauthorizedAccessException : Put token failed. status-code: 401, status-description: Ip has been prevented to connect to the endpoint.For more information see:Virtual Network service endpoints:Event Hubs: https://go.microsoft.com/fwlink/?linkid=2044192Service Bus: https://go.microsoft.com/fwlink/?linkid=2044235IP Filters:Event Hubs:  https://go.microsoft.com/fwlink/?linkid=2044428Service Bus: https://go.microsoft.com/fwlink/?linkid=2044183TrackingId:0ac55176-7c9d-4577-bc35-246418724a7d_G0

Azure Service Bus
Azure Service Bus
An Azure service that provides cloud messaging as a service and hybrid integration.
704 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Silvia Wibowo 6,046 Reputation points Microsoft Employee Volunteer Moderator
    2025-04-02T20:23:41.86+00:00

    Hi @Schneider, Michael , thank you for confirming that your issue has been resolved.

    Issue:

    • Service Bus Namespace (Standard SKU) with IP filter (SBN firewall) set to Public IP Address of NAT Gateway.
    • Azure Function is integrated with vnet, the subnet is set to use NAT Gateway.
    • Verified that NAT Gateway IP address is correct in SBN firewall.
    • Request from Azure Function to SBN is blocked.

    Solution:

    • Turns out that Azure Function's subnet has service endpoint for Service Bus. This causes requests from Azure Function is received in SBN with private IP address, not NAT Gateway public IP address.
    • Remove service endpoint for Service Bus in Azure Function's subnet.
    • Request from Azure Function to SBN goes through.

    Please accept an answer if correct. Original posters help the community find answers faster by identifying the correct answer. Here is how.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.