Featured image of post Create a Microsoft Fabric Warehouse with PowerShell

Create a Microsoft Fabric Warehouse with PowerShell

Introduction

Microsoft Fabric is a low friction unified analytics platform that brings together data engineering, data integration, data warehousing, data science, real-time analytics, and business intelligence.

Fabric Warehouse

A Fabric warehouseis a next-generation data warehousing solution.

It is designed to handle large volumes of data and provide fast query performance.

How do you create a Fabric Warehouse?

There are several ways to create a Fabric warehouse, including using the Fabric portal, Fabric CLI, using the Fabric Terraform provider.

What is FabricTools?

We are going to use [FabricTools, a PowerShell module that simplifies the management of Microsoft Fabric resources. You can find it on GitHub at[FabricTools provides functions to create, update, and delete Fabric warehouses and other resources. It has been developed and is maintained by members of the community.

How do you install FabricTools?

To install the FabricTools module from the PowerShell Gallery:

1
Install-PsResource -Name FabricTools

Create a Fabric Warehouse with PowerShell

First, you need to connect to your Fabric account using the Connect-FabricAccount cmdlet. This cmdlet will prompt you to sign in with your Microsoft account. I like to use a secret to store my tenant ID, so I can use it in my scripts without hardcoding it. You can use the Get-Secret cmdlet from the Microsoft.PowerShell.SecretManagement module to retrieve the secret.

1
Connect-fabricAccount -TenantId (Get-Secret -Name beard-mvp-tenant-id -AsPlainText)

Next, you can create a Fabric warehouse using the New-FabricWarehouse cmdlet. You need to specify the name of the warehouse, the workspace id that it will be assigned to, and optionally a description.

1
2
3
4
5
6
7
8
$WorkspaceName = "BlogPostWorkspace"
$WarehouseConfig = @{
   WorkspaceId = (Get-FabricWorkspace -WorkspaceName $WorkspaceName).Id
   WarehouseName = "Sock_Factory_Warehouse"
   WarehouseDescription = "This is a warehouse for the Sock Factory owned by Gianluca Sartori which enables the socks to leave in pairs."
}

New-FabricWarehouse @WarehouseConfig

This will create a new Fabric warehouse with the specified name and description in the specified workspace.

Warehouse Created

You can also see it in the Fabric portal in the workspace you specified.

Warehouse in Fabric Portal

You can also verify that the warehouse has been created by using the Get-FabricWarehouse function. This will also return the details of the SQL connection string that you can use to connect to the warehouse from other applications like SQL Server Management Studio Visual Studio Code.

1
Get-FabricWarehouse -WorkspaceName $WorkspaceName

Warehouse Details

Conclusion

In this post, we learned how to create a Microsoft Fabric warehouse using PowerShell. We used the New-FabricWarehouse cmdlet to create a warehouse in a specified workspace. This allows you to manage your data warehousing needs effectively within the Microsoft Fabric platform. You can now use this warehouse to store and analyze your data using the powerful features of Microsoft Fabric.

Built with Hugo
Theme Stack designed by Jimmy