Forum Discussion

stuckerj's avatar
stuckerj
Helper I
10 months ago
Solved

REST API vs. Notebookutils Lakehouse Update Issue

REST API vs. Notebookutils Lakehouse Update Issue

Problem Summary

I am automating notebook provisioning in Microsoft Fabric and need to programmatically set or update the default Lakehouse for a notebook. I have tried both the REST API and the built-in Fabric Python SDK (notebookutils.notebook.updateDefinition). My findings:


1. REST API (/updateDefinition)

Endpoint:

POST https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/notebooks/{notebookId}/updateDefinition

Payload Example:

{
  "name": "Notebook 1",
  "definition": {
    "format": "ipynb",
    "parts": [
      {
        "path": "generate_data.ipynb",
        "payload": "<BASE64>",
        "payloadType": "InlineBase64"
      }
    ]
  },
  "defaultLakehouse": "<lakehouse_id>"
}
  • I have tried all combinations of optional fields (defaultLakehouseWorkspace, workspaceId).
  • The API always returns 202 Accepted, never completing with 200 OK or 204 No Content, even after many retries (waiting several minutes).
  • The notebook appears in the workspace and /notebooks endpoints, but the lakehouse update never finalizes.
  • If I omit definition, I get 400 InvalidInput: The Definition field is required.

2. Manual UI

  • Setting the default Lakehouse for a notebook via the Fabric web portal UI works instantly and as expected.

3. Python SDK (notebookutils.notebook.updateDefinition)

Code Example (executed inside a Fabric notebook):

(notebookutils
    .notebook
    .updateDefinition(
        name = "Notebook 1",
        defaultLakehouse = "<lakehouse_id>"
        # workspaceId and defaultLakehouseWorkspace seem optional in SDK
    )
)
  • When run inside Notebook 2, I can successfully set the default Lakehouse for Notebook 1.
  • The update takes about 1 minute to propagate, but does complete.
  • I cannot update the default Lakehouse for the currently running notebook (Notebook 2) from inside itself—only for other notebooks.

4. Additional Findings

  • The SDK appears to use internal service calls or context not exposed to REST API users.
  • The REST API requires a full notebook definition, even for a simple lakehouse update.
  • Even with the correct payload, the REST API gets stuck in an async state and never completes.

5. Request for Support

  • Is updating a Fabric notebook’s default Lakehouse officially supported via REST API?
  • Is there a workaround, or plans to improve this API feature?
  • Can you confirm if the difference is due to internal context/session, or a limitation/bug in the public API?
  • Hi stuckerj,

     

    Thank you for reaching out to Microsoft Fabric Community.

     

    Thank you for sharing the detailed analysis, yes there is a difference between the REST API and the notebookutils behavior.

    At present, updating a notebook’s default Lakehouse is not fully supported through the public REST API. When an .ipynb payload is sent, the API accepts it, returns 202 Accepted but never completes the async update, this is a known product limitation.

    The supported and working method is using notebookutils.notebook.updateDefinition from another notebook. It runs inside fabric with the correct context. If REST must be used then it requires a full .py notebook definition and still may not complete fully.

     

    Thanks and regards,

    Anjan Kumar Chippa

  • Hi stuckerj,

     

    Yes, that’s exactly the right approach. Creating a separate notebook to programmatically configure or update other notebooks is a solid and supported workaround. It works because the command runs inside the fabric and has the right access to update lakehouse settings properly.

     

    Thanks and regards,

    Anjan Kumar Chippa

6 Replies

  • v-achippa's avatar
    v-achippa
    Community Support

    Hi stuckerj,

     

    Thank you for reaching out to Microsoft Fabric Community.

     

    Thank you for sharing the detailed analysis, yes there is a difference between the REST API and the notebookutils behavior.

    At present, updating a notebook’s default Lakehouse is not fully supported through the public REST API. When an .ipynb payload is sent, the API accepts it, returns 202 Accepted but never completes the async update, this is a known product limitation.

    The supported and working method is using notebookutils.notebook.updateDefinition from another notebook. It runs inside fabric with the correct context. If REST must be used then it requires a full .py notebook definition and still may not complete fully.

     

    Thanks and regards,

    Anjan Kumar Chippa

    • stuckerj's avatar
      stuckerj
      Helper I

      Thank you for confirming the limitation. 

      As a workaround, I was thinking about creating another Notebook programmatically, for the purpose of setting data connections for other Notebooks in the pipeline.  It sounds like that's a solid option.

      • v-achippa's avatar
        v-achippa
        Community Support

        Hi stuckerj,

         

        Yes, that’s exactly the right approach. Creating a separate notebook to programmatically configure or update other notebooks is a solid and supported workaround. It works because the command runs inside the fabric and has the right access to update lakehouse settings properly.

         

        Thanks and regards,

        Anjan Kumar Chippa