Closed lhammerbh closed 5 months ago
A couple weeks ago the API wasn't there. Properly this wil indeed work maybe: https://learn.microsoft.com/en-us/fabric/data-engineering/notebook-public-api#run-a-notebook-on-demand
But I have never tried it. Need to try it maybe. That will be a good idea. Then we can use also a Power Automate function for it.
@lhammerbh you can indeed run the Notebook through the API! So in that case you can trigger the Business Event from BC in Power Automate or Logic App then start the notebook.
You can do that with an Post to:
https://api.fabric.microsoft.com/v1/workspaces/
And in the body the following JSON: { "executionData": {
}
}
Scope of the request must be: https://api.fabric.microsoft.com/Item.ReadWrite.All
And in the app registration the following permissions:
Did you get this to work, Bert?
I'm having a hard time to get it to work in Postman. It keeps telling me "BadRequest". And I tried to follow your recipe.
Sorry to ask you about this, but maybe you can help me further:
My call is a POST to https://api.fabric.microsoft.com/v1/workspaces/{{WORKSPACE_ID}}/items/{{ARTIFACT_ID}}/jobs/instances?jobType=RunNotebook Workspace_ID is id of workspace and ARTIFACT_ID is id of notebook
Body is: { "executionData": { "parameters": { "parameterName": { "value": "new value", "type": "string" } }, "configuration": { "conf": { "spark.conf1": "value" }, "defaultLakehouse": { "name": "grm_bc2adls_lakehouse"
},
"useStarterPool": true
}
}
}
Can you share how you did it successfully?
I have indeed got it working. In the body you can only have this: { "executionData": {
}
}
Nothing more.
And for getting the credentials:
Thanks for your help, Bert. I am following your recipe. Unfortunately, I am still getting a BadRequest. The token is coming back as it should. The request is a POST with https://api.fabric.microsoft.com/...../[WORKSPACE_ID]/items/[NOTEBOOK_ID]/jobs/instances..... The body is only containing empty "executionData", like you specified.
I am wondering, if I need to enable something in the Fabric configuration, or if I am missing something else.
You don't have to setup anything in Fabric.
Only in the API set the permissions:
ANd is your GUID workspace correct?
And can you get all items with a GET request to: https://api.fabric.microsoft.com/v1/admin/items
Thanks for all you help, Bert
The app registration now have all the api permissions as you showed (except Tenant.ReadWrite.All). I have checked workspace id and notebook id several times (I'm grabbing them from the url, when viewing the notebook in fabric). Even with the simple GET https://api.fabric.microsoft.com/v1/admin/items, I receive a Bad request response
The only thing that is not yet verified is the info around the token:
Auth Url is: https://login.microsoftonline.com/{{TenantId}}/oauth2 And Access Token Url is: https://login.microsoftonline.com/{{TenantId}}/oauth2/token
My Auth URL is: https://login.microsoftonline.com/{{TenantId}}/oauth2/v2.0/authorize
Access Token URL is: https://login.microsoftonline.com/{{TenantId}}/oauth2/v2.0/token
Otherwise we can plan a meeting.
If you do have the time, Bert, that is highly appreciated. I'm available today between 13-15 CET. Or tomorrow between 11-12 CET Or friday between 9-11.30 CET
Lets do friday. I can also between 9-11.30 CET. Could you send me an invite to bverbeek@4ps.nl?
Hi Bert
In the authorization, I have added the Auth Request parameter:
resource https://analysis.windows.net/powerbi/api
And now everything is working correctly.
So I will thank you for all your help.
I will cancel our meeting on friday.
We will be working on triggering the CopyBusinessCentral notebook, when the extract of the delta files from Business Central is complete, so we can have consolidated data available as soon as possible.
I will get back to you on our experience in doing this.
Yours Lars Hammer
Created a blog post also about this: https://www.bertverbeek.nl/blog/2024/01/16/trigger-a-fabric-notebook-through-the-api/
Hi Bert
We are now successfully running BC2ADLS in a Fabric setup. Data are coming through correctly, and the fabric notebook is working beautifully in the new version.
I have seen that in the data lake version, you have suggested a Power Automate app that can trigger the data factory pipeline corresponding to the notebook.
Have you been looking into the how we can trigger the notebook in the Fabric solution, when the BC2ADLSE component has completed the delta export? Or do you have any thoughts on this?
I have been looking into, whether it is possible to use the Fabric Rest API's, that could be called from a Power Automate app: https://learn.microsoft.com/en-us/rest/api/fabric/articles/?source=recommendations Especially the notebooks api: https://learn.microsoft.com/en-us/fabric/data-engineering/notebook-public-api
But I am having issues getting it to work.
Sorry to use the issues list for this, but I didn't know, where else to put it.
Yours Lars Hammer