One of the features I appreciate most about Microsoft Fabric is that almost everything you can create through the user interface can also be automated. As data platforms become more sophisticated, automation is no longer a nice-to-have—it's an essential part of building scalable, repeatable, and production-ready data solutions.
Traditionally, creating a Lakehouse involves navigating to a workspace, clicking New, selecting Lakehouse, entering a name, and waiting for Fabric to provision the resource.
While that approach works perfectly well for ad hoc development, it isn't ideal when you're building automated deployment pipelines or provisioning environments for multiple projects.
Fortunately, Microsoft Fabric provides the notebookutils library, which allows us to create Fabric artifacts directly from a notebook.
In this article, I'll demonstrate how to programmatically create a Lakehouse using a Microsoft Fabric Notebook.
Why Create a Lakehouse Programmatically?
Automating Lakehouse creation provides several advantages.
For example, you may want to:
Provision development environments automatically.
Create separate Lakehouses for different business domains.
Build self-service onboarding processes.
Integrate infrastructure provisioning into CI/CD pipelines.
Standardize data platform deployments across multiple workspaces.
Instead of relying on manual clicks, you can automate the entire process with just a few lines of code.
The Code
Creating a Lakehouse programmatically is surprisingly straightforward.
artifact = notebookutils.lakehouse.create(
name="sales_copilot_lakehouse",
description="Lakehouse created programmatically"
)
print(f"Created Lakehouse: {artifact.displayName} (ID: {artifact.id})")
That's all it takes.
![notebook code]()
Understanding the Code
Let's break down what's happening.
Creating the Lakehouse
The create() method creates a brand-new Lakehouse in the current Microsoft Fabric workspace.
artifact = notebookutils.lakehouse.create(
name="sales_copilot_lakehouse",
description="Lakehouse created programmatically"
)
Here we're supplying two parameters:
name
name="sales_copilot_lakehouse"
This specifies the name that will appear in the Fabric workspace.
If a Lakehouse with the same name already exists, Fabric will return an error, so it's good practice to check for existing resources or use a naming convention that guarantees uniqueness.
description
description="Lakehouse created programmatically"
Although optional, descriptions are useful for documenting the purpose of each Lakehouse, especially in enterprise environments where multiple teams share the same workspace.
The Returned Object
After the Lakehouse is created, the create() method returns an object containing metadata about the newly created artifact.
In this example, the object is assigned to the variable:
artifact
This object contains useful properties such as:
Displaying the Results
To confirm that the Lakehouse has been created successfully, we can print two of its properties.
print(f"Created Lakehouse: {artifact.displayName} (ID: {artifact.id})")
The output looks similar to:
Created Lakehouse: sales_copilot_lakehouse
ID: 8d9bcb46-5c88-4af4-a3c8-f12b6e93c5d1
The unique identifier can be particularly useful when automating downstream tasks that reference the Lakehouse.
What Happens Behind the Scenes?
When the notebook executes the create() method, Microsoft Fabric performs several operations automatically.
Receives the request from the notebook.
Creates a new Lakehouse artifact in the current workspace.
Assigns a unique identifier.
Registers the Lakehouse in the workspace metadata.
Returns information about the newly created artifact.
From the developer's perspective, the entire process is completed with a single function call.
![notebook code2]()
Real-World Use Cases
Programmatically creating Lakehouses is useful in many scenarios.
Environment Provisioning
When onboarding a new project, a notebook can automatically create dedicated Lakehouses for:
This helps ensure consistency across environments.
Project Automation
Suppose your organization launches a new client project.
Instead of manually creating resources, a provisioning notebook can automatically create:
Lakehouse
Notebook
Data Pipeline
Semantic Model
Warehouse
within minutes.
CI/CD Pipelines
Infrastructure as Code is becoming increasingly common in modern data platforms.
A deployment pipeline can invoke a notebook that provisions Fabric artifacts before deploying notebooks, pipelines, and datasets.
This reduces manual intervention and minimizes configuration errors.
Multi-Tenant Solutions
Organizations supporting multiple customers often isolate each tenant into separate Lakehouses.
Rather than manually creating dozens—or even hundreds—of Lakehouses, the process can be fully automated using notebooks.
Best Practices
When creating Lakehouses programmatically, I recommend following a few best practices.
Use meaningful naming conventions
Instead of generic names, consider including:
Business domain
Environment
Project name
For example:
sales_dev_lakehouse
sales_test_lakehouse
sales_prod_lakehouse
This makes resources easier to identify and manage.
Include descriptions
Descriptions provide valuable context for administrators and other developers working in the same workspace.
Handle Exceptions
In production notebooks, wrap the creation logic in a try...except block to gracefully handle situations such as duplicate names or insufficient permissions.
For example:
try:
artifact = notebookutils.lakehouse.create(
name="sales_copilot_lakehouse",
description="Lakehouse created programmatically"
)
print(f"Created Lakehouse: {artifact.displayName}")
except Exception as e:
print(e)
This improves reliability and simplifies troubleshooting.
Standardize Resource Provisioning
If your organization frequently creates similar projects, consider encapsulating the creation logic into reusable functions or notebooks that can be called from orchestration pipelines.
Why This Matters
As Microsoft Fabric adoption continues to grow, data engineers are increasingly expected to automate not only data pipelines but also the underlying platform resources.
Being able to provision Lakehouses programmatically enables teams to build repeatable deployment processes, reduce manual effort, and maintain consistency across environments.
Automation also aligns with modern DevOps and DataOps practices, where infrastructure is created through code rather than manual configuration.
Final Thoughts
Creating a Lakehouse through the Microsoft Fabric user interface is quick and convenient, but programmatically creating one from a notebook opens the door to far more powerful automation scenarios.
With just a few lines of Python and the notebookutils.lakehouse.create() method, you can provision Lakehouses on demand, integrate resource creation into deployment workflows, and build scalable, repeatable solutions for enterprise data platforms.
As data engineering continues to evolve toward automation-first practices, understanding how to manage Fabric artifacts programmatically is becoming an increasingly valuable skill. Whether you're provisioning development environments, building CI/CD pipelines, or automating enterprise deployments, creating Lakehouses through code is a capability well worth adding to your Microsoft Fabric toolkit.