Open gpnikhil opened 2 weeks ago
If the connection already exists on the Gateway I have used the following to auto select the connection.
Get workspace using
$workspace = Get-PowerBIWorkspace -Name $workspaceName
Get datasets in workspace
$datasets = Invoke-PowerBIRestMethod -Url "groups/$($workspace.id)/datasets" -Method Get | ConvertFrom-Json
Then for each dataset, takeover the dataset and then bind to gateway connection
foreach ( $dataset in $datasets.value )
Invoke-PowerBIRestMethod -Url "groups/$($workspace.id)/datasets/$($datasetid)/Default.TakeOver" -Method POST
Invoke-PowerBIRestMethod -Url "groups/$($workspace.id)/datasets/$($datasetid)/Default.BindToGateway" -Body $body -Method POST | ConvertFrom-Json
As a final step I also refresh the dataset to make sure it processes and has data if a new dataset.
Invoke-PowerBIRestMethod -Url "groups/$($workspace.id)/datasets/$($datasetid)/refreshes" -Method POST
Scenario:
I have pushed my Power BI project to an Azure DevOps repository. The repo contains:
.Reports
folder.SemanticModel
folder, which includes themodel.bim
file with SQL server and database details.I created a deployment pipeline to publish the dashboard to a QA workspace using this sample pipeline approach.
Before deployment, I added a step in the pipeline to replace the development SQL connections with QA connections using regex on the
model.bim
file.After deployment, the report is successfully published, but the SQL credentials (username/password) are missing. I have to manually input them by editing the semantic model settings in app.powerbi.com.
Problem: I want to automate passing the SQL credentials (username/password) during the Continuous Deployment (CD) pipeline process. Here's what I've tried so far:
Approach 1:
Approach 2:
https://api.powerbi.com/v2.0/myorg/me/gatewayClusterCloudDatasource
Request:
How can I pass the SQL credentials (username and password) during the deployment process to avoid manual intervention?
Is it possible to include the credentials directly in the
model.bim
ordefinition.pbism
file as part of the CD pipeline?Alternatively, is there a way to automate the binding of the new data connection during deployment, perhaps using the Power BI REST API?
Any help or guidance on this would be appreciated!