Forum Discussion
Automated Deployment w/ Service Principal in DevOps
Thanks, I managed to get the connection functional thanks to your suggestion but am unable to connect the workspace from Git:
try {
Invoke-RestMethod -Headers $global:fabricHeaders -Uri $connectUrl -Method POST -Body $connectToGitBody
Write-Host "Workspace '$workspaceName' connected to Git." -ForegroundColor Green
} catch {
Write-Host "Failed to connect workspace to Git: $($_.Exception.Message)" -ForegroundColor Red
return
}
Hi 0_0,
Thank you for the update. The 400 Bad Request error when connecting the workspace to Git likely stems from an issue with the $connectToGitBody or Service Principal permissions for Git operations(Verify the SPN has Admin access)
check whether the JSON includes a valid connectionId (not null) from the Fabric workspace’s configured connection. Log $connectToGitBody before Invoke-RestMethod to confirm
If the issue still happening, please let me know.
Regards,
Harshitha.
- Anonymous1 year agoNot applicable
Hi 0_0,
I hope the information provided above assists you in resolving the issue. If you have any additional questions or concerns, please do not hesitate to contact us. We are here to support you and will be happy to help with any further assistance you may need.
Regards,
Harshitha.- 0_01 year agoFrequent Visitor
Hey Anonymous ,
I'm still unable to connect to git, I have a feeling it may be with the portion or the delegated scopes for the SPN itself.
$connectToGitBody = @{} if ($gitProviderDetails.gitProviderType -eq "AzureDevOps") { Write-Host "Getting connection by name: $connectionName" $connection = GetConnectionByName $connectionName Write-Host "Connection lookup result: $($connection | ConvertTo-Json -Depth 3)" if (-not $connection) { Write-Host "A connection with the requested name was not found." -ForegroundColor Red return } $connectToGitBodyObject = @{ gitProviderDetails = $gitProviderDetails myGitCredentials = @{ source = "ConfiguredConnection" connectionId = $connection.id } } if (-not $workspace.Id) { Write-Host "Workspace ID is null"; return } if (-not $connection.id) { Write-Host "Connection ID is null"; return } $connectToGitBody = $connectToGitBodyObject | ConvertTo-Json -Depth 3 Write-Host "Connect to Git body: $connectToGitBody" try { Invoke-RestMethod -Headers $global:fabricHeaders -Uri $connectUrl -Method POST -Body $connectToGitBody Write-Host "Workspace '$workspaceName' connected to Git." -ForegroundColor Green } catch { Write-Host "Failed to connect workspace to Git. Detailed error: $($_ | ConvertTo-Json -Depth 3)" -ForegroundColor Red return } }Thanks!
- Anonymous1 year agoNot applicable
Hi 0_0 ,
We regret the inconvenience caused. Please consider raising a Microsoft support ticket for further investigation. You can explain all the troubleshooting steps you have taken to help them better understand the issue.
You can create a Microsoft support ticket with the help of the link below:
https://learn.microsoft.com/en-us/power-bi/support/create-support-ticket