Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

LorenzoBonati

How to delete an orphaned Fabric SQL Analytics Endpoint

When deleting a Lakehouse in Microsoft Fabric, the SQL Analytics Endpoint linked to it should normally be removed as well.
In some cases, the SQL Endpoint remains orphaned inside the workspace. This can cause issues such as:

 

  • Deployment errors

  • Invalid shortcut metadata

  • Stale objects that cannot be removed from the UI

 

To make this cleanup easy and secure, I published a small Fabric Notebook script that removes the orphaned SQL Endpoint directly from Fabric — no PowerShell required, no bearer token extraction, and no admin permissions on your PC.

 


GitHub Repository

You can find the script here (check the readme for clear instructions on how to use):

👉microsoft-fabric-scripts/fabric-data-warehouse/delete_fabric_orphaned_sql_analytics_endpoint.py

 


Why this Fabric Notebook script is helpful

This method is ideal when:

 

  • You cannot run PowerShell or local scripts

  • Your environment is locked down or strictly cloud-managed

  • You prefer running everything inside Fabric

 


Parameters you need

 

To run the cleanup you only need two values:

 

  • Host URL – Open the affected workspace → press F12  Network tab → refresh the web page → select any successful GET request → copy the value in the :authority / Host header (example: wabi-west-us3-a-primary-redirect.analysis.windows.net).

     
     
    LorenzoBonati_3-1763899682706.png

     

  • Artifact ID – Open the SQL Endpoint in your browser → copy the ArtifactID that appears in the URL after mirroredwarehouses/ (example structure: https://msit.powerbi.com/groups/<workspace-id>/mirroredwarehouses/<artifact-id>?experience=fabric-developer). Sometimes the URL shows 'lakewarehouses' instead of 'mirroredwarehouses'.

 


Fabric Notebook Script

Paste the following into a Fabric Python Notebook cell:

 

import requests

# ==== PARAMETERS TO FILL IN ====
artifact_id = "<PUT-ARTIFACT-ID-HERE>"
host_url    = "<PUT-HOST-URL-HERE>"
# =================================

# Retrieve Fabric backend token automatically
bearer = mssparkutils.credentials.getToken("https://analysis.windows.net/powerbi/api")

headers = {
    "Authorization": f"Bearer {bearer}"
}

url = f"https://{host_url}/metadata/artifacts/{artifact_id}"

response = requests.delete(url, headers=headers)

print("Status:", response.status_code)
print("Response:", response.text)

 

This will remove the orphaned SQL Analytics Endpoint from your workspace.

 

If you have ideas to extend or improve the script, feel free to contact me!

Comments

Okk thnkyuuu for the answer 

 

import requests

# ==== PARAMETERS TO FILL IN ====
artifact_id = "<PUT-ARTIFACT-ID-HERE>"
host_url    = "<PUT-HOST-URL-HERE>"
# =================================

# Retrieve Fabric backend token automatically
bearer = mssparkutils.credentials.getToken("https://analysis.windows.net/powerbi/api")

headers = {
    "Authorization": f"Bearer {bearer}"
}