Forum Discussion
Update from Git - Azure Devops Pipeline
- 1 year ago
Hi, MartinMason
Update your pipeline's PowerShell script to use the PAT instead of trying to authenticate via Service Principal.
- powershell: | $pat = "$(PAT)" # Your PAT stored securely in Azure DevOps $headers = @{ Authorization = "Bearer $pat" "Content-Type" = "application/json" } $body = @{ remoteCommitHash = "$(GIT_COMMIT_HASH)" conflictResolution = @{ conflictResolutionType = "Workspace" conflictResolutionPolicy = "PreferWorkspace" } options = @{ allowOverrideItems = $true } } Invoke-RestMethod -Uri "https://api.fabric.microsoft.com/v1/workspaces/$(PBI_WORKSPACE_ID)/git/updateFromGit" -Method Post -Headers $headers -Body ($body | ConvertTo-Json -Compress) displayName: 'Update Power BI Workspace from Git'For now, the PAT approach or interactive user authentication are your best bets to achieve the desired functionality. Both have their pros and cons, but they can enable automated deployments until Microsoft officially supports Service Principal authentication for this endpoint.
Hi MartinMason,
I am trying to create a similar pipeline, can you tell me how to get the value for GIT_COMMIT_HASH variable.
Most of what I'm using, I'm pilfering from this page:
Automate Git integration by using APIs - Microsoft Fabric | Microsoft Learn
The call to the workspaces/$workspaceId/git/status endpoint will return the remoteCommitHash and the workspaceHead value that need to be included in the body of the call to the workspaces/$workspaceId/git/updateFromGit endpoint. It's a long running operation so it'll return a 202 status code with the operation id that you'll need to check periodically to determine the status. Currently, we have to run it with the credentials of the semantic model/paginated report owner so it's of limited use in a triggered scenario