Deploy a workspace with PowerShell

This article explains how to create an Azure Databricks workspace using Powershell.

If you choose to use PowerShell locally, this article requires that you install the Az PowerShell module and connect to your Azure account using the Connect-AzAccount cmdlet. For more information about installing the Az PowerShell module, see Install Azure PowerShell.

To connect to your Azure account as a user, see PowerShell login with an Azure Databricks user account. To connect to your Azure account as a service principal, see PowerShell login with a Microsoft Entra ID service principal.

Note

If you want to create an Azure Databricks workspace in the Azure Commercial Cloud that holds US Government compliance certifications like FedRAMP High, please reach out to your Microsoft or Azure Databricks account team to gain access to this experience.

If this is your first time using Azure Databricks, you must register the Microsoft.Databricks resource provider.

  Register-AzResourceProvider -ProviderNamespace Microsoft.Databricks

Use Azure Cloud Shell

Azure hosts Azure Cloud Shell, an interactive shell environment that you can use through your browser. You can use either Bash or PowerShell with Cloud Shell to work with Azure services. You can use the Cloud Shell preinstalled commands to run the code in this article without having to install anything on your local environment.

To start Azure Cloud Shell:

  • Select Try It in the upper-right corner of a code block. Selecting Try It doesn’t automatically copy the code to Cloud Shell.
  • Go to https://shell.azure.com, or select the Launch Cloud Shell button to open Cloud Shell in your browser.
  • Select the Cloud Shell button on the menu bar at the upper right in the Azure portal.

To run the code in this article in Azure Cloud Shell:

  • Start Cloud Shell.
  • Select the Copy button on a code block to copy the code.
  • Paste the code into the Cloud Shell session by selecting Ctrl+Shift+V on Windows and Linux or by selecting Cmd+Shift+V on macOS.
  • Select Enter to run the code.

If you have multiple Azure subscriptions, choose the appropriate subscription in which the resources should be billed. Select a specific subscription ID using the Set-AzContext cmdlet.

Set-AzContext -SubscriptionId 00000000-0000-0000-0000-000000000000

Create a resource group

Create an Azure resource group using the New-AzResourceGroup cmdlet. A resource group is a logical container in which Azure resources are deployed and managed as a group.

The following example creates a resource group named myresourcegroup in the West US 2 region.

New-AzResourceGroup -Name myresourcegroup -Location westus2

Create an Azure Databricks workspace

In this section, you create an Azure Databricks workspace using PowerShell.

New-AzDatabricksWorkspace -Name mydatabricksws -ResourceGroupName myresourcegroup -Location westus2 -ManagedResourceGroupName databricks-group -Sku standard

Provide the following values:

Property Description
Name Provide a name for your Databricks workspace
ResourceGroupName Specify an existing resource group name
Location Select West US 2. For other available regions, see Azure services available by region
ManagedResourceGroupName Specify whether you want to create a new managed resource group or use an existing one.
Sku Choose between Standard, Premium, or Trial. For more information on these tiers, see Databricks pricing

The workspace creation takes a few minutes. Once this process is finished, your user account is automatically added as an admin user in the workspace.

Note

When a workspace deployment fails, the workspace is still created in a failed state. Delete the failed workspace and create a new workspace that resolves the deployment errors. When you delete the failed workspace, the managed resource group and any successfully deployed resources are also deleted.

Determine the provisioning state of a Databricks workspace

To determine if a Databricks workspace was provisioned successfully, you can use the Get-AzDatabricksWorkspace cmdlet.

Get-AzDatabricksWorkspace -Name mydatabricksws -ResourceGroupName myresourcegroup |
  Select-Object -Property Name, SkuName, Location, ProvisioningState
Name            SkuName   Location  ProvisioningState
----            -------   --------  -----------------
mydatabricksws  standard  westus2   Succeeded