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 August 31st. Request your voucher.

0

Assigning Datasources to Service Principals

I've been trying to automate a couple of our workflows using the PowerBI API. 
One automation that I'm struggling with is refreshing a dataset.

 

A script that refreshes a dataset runs fine when run with a normal user that has admin access.
However, when running the script with a Service Prinicpal, It fails the refresh.

We know this is because the dataset that we want to refresh, requires a couple of datasources to be correct.

zeida_0-1660896556454.png

In our personal user accounts we can see these datasources in the web interface stored under the Settings > Manage Datasources tab.

zeida_2-1660899067836.png

Under Data Sources are the "Personal datasources"

 

zeida_1-1660896736772.png


What I'm wondering is how we can add these datasources to a Service Principal without the use of an On-prem or vnet gateway?

Status: Delivered

Hi @zeida,

 

Do you mean you would like to refresh your dataset with service principal? If so, you could complete it with the Datasets-Refresh Dataset in Group rest api. But you need make sure you have the required scope Dataset.ReadWrite.All and you need enable required options in Admin portal of your Power BI.

Use Power BI API with service principal (Preview) | Microsoft Power BI Blog | Microsoft Power BI

Use service principal profiles to manage customer data in multi-tenant apps - Power BI | Microsoft D...

 

As for the needs of gateway, Power BI refreshes your datasets with the credentials you provided for your data sources. If your data source is the one that couldn’t be accessed directly by Power BI service, then you need gateway to help you complete the connection. Service principal is just an identified used to call the rest api and data source couldn’t be added to service principal. No matter you are using Power BI account or service principal to call the api, Power BI will use the credential you provide to connect your data source and perform refresh.

 

Best Regards,    

Community Support Team _ Caiyun

Comments
v-cazheng-msft
Community Support
Status changed to: Delivered

Hi @zeida,

 

Do you mean you would like to refresh your dataset with service principal? If so, you could complete it with the Datasets-Refresh Dataset in Group rest api. But you need make sure you have the required scope Dataset.ReadWrite.All and you need enable required options in Admin portal of your Power BI.

Use Power BI API with service principal (Preview) | Microsoft Power BI Blog | Microsoft Power BI

Use service principal profiles to manage customer data in multi-tenant apps - Power BI | Microsoft D...

 

As for the needs of gateway, Power BI refreshes your datasets with the credentials you provided for your data sources. If your data source is the one that couldn’t be accessed directly by Power BI service, then you need gateway to help you complete the connection. Service principal is just an identified used to call the rest api and data source couldn’t be added to service principal. No matter you are using Power BI account or service principal to call the api, Power BI will use the credential you provide to connect your data source and perform refresh.

 

Best Regards,    

Community Support Team _ Caiyun

zeida
Regular Visitor

Hi @v-cazheng-msft ,

Thank you for your explanation.

One thing I forgot to mention is that the Service Principal is also the owner of the dataset. 

I can then not provide the credentials manually through the PowerBI browser without taking over the dataset.

In that case, how do I provide the credentials using a Service Principal before performing a refresh?