Forum Discussion
Dataset refresh error Service principal
- 6 years ago
Hi Anonymous ,
The gateway used here is a deafult gateway which internally microsoft using for all the dataset. First use the below script in your local and use the fiddler to catch the exact error message. There are several reasons for bad reqeust. Find what is the reason for the bad request from the fiddler.
$applicationId = "" # Need to pass the clientid from devops variable $clientsec = "" | ConvertTo-SecureString -AsPlainText -Force # Need to pass from devops secret variable $credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $applicationId, $clientsec Connect-PowerBIServiceAccount -ServicePrincipal -Credential $credential -TenantId "" # Need to pass from devops variable $workspacename="PowerBI_CICD_PROD" $datasetname="AdventureReports" ## user credentials $username= "sadmin" $password= "Password@123" # Need to pass from devops secret variable ##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 ## update data source credentials $BounGateway=Invoke-PowerBIRestMethod -Url "groups/$($workspace.id)/datasets/$($datasetid)/Default.GetBoundGatewayDataSources" -Method GET | ConvertFrom-Json $UpdateUserCredential = @{ credentialType ="Basic" basicCredentials = @{ username= $username password=$password } } | ConvertTo-Json Invoke-PowerBIRestMethod -Url "gateways/$($BounGateway.value.gatewayId)/datasources/$($BounGateway.value.id)" -Method PATCH -Body $UpdateUserCredential | ConvertFrom-Json
Hi Anonymous ,
Please check if it hits the limitations:
- Service principal only works with new workspaces.
- My Workspace isn't supported when using service principal.
- Dedicated capacity is required when moving to production.
- You can't sign into the Power BI portal using service principal.
- Power BI admin rights are required to enable service principal in developer settings within the Power BI admin portal.
- You can't install or manage an on-premises data gateway using service principal.
- Embed for your organization applications can't use service principal.
- Dataflows management is not supported.
- Service principal currently does not support any admin APIs.
- When using service principal with an Azure Analysis Services data source, the service principal itself must have an Azure Analysis Services instance permissions. Using a security group that contains the service principal for this purpose, doesn't work.
I'm not familiar with Azure DevOps. You could reference these documents. Hope they can help you.
The service principal is now available for Power BI Embedded
Embedding Power BI content with service principal and application secret
Power BI Developer community January update
If these can't work, you could create a support ticket to get the dedicate help.
- Anonymous6 years agoNot applicable
i have created a support ticket, because i have checked all the things you mentioned.
Because also when the owner is changed for the dataset. The service principal is also allowed to refresh the dataset using an API call
- v-xuding-msft6 years agoCommunity Support
Hi Anonymous ,
Hope the issue will be resolved soon. And please share the solution here while it is solved. More people will benefit from this thread. Thanks in advance!