Forum Discussion
How to connect Power BI Service to an API with separate token authentication using service principal
- 1 year ago
Hi Anonymous,
Try the below suggestion:
To avoid using an on-premises data gateway, you can use Azure Functions or Logic Apps as a secure middleware proxy. This setup allows Power BI to connect to a single, simplified public endpoint.
The Azure Function handles the complex parts: it first calls the token endpoint using client credentials, gets the access token, then makes the actual API request with the required headers, and finally returns clean JSON data to Power BI.
In Power BI, you just use a basic Web.Contents() call to the Azure Function URL with anonymous authentication, since all authentication logic is handled within the Azure Function itself. To keep it secure, you should store secrets in Azure Key Vault or the function’s App Settings, and protect the function using an API key or IP restrictions.
This method ensures secure, reliable, and gateway-free scheduled refresh in Power BI Service.
If my response was helpful, consider clicking "Accept as Solution" and give us "Kudos" so that other community members can find it easily. Let me know if you need any more assistance!
Thanks for using Microsoft Fabric Community Forum.
Hi v-sgandrathi
Thank you for the information. The client has opted to connect directly to the database for now, as implementing Azure Functions is considered too involved.
- v-sgandrathi1 year agoCommunity Support
HI Anonymous,
Good to hear that you have opted to connect directly to the database for now. This approach definitely simplifies the setup and avoids additional infrastructure like Azure Functions or gateways, especially when you want to move quickly and keep things straightforward. Just keep in mind that if your database is on-premises or behind a firewall, you may still need an on-premises data gateway for scheduled refresh in Power BI Service.
Please consider marking the useful reply as accepted solution if it helped you, this will make it easier for others in the community to find the solution.
Thank you for using Microsoft Fabric Community Forum!