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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
mbutler71
Advocate I
Advocate I

Automating Updating a Dataset's Datasource and the Gateway Datasource "Maps To" with PowerShell

I was working to implement true CI/CD between Azure DevOps and our Power BI service. 

Had a lot of trouble updating the Dataset's (report) Datasource and having it automatically "Maps To" the correct Gateway Datasource (DSN). 

So, here is the solution that worked:
The Service Principal has access to update the Dataset's datasouce, but doesn't have access to the Gateway datasource (interface doesn't allow it at this time). So, we use the Service Principal to update the datasource in one PowerShell script, and a Generic Id to refresh the gateway (Bind To Gateway) in another PowerShell script. These two tasks, running sequentially, now run successfully in our DevOps Release Pipeline.

Hope this helps someone.

6 REPLIES 6
m-colbert
Resolver II
Resolver II

@mbutler71 

When adding data source users in the gateway admin, you can specifiy a security group. If you add the service principal to the security group, this should then allow you to use the service principal to bind the gateway datasource.
Hope this helps.

khemkandel
New Member

Hi,

I am using org service account that's synced to Azure AD. When I manually login (Login-PowerBIServiceAccount) it works - I get pop up to login where I would enter service account anme and password into my org login page. Then it connects and I can bind the gateway.  However when I try to use below code for automation, it doesn't work.

 

$PbiSecurePassword = ConvertTo-SecureString $password -Force -AsPlainText
$PbiCredential = New-Object Management.Automation.PSCredential($username, $PbiSecurePassword)

 

Connect-PowerBIServiceAccount -Credential $PbiCredential
Login-PowerBIServiceAccount -Credential $PbiCredential

 

Any Ideas: I am thinking that it's because I am not using @onmicrosoft.com account and for some reason PowerBi commandlet doesn't  support connect / login doesn't support  accounts that are synced via Azure Sync??

 

Any advise is appreciated. 

 

Thanks

 

mbutler71
Advocate I
Advocate I

Not sure where to submit that, but they should allow the Service Principal accounts to be added to the Gateway Datasource "Users." 
That would help. It would allow us to use one account for the whole process. 

Hi @mbutler71,

You can discuss these on the power bi 'feature release' blog('power bi xxxx feature summary' which mentioned the embedded features) or submit and the idea forum.

Here is the link of ideas foumn:

Power BI Ideas

Regards,
Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

v-shex-msft
Community Support
Community Support

HI @mbutler71,

Thanks for sharing, This should help if someone faced similar requirements.
BTW, I think you can also consider submitting ideas or contact the power bi dev team to report this requirement to help improving power bi features.

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.