Rest call failed with client error in Source ADF , status code 401 Unauthorized with Service bus in Azure Cloud

chaitanya.K 20 Reputation points
2025-02-06T21:18:10.75+00:00

Hi,

Trying to post a JSON message to Service bus queue via ADF REST API call but ended up the following error message. The ADF has the service bus owner and sender roles. ADF and service bus are in different virtual networks (West US and West US2) in the same subscription and resource group and private endpoints are enabled for both resources. Virtual network IP CIDR is also whitelisted in Service bus.
User's image

Thank you.

Azure Service Bus
Azure Service Bus
An Azure service that provides cloud messaging as a service and hybrid integration.
662 questions
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,206 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Chandra Boorla 7,810 Reputation points Microsoft Vendor
    2025-02-07T06:56:06.6633333+00:00

    @chaitanya.K

    Greetings & Welcome to Microsoft Q&A forum! Thanks for posting your query!

    This error indicates that the Azure Data Factory (ADF) pipeline is failing to post a JSON message to the Service Bus due to a 401 Unauthorized error. Even though the ADF has the required roles (Service Bus Owner and Sender), the issue likely stems from network restrictions or authentication configuration.

    Understanding the Error

    The error message indicates that the Azure Data Factory is attempting to connect to a Service Bus queue but is being prevented.

    • ErrorCode=RestCallFailedWithClientError - This means the ADF was unable to complete the REST API call to Service Bus.
    • Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException - This indicates a general exception related to the ADF's data transfer capabilities.
    • Message=Rest call failed with client error, status code 401 Unauthorized - This points to a 401 Unauthorized error, which means the ADF is attempting to access the Service Bus queue without the necessary permissions.
    • Response: <Error> <Code>401</Code> <Detail>Ip has been prevented to connect to the endpoint - This confirms that the ADF's IP address is being blocked from accessing the Service Bus endpoint.

    Here are some potential causes and resolutions that might help you in resolving the issue:

    Authentication Issues - Ensure that the ADF has the correct permissions to access the Service Bus. Even though you mentioned that ADF has the service bus owner and sender roles, double-check that the roles are correctly assigned and that there are no issues with the authentication token being used.

    Network Configuration - Since ADF and the Service Bus are in different virtual networks, ensure that the private endpoints are correctly configured and that the necessary network rules are in place. Verify that the virtual network IP CIDR is indeed whitelisted in the Service Bus.

    Service Bus Configuration - Check the Service Bus settings to ensure that it is configured to accept connections from the ADF's virtual network. Sometimes, additional settings might be required to allow cross-network communication.

    Token Expiration - If you are using a token for authentication, ensure that it has not expired. You may need to refresh the token before making the API call.

    Service Bus Namespace - Ensure that the correct Service Bus namespace is being targeted in your API call. A mismatch in the namespace can lead to authentication failures.

    Please refer to the links provided below, as they might offer some insights that could help you address your question.

    Please refer to this similar thread:

    I hope this information helps. Please do let us know if you have any further queries.


    If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.

    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.