Forum Discussion

pradipsodha's avatar
pradipsodha
New Member
4 months ago

How to programmatically bind a Fabric Connection to a Notebook?

Context

We are automating Fabric workspace provisioning end-to-end via the public Fabric REST API:

  • Create Web connection with allowUsageInUserControlledCode: true → works
  • Upload notebook via POST /v1/workspaces/{wsId}/notebooks → works
  • Trigger notebook remotely via RunNotebook job → works

The only manual step is binding the connection to the notebook (clicking "Connect" in the Connections pane). We need a way to automate this.

What we want

When we upload a notebook, we can include Lakehouse binding as part of the notebook metadata — fully automated, no UI step:

{
  "metadata": {
    "dependencies": {
      "lakehouse": {
        "known_lakehouses": [{ "id": "a4bdcfbf-..." }],
        "default_lakehouse": "a4bdcfbf-...",
        "default_lakehouse_name": "my_lake",
        "default_lakehouse_workspace_id": "029f9998-..."
      }
    }
  }
}

We want the same for Connections. Something like:

{
  "metadata": {
    "dependencies": {
      "lakehouse": { "..." : "..." },
      "connections": {
        "known_connections": [{ "id": "<connectionId>", "name": "my-web-conn" }]
      }
    }
  }
}

Or a REST API endpoint to bind after creation, similar to the existing Bind Semantic Model Connection API:

POST /v1/workspaces/{wsId}/notebooks/{nbId}/bindConnection

Observations

 

The binding creates a new UUID

After clicking "Connect" in the portal UI, the connection gets a new bound UUID different from the original connection ID. notebookutils.connections.getCredential() requires this bound UUID, not the original.

ID Source

Original connection IDCreated via POST /v1/connections
Bound connection ID (different)Generated after UI "Connect" step

Using the original connection ID with getCredential() fails with a 400 error: "Artifact Connection {id} does not exist." Only the bound UUID works.

 

The notebook definition does not change after binding

We downloaded the notebook .ipynb before and after the "Connect" step — they are identical. The binding is a server-side linkage with no representation in the notebook file. This is different from Lakehouse, where the binding is embedded in the notebook metadata.dependencies.

 

The portal performs this binding via an internal API

By inspecting browser network requests when clicking "Connect", we observed the portal calls an internal endpoint to create the binding. This internal endpoint is not part of the public Fabric REST API, does not resolve outside Fabric infrastructure, and rejects tokens obtained from notebookutils.credentials.getToken() inside notebooks.

 

Approaches we tried

Approach Result

Include connection in notebook metadata.dependencies (like Lakehouse)No such field exists in the notebook schema
POST /v1/workspaces/{wsId}/notebooks/{nbId}/connections404 — endpoint does not exist
GET /v1/workspaces/{wsId}/items/{nbId}/connectionsLists connections (read-only), no bind operation
Bind Semantic Model Connection APIOnly works for semantic models, not notebooks
Grant connection permissions to bypass bindingBinding is structural (not a permission check) — even as connection Owner, getCredential() fails without binding
Fabric CLI (fab create .connections, fab set, fab assign)Can create/manage connections but no command to bind to a notebook

Questions

  1. Is there a way to include connection binding in the notebook metadata/definition (like Lakehouse dependencies) so it's bound at upload time via the Create/Update Notebook Definition API?
  2. Is there a public REST API (or upcoming preview) to programmatically bind a connection to a notebook — similar to the Bind Semantic Model Connection API but for notebook items?
  3. Is there a planned Fabric CLI command (e.g. fab assign or fab ln) to bind a connection to a notebook artifact?

References

Environment

  • Fabric capacity: Trial (Southeast Asia)
  • Feature: "Fabric Connection in notebooks (Preview)" enabled
  • Connection type: Web, Basic auth, allowUsageInUserControlledCode: true
  • API version: v1
  • Date: April 2026

4 Replies

  • Hi. Bind a Notebook is not possible right now. You can't do that by API. Binding is for semantic models or reports only. When working with notebooks you can avoid a picking one lakehouse and just call any of them with your fill path instead of "Files/folder/x.parquet". You don't need to rebind or something like that.

    I hope that helps,

  • Hi pradipsodha ,


    Thanks for posting in Microsoft Fabric Community.

    As mentioned by ibarrau there is currently no way to programmatically bind a Fabric Connection to a notebook. The manual Connect step in the Connections pane seems to be the only option for now.

     

    We'd suggest posting this as an idea on the Fabric Ideas forum so the product team can consider it for a future release.
    Thank you.

  • Hi pradipsodha ,

    We wanted to kindly follow up regarding your query. If you need any further assistance, please reach out.

    Also, if you have submitted an idea in the Ideas Portal, please feel free to share the link here so others in the community can upvote it. With enough support, Microsoft may consider it for future implementation.


    Thank you.

  • Hi pradipsodha  I would like to give you a big KUDOS for an excellent description of the issue you're experiencing, that makes a lot easier to reproduce the issue and help in the resolution 👍  The fabric API is getting there, but as of now, unfortunately there's no interface to bind this via API and yes, I observed the same, I connect a notebook to my exisitng connection and cross my fingers to see changes in the definition, but no 😒 that feature is still not tracked in Git. I guess we will have to wait a rally for this to be added, perhaps this could take the form of two ideas, adding the binding to be tracked by Git and second, add an interface to do the binding via API. Since you already have all this information, perhaps you can do the honors? Please create here and let me know to get my vote Fabric Ideas - Microsoft Fabric Community

     

    All the very best of lucks