快速入门:使用 PowerShell 创建 Azure Databricks 工作区Quickstart: Create an Azure Databricks workspace using PowerShell

此快速入门介绍如何使用 PowerShell 创建 Azure Databricks 工作区。This quickstart describes how to use PowerShell to create an Azure Databricks workspace. 可以使用 PowerShell 以交互方式或者通过脚本创建和管理 Azure 资源。You can use PowerShell to create and manage Azure resources interactively or in scripts.

先决条件Prerequisites

如果没有 Azure 订阅,请在开始之前创建一个试用帐户。If you don't have an Azure subscription, create a trial account before you begin.

如果选择在本地使用 PowerShell,则本文要求安装 Az PowerShell 模块,并使用 Connect-AzAccount cmdlet 连接到 Azure 帐户。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. 有关安装 Az PowerShell 模块的详细信息,请参阅安装 Azure PowerShellFor more information about installing the Az PowerShell module, see Install Azure PowerShell.

重要

尽管 Az.Databricks PowerShell 模块为预览版,但必须使用以下命令从 Az PowerShell 模块单独安装它:Install-Module -Name Az.Databricks -AllowPrereleaseWhile the Az.Databricks PowerShell module is in preview, you must install it separately from the Az PowerShell module using the following command: Install-Module -Name Az.Databricks -AllowPrerelease. Az.Databricks PowerShell 模块正式版推出后,它会包含在将来的 Az PowerShell 模块发行版中。Once the Az.Databricks PowerShell module is generally available, it becomes part of future Az PowerShell module releases.

备注

如果要在持有美国政府合规性认证(如 FedRAMP High)的 Azure 商业云中创建 Azure Databricks 工作区,请联系你的 Microsoft 代表或 Databricks 代表以获得这种体验的访问权限。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 Databricks representative to gain access to this experience.

如果这是你第一次使用 Azure Databricks,则必须注册 Microsoft.Databricks 资源提供程序。If this is your first time using Azure Databricks, you must register the Microsoft.Databricks resource provider.

Register-AzResourceProvider -ProviderNamespace Microsoft.Databricks

创建资源组Create a resource group

使用 New-AzResourceGroup cmdlet 创建 Azure 资源组Create an Azure resource group using the New-AzResourceGroup cmdlet. 资源组是在其中以组的形式部署和管理 Azure 资源的逻辑容器。A resource group is a logical container in which Azure resources are deployed and managed as a group.

以下示例在“中国东部 2”区域创建名为“myresourcegroup”的资源组。The following example creates a resource group named myresourcegroup in the China East 2 region.

New-AzResourceGroup -Name myresourcegroup -Location chinaeast2

创建 Azure Databricks 工作区Create an Azure Databricks workspace

在本部分,使用 PowerShell 创建 Azure Databricks 工作区。In this section, you create an Azure Databricks workspace using PowerShell.

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

提供以下值:Provide the following values:

属性Property 说明Description
名称Name 提供 Databricks 工作区的名称Provide a name for your Databricks workspace
ResourceGroupNameResourceGroupName 指定现有资源组名称Specify an existing resource group name
位置Location 选择“中国东部 2”。Select China East 2 . 有关其他可用区域,请参阅各区域推出的 Azure 服务For other available regions, see Azure services available by region
ManagedResourceGroupNameManagedResourceGroupName 指定是要创建新的受管理资源组还是使用现有受管理资源组。Specify whether you want to create a new managed resource group or use an existing one.
SKUSku 在“标准”、“高级”和“试用”之间进行选择。Choose between Standard , Premium , or Trial . 有关这些层的详细信息,请参阅 Databricks 定价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.

当工作区部署失败时,仍然会在失败状态下创建工作区。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.

确定 Databricks 工作区的预配状态Determine the provisioning state of a Databricks workspace

若要确定 Databricks 工作区是否已成功预配,可以使用 Get-AzDatabricksWorkspace cmdlet。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  chinaeast2   Succeeded

清理资源Clean up resources

如果其他快速入门或教程不需要使用本快速入门中创建的资源,可以运行以下示例将其删除。If the resources created in this quickstart aren't needed for another quickstart or tutorial, you can delete them by running the following example.

注意

以下示例删除指定的资源组及其包含的所有资源。The following example deletes the specified resource group and all resources contained within it. 如果指定的资源组中存在本快速入门范围外的资源,这些资源也会被删除。If resources outside the scope of this quickstart exist in the specified resource group, they will also be deleted.

Remove-AzResourceGroup -Name myresourcegroup

若要仅删除本快速入门中创建的服务器而不删除资源组,请使用 Remove-AzDatabricksWorkspace cmdlet。To delete only the server created in this quickstart without deleting the resource group, use the Remove-AzDatabricksWorkspace cmdlet.

Remove-AzDatabricksWorkspace -Name mydatabricksws -ResourceGroupName myresourcegroup

后续步骤Next steps