Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
shane-ds
Frequent Visitor

How to Upload DataFlow via Custom Azure Web Function

Hi,

 

I've been trying to write an Azure Web Function (in C#) that can upload DataFlow to PowerBI, but uploading a DataFlow is blocked at every turn.

 

[1] I've used a Registered App (ClientId + ClientSecret) via PublicClientApplicationBuilder which has worked in so far. It authenitcates without issue, able to see Workspaces and create Workspaces, assign users, but cannot Upload a DataFlow. This login type is denied by the API for reasons.. 

 

[2] There is maybe a way of using a registered app to upload 'On Behalf' of a user, but this I have not gotten working either.

 

[3] If I attempt to use User Credentials (Username, Password) to login, this is blocked by Multi-Factor Authentication

 

[4] The most promising approach I have is to use Azure CLI to login (user login) via PowerShell, copy the bearer token, and use that to get a login. The PowerBIClient seems to get created okay, but I get 'Forbidden' when accessing the Groups, code which works with an App Reg login.

 

var tokenCredentials = "xxxx" //Bearer Token Sourced from Azure CLI, 'Az Login' 
var powerBIAPIURL = "https://analysis.windows.net/powerbi/api/.default";
var powerBIClient = new PowerBIClient(new Uri(powerBIAPIURL), tokenCredentials);
try {
var groups = await _powerBIClient.Groups.GetGroupsAsync($"name eq '{workspaceName}'");
...
} catch (HttpOperationException) {

Microsoft.Rest.HttpOperationException: 'Operation returned an invalid status code 'Forbidden''

 

I'm confused by the number of paths and that each one is seemingly arbitrarily blocked. Which path is the right one? And how do I get past these blockers.

3 REPLIES 3
Anonymous
Not applicable

HI @shane-ds,

Did you mean to use azure function to invoke power bi rest API? if that is the case, I'd like to suggest you to take a look at the following blog:

Developing for Power BI using Azure Functions - Ju... - Microsoft Power BI Community

Regards,

Xiaoxin Sheng

Thanks, but, if not here, where else can I go to get relevant support?

Yes, I'm using an Azure Function to invoke the PowerBI REST API. The blog only covers Service Principal authentication, which I already understand and have working.

 

According to the following PowerBI REST API documentation page

https://learn.microsoft.com/en-us/rest/api/power-bi/imports/post-import 

Limitations

  • Dataflows with service principal aren't supported.

This is the blocker. I need it unblocked. The code I've writted verifies that Service Principals are indeed arbitrarily denied the ability to upload a DataFlows. I need an alternate means or backdoor to get around this arbitrary denial of service. Or a means of getting a user Access Token that can bypass MFA and isn't presented with 'Forbidden' whenever I try to invoke the Power BI REST API using such a token.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.