Forum Discussion
Automated Deployment w/ Service Principal in DevOps
Thanks For the Input,
Up until the Get Connection By Name function it works perfectly fine, I'm stumped on what it means by ConfiguredConnection, is this a service connection we set up linking it to the Service Principal within DevOps. I'm currently getting this response from the GetConnectionBy Name:
Connection lookup result: {
"value": []
}
Connect to Git body: {
"gitProviderDetails": {
"directoryName": "directoryname",
"repositoryName": "repositoryname",
"organizationName": "organizationname",
"projectName": "projectname",
"gitProviderType": "AzureDevOps",
"branchName": "prod"
},
"myGitCredentials": {
"source": "ConfiguredConnection",
"connectionId": "null"
}
}
Failed to connect workspace to Git: Response status code does not indicate success: 400 (Bad Request).
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.
- 0_01 year agoFrequent Visitor
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 }Failed to connect workspace to Git: Response status code does not indicate success: 400 (Bad Request). I'm assuming it would be an issue with the permissions of the connections, It has access to the repository with the ability to contribute as well as contributor access in our workspace and is able to call public APIs enabled within the admin portal.- 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.