Forum Discussion

SimonPl's avatar
SimonPl
New Member
1 year ago
Solved

Fabric REST API endpoints for GCC

Hi,   Context: I am trying to run a PowerShell script using the Fabric REST APIs. We are working in a multi-tenant environment, so the idea is to run the script using a DevOps pipeline. The source...
  • SimonPlancke's avatar
    SimonPlancke
    1 year ago

    Thank you for the reply! In the end, we found the following:

    • We were initially using PowerShell command (Get-AzAccessToken -ResourceUrl $fabricResourceUrl).Token to request our access token for a personal user.
    • We found out that any access token generated in this way on a GCC description does not provide access to any of the Fabric services. Since we are working with a service principal, we tried a different way of getting our access token: 

     

            $appId = $env:servicePrincipalId 
            $clientSecret = $env:servicePrincipalKey
            $tenantId = $env:tenantId
    
            $authority = "https://login.microsoftonline.com/${tenantId}/oauth2/v2.0/token"
            # access token
            $body = @{
                client_id = $appId
                scope = "$fabricResourceUrl/.default"
                client_secret = $clientSecret
                grant_type = "client_credentials"
            }
            
            $response = Invoke-RestMethod -Method Post -Uri $authority -ContentType "application/x-www-form-urlencoded" -Body $body
            $fabricToken = $response.access_token

     

    • This new method for token retrieval resolved the issues we were having. We could use exactly the same Fabric endpoints for GCC, but now with a valid access token. I do not have a clear explanation on why this resolves the issue.