Forum Discussion

yazdanb's avatar
yazdanb
Frequent Visitor
10 months ago
Solved

Issue with Fabric Git API loop from Azure DevOps

Hi everyone,   My team and I are having issues trying to automate Power BI report deployment from Azure DevOps to Microsoft Fabric using the Fabric Git REST APIs. The goal is simple: connect a work...
  • v-sgandrathi's avatar
    10 months ago

    Hi yazdanb,

    Thank you for reaching out to the Microsoft Fabric Community.


    Based on your description, the issue seems to occur because the initializeConnection API call is missing the required parameters and proper handling for long-running operations (LRO). In Fabric, this endpoint does not complete immediately; instead, it returns a 202 Accepted response with a Location header containing an operation URL. You need to poll this URL until the initialization is finished. If you send an empty JSON body ({}) or omit the initializationStrategy, the API may return an UnknownError or make the workspace look connected without being fully initialized, leading to the "WorkspaceGitConnectionNotInitialized" message.

    To resolve this, update your API call to include the initializationStrategy parameter in the request body. For most automated deployments, use the following payload:

    { "initializationStrategy": "PreferRemote" }

     

    Alternatively, you can use "PreferWorkspace" if you want your Fabric workspace content to take precedence over the repository. Once you submit this request, make sure to capture the Location URL from the response headers and keep polling that endpoint until the operation state is Succeeded. Skipping this step will leave the connection in a partial state and can cause the same circular issue you're experiencing.

    Also, check that your service principal's Git credentials are correctly set up. You can do this by calling GET /git/myGitCredentials to verify the source is "ConfiguredConnection" and that the connectionId matches the one in your connect request. If it's not set up, you can update it using the PATCH endpoint as shown:

    { "source": "ConfiguredConnection", "connectionId": "<FABRIC_CONNECTION_ID>" }

     

    Without this configuration, /git/connect may show success, but initialization can fail if credentials aren't linked. After successful initialization, check GET /git/status. If "requiredAction" is "UpdateFromGit", use POST /git/updateFromGit and poll until done. Make sure your Fabric workspace has capacity assigned and your service principal has Admin access to both the workspace and Azure DevOps repository for the Git APIs to work.

     

    Git - Initialize Connection - REST API (Core) | Microsoft Learn
    Git - Connect - REST API (Core) | Microsoft Learn

     

    Thank you and regards,
    Sahasra.