Edit

Share via


Create a SQL database with the Fabric CLI

Applies to:SQL database in Microsoft Fabric

You can use the Fabric Command Line Interface (CLI) to create SQL databases in Fabric. The Fabric CLI (fab) is a fast, file‑system‑inspired command‑line interface for Microsoft Fabric.

This article and sample scripts demonstrate the basic Fabric CLI commands that can be used to deploy a Fabric SQL database.

Prerequisites

Before you begin:

  • You need an existing Fabric capacity. If you don't, start a Fabric trial.

  • You can use an existing workspace or create a new Fabric workspace.

  • You must be a member of the Admin or Member roles for the workspace to create a SQL database.

  • Make sure Python version 3.10, 3.11, or 3.12 is installed on your machine. Python should be accessible from your terminal, via the PATH environment variable.

  • Install Fabric CLI on your machine with the following command. If you see a message about updating the PATH in the output of the installer, fix that before proceeding or subsequent steps can fail.

    pip install ms-fabric-cli
    

Create a new SQL database with Fabric CLI

  1. Sign in to Microsoft Fabric. Open a command prompt and run the following command:

    fab auth login 
    
  2. Follow the prompts to authenticate using your Microsoft account with access to your Fabric workspace.

  3. Run the following command to create a new SQL database:

    • Replace <workspacename> with the name of the workspace where you want to create the SQL database.
    • Replace <databasename> with the name that you want to use for your new SQL database.
    fab create <workspacename>.Workspace/<databasename>.SQLDatabase
    
  4. Verify the new SQL database in your workspace with the following command:

    • Replace <workspacename> with the name of the workspace where you want to create the SQL database.
    fab ls <workspacename>.Workspace 
    

    The fab ls command displays a list of all items in the workspace, including your new SQL database.