Forum Discussion
Automated Deployment w/ Service Principal in DevOps
Hello 0_0 ,
Thanks for the update.
The Connection lookup result: { "value": [] } and 400 Bad Request errors indicate that the $connectionName specified in your script doesn’t match any configured connection in the Fabric workspace, resulting in a null connectionId.
This refers to a Git connection set up in the Fabric workspace (Settings > Git integration) for your Azure DevOps repository, not a DevOps service connection. It links Fabric to your Azure DevOps organization, project, repository, and branch.
Steps to Resolve:
- In the Fabric portal, go to your workspace’s Settings > Git integration and confirm the $connectionName matches an existing connection. If not, set it up with your Azure DevOps details: Git Integration with Fabric.
- Ensure the Service Principal has Contributor or Admin access to the workspace and Azure DevOps repository.
- Since SPN support for Azure DevOps updateFromGit is limited , try using a Personal Access Token (PAT) with UserPrincipal authentication.
Please confirm if the connection is set up correctly or share the full 400 error response for further assistance.
Best Regards,
Harshitha.
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
}
- Anonymous1 year agoNot applicable
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 confirmIf 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!