Change ownership of Fabric Warehouse

Applies to: ✅ Warehouse in Microsoft Fabric

The Warehouse item uses the owner's identity when accessing data on OneLake. To change the owner of these items, currently the solution method is to use an API call as described in this article.

This guide walks you through the steps to change your Warehouse owner to your Organizational account. The takeover APIs for each allow you to change this owner's identity to an SPN or other organization account (Microsoft Entra ID). For more information, see Microsoft Entra authentication as an alternative to SQL authentication in Microsoft Fabric.

The takeover API only works for Warehouse, not the SQL analytics endpoint.

Prerequisites

Before you begin, you need:

  • A Fabric workspace with an active capacity or trial capacity.

  • A Fabric warehouse on a Lakehouse.

  • Either be a member of the Administrator, Member, or Contributor roles on the workspace.

  • Install and import the Power BI PowerShell module, if not installed already. Open Windows PowerShell as an administrator in an internet-connected workstation and execute the following command:

    Install-Module -Name MicrosoftPowerBIMgmt
    Import-Module MicrosoftPowerBIMgmt 
    

Connect

  1. Open Windows PowerShell as an administrator.
  2. Connect to your Power BI Service:
Connect-PowerBIServiceAccount

Take ownership of Warehouse

  1. Navigate to the Warehouse item you want to change the owner in the workspace. Open the SQL Editor.
  2. Copy the URL from your browser and place a text editor for use later on.
  3. Copy the first GUID from the URL, for example, 11aaa111-a11a-1111-1aaa-aa111111aaa. Don't include the / characters. Store this in a text editor for use soon.
  4. Copy the second GUID from the URL, for example, 11aaa111-a11a-1111-1aaa-aa111111aaa. Don't include the / characters. Store this in a text editor for use soon.
  5. In the following script, replace workspaceID with the first GUID you copied. Run the following command.
    $workspaceID = 'workspaceID'
    
  6. In the following script, replace warehouseID with the second GUID you copied. Run the following command.
    $warehouseid = 'warehouseID'
    
  7. Run the following command:
    $url = 'groups/' + $workspaceID + '/datawarehouses/' + $warehouseid + '/takeover'
    
  8. Run the following command:
    Invoke-PowerBIRestMethod -Url $url -Method Post -Body ""
    
  9. Owner of the warehouse item has now changed.

Full script

# Install the Power BI PowerShell module if not already installed
Install-Module -Name MicrosoftPowerBIMgmt

# Import the Power BI PowerShell module
Import-Module MicrosoftPowerBIMgmt

# Fill the parameters
$workspaceID = 'workspaceID'
$warehouseid = 'warehouseID'

# Connect to the Power BI service
Connect-PowerBIServiceAccount

#Invoke warehouse takeover
$url = 'groups/' + $workspaceID + '/datawarehouses/' + $warehouseid + '/takeover'
Invoke-PowerBIRestMethod -Url $url -Method Post -Body ""