Forum Discussion
Set Service Principal s Dataset Owner
- 6 years ago
Hi dom99 ,
Using powershell it is possible
I already created the entier script and published here
https://gallery.technet.microsoft.com/AzureDevOps-CICD-for-fefd58b8
The powershell scripts looks like
$applicationId = "" $clientsec = "" | ConvertTo-SecureString -AsPlainText -Force # $credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $applicationId, $clientsec Connect-PowerBIServiceAccount -ServicePrincipal -Credential $credential -TenantId "" $workspacename="PowerBI_CICD_PROD" $datasetname="AdventureReports" ##Getworksapce $workspace =Get-PowerBIWorkspace -Name $workspacename # GetDataSets $DatasetResponse=Invoke-PowerBIRestMethod -Url "groups/$($workspace.id)/datasets" -Method Get | ConvertFrom-Json # Get DataSet $datasets = $DatasetResponse.value foreach($dataset in $datasets){ if($dataset.name -eq $datasetname){ $datasetid= $dataset.id; break; } } ## Take Over DataSet Invoke-PowerBIRestMethod -Url "groups/$($workspace.id)/datasets/$($datasetid)/Default.TakeOver" -Method Post
Hiya!
Although I am pretty late to this party here, I still wanted to distribute two blog posts that are very much related to this topic. So, in case someone finds him/herself in the situation where a service principal needs to own the power bi dataset, I hope you find any of the following helpful.
Blog Post A:
https://www.tackytech.blog/how-to-make-a-service-principal-the-owner-of-a-power-bi-dataset/
A walkthrough on how to take over a dataset by a service principal via an Azure DevOps pipeline. Likewise to the accepted answer in this thread here, the core is also a Powershell script that can be used outside an Azure DevOps pipeline as well.
Blog Post B:
An ETL flow in Azure Data Factory where the data factory is responsible for updating the oauth2 token for all data sources in the power bi dataset prior to kickstarting the dataset refresh (via managed identity). Here, a prerequesite is that the dataset is owned by a service principal.
Once again, I hope this is helping! 🙂
/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/