azuremicrosoft-fabric

Cannot Find Fabric In Azure Portal under App Registrations


While trying to Assign API Permissions for Microsoft Fabric for user ( user2@salmancrsyahooco.onmicrosoft.com ), I cannot find "Fabric" listed under API Permissions under Microsoft API's. Is it due to my account being personal, how can I resolve this?

Also this is to call the API https://learn.microsoft.com/en-us/rest/api/fabric/core/git/update-from-git?tabs=HTTP#code-try-0 to update a Fabric workspace using Postman

Update: enter image description here


Solution

  • To grant PowerBI API permissions, check the below:

    Go to Microsoft Entra ID application -> API permissions -> Add a permission -> PowerBI Service

    As you are calling update from GIT API, you need to grant Workspace.GitUpdate.All delegated scope:

    enter image description here

    Now generate the access token using any user interactive flow or delegated flow via Postman using below parameters:

    Generate auth-code:

    https://login.microsoftonline.com/TenantID/oauth2/v2.0/authorize?
    &client_id=ClientID
    &response_type=code
    &redirect_uri=https://jwt.ms
    &response_mode=query
    &scope=https://api.fabric.microsoft.com/.default
    &state=12345
    

    enter image description here

    https://login.microsoftonline.com/TenantID/oauth2/v2.0/token
    
    client_id: ClientID
    grant_type: authorization_code
    scope: https://api.fabric.microsoft.com/.default
    redirect_uri: RedirectURL
    code: code
    client_secret: xxx
    

    enter image description here

    Make sure to decode the access token in jwt.ms: Welcome! and check the aud and scp claim:

    enter image description here

    Now call the update GIT API:

    POST https://api.fabric.microsoft.com/v1/workspaces/WorkspaceID/git/updateFromGit
    
    {
      "workspaceHead": "xxx",
      "remoteCommitHash": "xxx",
      "conflictResolution": {
        "conflictResolutionType": "Workspace",
        "conflictResolutionPolicy": "PreferWorkspace"
      },
      "options": {
        "allowOverrideItems": true
      }
    }
    

    For sample, I assigned Workspace.Read.All API permission and generated access token.

    Called the get workspace API:

    https://api.fabric.microsoft.com/v1/workspaces
    

    enter image description here

    UPDATE:

    As you are making use of Client credential flow, you need to grant application type API permission:

    enter image description here

    In PowerBI Admin Portal, you need to enable the below option:

    enter image description here

    And add the Service principal as Admin or Contributor to the workspace:

    enter image description here

    To perform the above, you must be having Fabric Administrator role.

    Now generate the access token using Client credential flow:

    https://login.microsoftonline.com/TenantID/oauth2/v2.0/token
    
    client_id:
    client_secret: xxx
    scope: https://api.fabric.microsoft.com/.default
    grant_type: client_credentials
    

    enter image description here

    And decode the access token and check the roles and aud claim:

    enter image description here

    And now make use of this access token to call the API.