Dear All,
We have configured Microsoft Fabric in our environment, with dedicated workspaces for Dev, UAT, and PROD. Instead of using Deployment Pipelines, we have integrated our workspaces with an Azure DevOps Git repository branch for version control.
Current Implementation
We are using the Fabric API to trigger deployments: 🔗 API Endpoint: https://api.fabric.microsoft.com/v1/workspaces/$WorkspaceId/git/updateFromGit
Initially, we used a service account for deployments. While testing via Postman, we were able to retrieve all workspace IDs, but the deployment API returned the following error:
{
Actions Taken
- Followed Microsoft documentation to create an Application ID and Client Secret.
- Granted the following permissions to the App:
- Workspace.ReadWrite.All
- Workspace.GitUpdate
- Added the App ID as a Workspace Admin.
Issue with API Token Authentication
When running the following PowerShell script in our Azure DevOps pipeline to generate an access token, we faced an authentication issue while retrieving workspace IDs or deploying contents:
Pipeline Script for Token Generation
powershell
CopyEdit
$TenantId = "$(TENANT_ID)"
$ClientId = "$(CLIENT_ID)"
$ClientSecret = "$(CLIENT_SECRET)"
$TokenUrl = "https://login.microsoftonline.com/$TenantId/oauth2/v2.0/token"
$Body = @{
client_id = $ClientId
client_secret = $ClientSecret
scope = "https://api.fabric.microsoft.com/.default"
grant_type = "client_credentials"
}
try {
$Response = Invoke-RestMethod -Uri $TokenUrl -Method Post -Body $Body -ContentType "application/x-www-form-urlencoded"
$AccessToken = $Response.access_token
if (-not $AccessToken) {
Write-Host "##[error]Failed to fetch Access Token!"
exit 1
}
Write-Host "Access Token (First 10 chars): $($AccessToken.Substring(0,10))..."
Write-Host "##vso[task.setvariable variable=FabricAccessToken;isSecret=true]$AccessToken"
} catch {
Write-Host "##[error]Failed to retrieve access token: $_"
exit 1
}
Err{ "requestId": "29bcee65-1313-4103-bcb6-56d7e572ec27", "errorCode": "Unauthorized", "message": "The caller is not authenticated to access this resource" }