Forum Discussion

MartinMason's avatar
MartinMason
Resolver I
1 year ago
Solved

Update from Git - Azure Devops Pipeline

I'm trying to construct an Azure Devops pipeline to orchestrate our deployment process. One of the first steps I need to accomplish is to update our Development workspace from Git. I was thinking it ...
  • hackcrr's avatar
    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.