快速入门:使用 ARM 模板创建 Ubuntu Data Science Virtual MachineQuickstart: Create an Ubuntu Data Science Virtual Machine using an ARM template

适用于:是基本版是企业版               (升级到企业版APPLIES TO: yesBasic edition yesEnterprise edition                    (Upgrade to Enterprise edition)

本快速入门将介绍如何使用 Azure 资源管理器模板(ARM 模板)创建 Ubuntu 18.04 Data Science Virtual Machine。This quickstart will show you how to create an Ubuntu 18.04 Data Science Virtual Machine using an Azure Resource Manager template (ARM template). Data Science Virtual Machine 是基于云的虚拟机,预加载了一套数据科学和机器学习框架及工具。Data Science Virtual Machines are cloud-based virtual machines preloaded with a suite of data science and machine learning frameworks and tools. 当部署在 GPU 驱动的计算资源上时,所有工具和库都配置为使用 GPU。When deployed on GPU-powered compute resources, all tools and libraries are configured to use the GPU.

ARM 模板是定义项目基础结构和配置的 JavaScript 对象表示法 (JSON) 文件。An ARM template is a JavaScript Object Notation (JSON) file that defines the infrastructure and configuration for your project. 该模板使用声明性语法,使你可以声明要部署的内容,而不需要编写一系列编程命令来进行创建。The template uses declarative syntax, which lets you state what you intend to deploy without having to write the sequence of programming commands to create it.

如果你的环境满足先决条件,并且你熟悉如何使用 ARM 模板,请选择“部署到 Azure”按钮。If your environment meets the prerequisites and you're familiar with using ARM templates, select the Deploy to Azure button. Azure 门户中会打开模板。The template will open in the Azure portal.

部署到 AzureDeploy to Azure

先决条件Prerequisites

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

  • 若要从本地环境 使用本文档中的 CLI 命令,需要使用 Azure CLITo use the CLI commands in this document from your local environment, you need the Azure CLI

查看模板Review the template

本快速入门中使用的模板来自 Azure 快速启动模板The template used in this quickstart is from Azure Quickstart Templates. 本文的完整模板太长,无法在此处显示。The complete template for this article is too long to show here. 若要查看完整模板,请参阅 azuredeploy.jsonTo view the complete template, see azuredeploy.json. 定义 DSVM 细节的部分如下所示:The portion that defines the specifics of the DSVM is shown here:

    {

      "type": "Microsoft.Compute/virtualMachines",

      "apiVersion": "2019-03-01",

      "name": "[concat(variables('virtualMachineName'),'-', parameters('Cpu-Gpu'))]",

      "location": "[parameters('location')]",

      "dependsOn": [

        "[resourceId('Microsoft.Network/networkInterfaces/', variables('networkInterfaceName'))]",

        "[resourceId('Microsoft.Storage/storageAccounts/', variables('storageAccountName'))]"

      ],

      "properties": {

        "hardwareProfile": {

          "vmSize": "[variables('vmSize')[parameters('Cpu-Gpu')]]"

        },

        "storageProfile": {

          "osDisk": {

            "createOption": "fromImage",

            "managedDisk": {

              "storageAccountType": "[variables('osDiskType')]"

            }

          },

          "imageReference": {

            "publisher": "microsoft-dsvm",

            "offer": "ubuntu-1804",

            "sku": "1804-gen2",

            "version": "latest"

          }

        },

        "networkProfile": {

          "networkInterfaces": [

            {

              "id": "[resourceId('Microsoft.Network/networkInterfaces', variables('networkInterfaceName'))]"

            }

          ]

        },

        "osProfile": {

          "computerName": "[variables('virtualMachineName')]",

          "adminUsername": "[parameters('adminUsername')]",

          "adminPassword": "[parameters('adminPasswordOrKey')]",

          "linuxConfiguration": "[if(equals(parameters('authenticationType'), 'password'), json('null'), variables('linuxConfiguration'))]"

        }

      }

    }

该模板中定义了以下资源:The following resources are defined in the template:

部署模板Deploy the template

若要通过 Azure CLI 使用该模板,请登录并选择你的订阅(请参阅使用 Azure CLI 登录)。To use the template from the Azure CLI, login and choose your subscription (See Sign in with Azure CLI). 运行:Then run:

read -p "Enter the name of the resource group to create:" resourceGroupName &&
read -p "Enter the Azure location (e.g., chinaeast2):" location &&
read -p "Enter the authentication type (must be 'password' or 'sshPublicKey') :" authenticationType &&
read -p "Enter the login name for the administrator account (may not be 'admin'):" adminUsername &&
read -p "Enter administrator account secure string (value of password or ssh public key):" adminPasswordOrKey &&
templateUri="https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/101-vm-ubuntu-DSVM-GPU-or-CPU/azuredeploy.json" &&
az group create --name $resourceGroupName --location "$location" &&
az deployment group create --resource-group $resourceGroupName --template-uri $templateUri --parameters adminUsername=$adminUsername authenticationType=$authenticationType adminPasswordOrKey=$adminPasswordOrKey && 
echo "Press [ENTER] to continue ..." &&
read

运行上述命令时,请输入:When you run the above command, enter:

  1. 要创建的包含 DSVM 和关联资源的资源组的名称。The name of the resource group you'd like to create to contain the DSVM and associated resources.
  2. 要在其中进行部署的 Azure 位置The Azure location in which you wish to make the deployment
  3. 要使用的身份验证类型(输入字符串 passwordsshPublicKeyThe authentication type you'd like to use (enter the string password or sshPublicKey)
  4. 管理员帐户的登录名(此值不能为 adminThe login name of the administrator account (this value may not be admin)
  5. 帐户的密码或 SSH 公钥的值The value of the password or ssh public key for the account

查看已部署的资源Review deployed resources

若要查看 Data Science Virtual Machine:To see your Data Science Virtual Machine:

  1. 转到 Azure 门户Go to the Azure portal
  2. 登录Sign in
  3. 选择刚创建的资源组Choose the resource group you just created

你将看到资源组的信息:You'll see the Resource Group's information:

包含 DSVM 的基本资源组的屏幕截图

单击虚拟机资源转到其信息页面。Click on the Virtual Machine resource to go to its information page. 可在此处找到 VM 的相关信息,包括连接详细信息。Here you can find information on the VM, including connection details.

清理资源Clean up resources

如果不想使用此虚拟机,请删除它。If you don't want to use this virtual machine, delete it. 由于 DSVM 与其他资源(例如存储帐户)关联,因此可能需要删除所创建的整个资源组。Since the DSVM is associated with other resources such as a storage account, you'll probably want to delete the entire resource group you created. 可以使用门户删除资源组,方法是单击“删除”按钮并进行确认。You can delete the resource group using the portal by clicking on the "Delete" button and confirming. 也可以从 CLI 中使用以下命令删除资源组:Or, you can delete the resource group from the CLI with:

echo "Enter the Resource Group name:" &&
read resourceGroupName &&
az group delete --name $resourceGroupName &&
echo "Press [ENTER] to continue ..."

后续步骤Next steps

在本快速入门中,你通过 Azure 资源管理器模板创建了 Data Science Virtual Machine。In this quickstart, you created a Data Science Virtual Machine from an Azure Resource Manager template.