Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
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.
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
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
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).
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'.
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.