How can I trigger Fabric Notebook or Fabric data pipeline from Azure Data Factory?

Sunay Pistulkar 5 Reputation points
2024-10-11T09:43:46.26+00:00

I am trying to trigger fabric notebook via ADF via API calls but it is throwing an error.

Details: https://learn.microsoft.com/en-us/fabric/data-engineering/notebook-public-api#run-a-notebook-on-demand
Using above article's API

Error: {"requestId":"407e6421-9958-439b-9dfe-3ad3303c420c","errorCode":"Unauthorized","message":"The caller is not authenticated to access this resource"}

I have provided admin level permission to ADF user.

Please let me know easier way to trigger fabric notebook on demand..

Thanks,
Sunay

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
10,924 questions
Microsoft Fabric Training
Microsoft Fabric Training
Microsoft Fabric: A Microsoft unified data platform.Training: Instruction to develop new skills.
52 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Vinodh247 24,091 Reputation points MVP
    2024-10-11T10:22:24.1333333+00:00

    Hi ,

    Thanks for reaching out to Microsoft Q&A.

    The "Unauthorized" error indicates that the API call is not being authenticated properly, despite the permissions you have set up. To resolve this, ensure the following steps are taken:

    1. Authentication: Verify that Azure Data Factory is properly authenticating to Microsoft Fabric using a supported auth method, such as AAD. You can authenticate using a Service Principal or a MI (if your ADF has one). Make sure the token acquired is valid and that it is passed correctly in the API call.
    2. Access Token: When calling the Fabric Notebook API, you need to obtain a valid bearer token from Azure AD. Here is an outline of the process:
    • First, register an Azure AD app (if using a Service Principal) or use the Managed Identity of ADF.
    • Acquire an OAuth 2.0 token by calling Azure AD’s token endpoint.
      • Pass the token in the authorization header of your API request in bash:
        • Authorization: Bearer <access_token>
        API Permissions: Ensure that the Azure AD app or Managed Identity has the necessary permissions on Microsoft Fabric. You may need to assign the necessary roles or API permissions to the app, such as the "Fabric Admin" or other roles required to execute notebooks. Validating Token Scope: Ensure that the token you are using is valid for Microsoft Fabric API access. The token's scope should include the proper API permissions, such as https://fabric.microsoft.com/.default. Managed Identity Setup (Preferred): If using ADF’s Managed Identity, ensure that it is correctly set up in both ADF and Fabric. Assign the identity proper access to Fabric resources. Diagnostics: Use a tool like Postman to manually authenticate and make the same API call to check if the issue persists outside ADF. This can help isolate whether it's an authentication or configuration issue within ADF.

    For a simpler way to trigger the notebook, you could consider the following options:

    • Use Logic Apps or Azure Functions to handle the authentication and API call logic & trigger them from ADF as part of your pipeline.
    • Ensure that the user or identity making the API call has the correct permissions by checking the roles assigned to the user or service principal in Microsoft Fabric.

    Please 'Upvote'(Thumbs-up) and 'Accept' as an answer if the reply was helpful. This will benefit other community members who face the same issue.

    0 comments No comments

  2. Nandan Hegde 32,656 Reputation points MVP
    2024-10-11T11:24:36.89+00:00

    Plz refer the below blog :

    https://learn-it-all.medium.com/calling-a-fabric-data-pipeline-from-azure-data-factory-pipeline-b739418e6b34

    Note : it uses ROPC authentication which is not a secure form of auth as stated by MSFT itself :

    https://learn.microsoft.com/en-us/entra/identity-platform/v2-oauth-ropc

    Other way to trigger would be :

    leverage event trigger to trigger the fabric data pipeline which in turn would trigger the notebook

    You can upload the file from ADf which in turn would trigger the fabric pipeline


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.