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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
saifi777
New Member

PowerBI Service API not works with AzureAD federated with onPremise ADFS

HI, I am using PowerBI Premimum API to publish my report on frequent basis to PowerBI services. 

The Publish job is using an Azure Active directory Account (Premium Licence is prequired with that ) 

 

So basiacally we have OnPrem AD (example IntApp.com) thats migrated to Azure AD using ADConnect tool.  again the Azure AD is federated with onpremise AD using ADFS on IntApp.com

 

Now when i try to publish report to PowerBI service using API, i use my Admin account saifi@IntApp.com (Which exists in AAD)

with below code. I am getting ADFS Login Screen. 

 

 var userCreds = new UserPasswordCredential("saifi@IntApp.com", "password");

 var userAuthnResult1 = authenticationContext.AcquireTokenAsync(ProgramConstants.PowerBiServiceResourceUri,

                                                                              ClientID,  userCreds).Result;

 

I know the reason is Azure AD is federated with on Premise ADFS where it need NetWorkCredentials(). But since with API we do not have any way i can provide Credentialcache.DefaultCredential so AzureAD openop a popup for username and passwoed. 

 

My requirement is the webjob to work in background where it does not require any intervention. Please can any one assist.

 

Thanks

Saifi

3 REPLIES 3
Eric_Zhang
Employee
Employee


@saifi777 wrote:

HI, I am using PowerBI Premimum API to publish my report on frequent basis to PowerBI services. 

The Publish job is using an Azure Active directory Account (Premium Licence is prequired with that ) 

 

So basiacally we have OnPrem AD (example IntApp.com) thats migrated to Azure AD using ADConnect tool.  again the Azure AD is federated with onpremise AD using ADFS on IntApp.com

 

Now when i try to publish report to PowerBI service using API, i use my Admin account saifi@IntApp.com (Which exists in AAD)

with below code. I am getting ADFS Login Screen. 

 

 var userCreds = new UserPasswordCredential("saifi@IntApp.com", "password");

 var userAuthnResult1 = authenticationContext.AcquireTokenAsync(ProgramConstants.PowerBiServiceResourceUri,

                                                                              ClientID,  userCreds).Result;

 

I know the reason is Azure AD is federated with on Premise ADFS where it need NetWorkCredentials(). But since with API we do not have any way i can provide Credentialcache.DefaultCredential so AzureAD openop a popup for username and passwoed. 

 

My requirement is the webjob to work in background where it does not require any intervention. Please can any one assist.

 

Thanks

Saifi


@saifi777

The code snippet in your post works with my AAD account without any pop up. Since your questions is actually related to Azure AD, the ADFS and NetWorkCredentials are actually out of the topic of Power BI , I'd suggest you post it in the dedicated AAD forum, you will get better response there.

Thanks Eric thanks for reply. My problem is with the PowerBI API support.

The API does support pure AAD suthentication (pass Azure AD user and password) and below code works well

var userCreds = new UserPasswordCredential("saifi@IntApp..com", "password");

 

But if your AAD is Federated with ADFS, the microsoft Login page (in case of trying logging in Browser) will reditect to ADFS login page.

My problem is API does not have any mechanism where we can pass credential that is accepted by ADFS as its a second level of authentication.

Anonymous
Not applicable

Stumbled across this article a moment ago which might be of help.

 

https://blogs.msdn.microsoft.com/azuredev/2018/01/22/accessing-the-power-bi-apis-in-a-federated-azur...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors