Trigger A Fabric Notebook Through The API
When you want to schedule the export of bc2adls (Bertverbeek4PS/bc2adls) you also must schedule the export of the Fabric Notebook after the export from Business Central to Microsoft Fabric is finished.
See also my blogpost in the past:
BC2ADLS: MS Fabric enabled part 2 – Discover Microsoft Business Central (bertverbeek.nl)
But now there is an API available to trigger the notebook! In that case when you finished the bc2adls export you can trigger the notebook directly. So you have almost a near real time copy of your records.
Notebook API
Currently it is possible to run a notebook on-demand:
Manage and execute Fabric notebooks with public APIs – Microsoft Fabric | Microsoft Learn
You can call the notebook with the following API request:
POST https://api.fabric.microsoft.com/v1/workspaces/4f8a8c2e-86b0-405d-a7e5-a4c84214f1dd/items/bd4ac8cf-67bf-4ae1-a4cb-321844f8d019/jobs/instances?jobType=RunNotebook
The GUID 4f8a8c2e-86b0-405d-a7e5-a4c84214f1dd is your workspace GUID and bd4ac8cf-67bf-4ae1-a4cb-321844f8d019 is the notebook GUID.
When you navigate to the notebook inside MS Fabric you can extract it from the URL:
In the body you don’t have to declare anything:
{
"executionData": {
}
}
When you to the POST request and look inside MS Fabric you can see that it is executed:
NB: to run the notebook you need to do it under a real user. It doesn’t allow you to it with the client credentials flow yet. It will say that he accepted it. But the Notebook will not run.
It only will run with the Authorization flow code and Password credentials.
Business Event inside bc2adls
But now you need to receive a notification that the bc2adls export is finished. Lucky, we have since BC22 External Business Events. And in the bc2adls there is an External Business Event when the export is finished:
So in that way we can use Power Automate or Logic app (or any other app) to kick of the Fabric notebook straight away when bc2adls is finished.
Power Automate Flow
When you use Power Automate you can use also the trigger “When a business event occurs (V3)”:
And select the event “Export is finished”.
When that is happen you can kick of the API of the Fabric Notebook:
And when you have done this your notebook will start directly when the export is finished. So i that case you have a real near time copy of your data in Microsoft Fabric.
NB: I have stored the Client Secret and password directly in the Power Automate flow because of simplicity for this blog. But please stores those values safely into a key vault for example.
An example of the Power Automate flow you can download here:
Power Automate Package
2 COMMENTS