快速入门:使用 ARM 模板创建批处理帐户Quickstart: Create a Batch account by using ARM template

需要一个 Batch 帐户来创建计算资源(计算节点池)和批处理作业。You need a Batch account to create compute resources (pools of compute nodes) and Batch jobs. 可将 Azure 存储帐户与 Batch 帐户关联,后者可以用于为大多数现实世界的工作负荷部署应用程序和存储输入和输出数据。You can link an Azure Storage account with your Batch account, which is useful to deploy applications and store input and output data for most real-world workloads. 本快速入门介绍如何使用 Azure 资源管理器模板(ARM 模板)创建批处理帐户(包括存储)。This quickstart shows how to use an Azure Resource Manager template (ARM template) to create a Batch account, including storage. 完成本快速入门以后,你会了解 Batch 服务的重要概念,并可使用更逼真的工作负荷进行更大规模的 Batch 试用。After completing this quickstart, you will understand the key concepts of the Batch service and be ready to try Batch with more realistic workloads at larger scale.

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.

部署到 Azure Deploy to Azure

先决条件Prerequisites

必须拥有一个有效的 Azure 订阅。You must have an active Azure subscription.

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

查看模板Review the template

本快速入门中使用的模板来自 Azure 快速启动模板The template used in this quickstart is from Azure Quickstart Templates.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "batchAccountName": {
      "type": "string",
      "defaultValue": "[concat(toLower(uniqueString(resourceGroup().id)), 'batch')]",
      "metadata": {
        "description": "Batch Account Name"
      }
    },
    "storageAccountsku": {
      "type": "string",
      "defaultValue": "Standard_LRS",
      "allowedValues": [
        "Standard_LRS",
        "Standard_GRS",
        "Premium_LRS"
      ],
      "metadata": {
        "description": "Storage Account type"
      }
    },
    "location": {
      "type": "string",
      "defaultValue": "[resourceGroup().location]",
      "metadata": {
        "description": "Location for all resources."
      }
    }
  },
  "variables": {
    

    "storageAccountName": "[concat(uniqueString(resourceGroup().id),'storage')]"
  },
  "resources": [
    {
      "comments": "This storage account is used to associate to a batch account",
      "type": "Microsoft.Storage/storageAccounts",
      "apiVersion": "2019-06-01",
      "name": "[variables('storageAccountname')]",
      "location": "[parameters('location')]",
      "sku": {
        "name": "[parameters('storageAccountsku')]"
      },
      "kind": "StorageV2",
      "tags": {
        "ObjectName": "[variables('storageAccountName')]"
      },
      "properties": {}
    },
    {
      "type": "Microsoft.Batch/batchAccounts",
      "apiVersion": "2019-08-01",
      "name": "[parameters('batchAccountName')]",
      "location": "[parameters('location')]",
      "dependsOn": [
        "[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]"
      ],
      "tags": {
        "ObjectName": "[parameters('batchAccountName')]"
      },
      "properties": {
        "autoStorage": {
          "storageAccountId": "[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]"
        }
      }
    }
  ],
  "outputs": {
    "storageAccountEndPoint": "https://core.chinacloudapi.cn/",

    "storageAccountName": {
      "type": "string",
      "value": "[variables('storageAccountName')]"
    },
    "batchAccountName": {
      "type": "string",
      "value": "[parameters('batchAccountName')]"
    }
  }
}

该模板中定义了两个 Azure 资源:Two Azure resources are defined in the template:

  • Microsoft.Storage/storageAccounts:创建存储帐户。Microsoft.Storage/storageAccounts: Creates a storage account.
  • Microsoft.Batch/batchAccounts:创建 Batch 帐户。Microsoft.Batch/batchAccounts: Creates a Batch account.

部署模板Deploy the template

  1. 选择下图登录到 Azure 并打开一个模板。Select the following image to sign in to Azure and open a template. 该模板将创建一个 Azure Batch 帐户和一个存储帐户。The template creates an Azure Batch account and a storage account.

    部署到 Azure Deploy to Azure

  2. 选择或输入以下值。Select or enter the following values.

    资源管理器模板、Batch 帐户创建、部署门户

    • 订阅:选择一个 Azure 订阅。Subscription: select an Azure subscription.
    • 资源组:选择“新建”,输入资源组的唯一名称,然后单击“确定”。 Resource group: select Create new, enter a unique name for the resource group, and then click OK.
    • 位置:选择一个位置。Location: select a location. 例如,中国北部For example, China North.
    • Batch 帐户名:保留默认值。Batch Account Name: Leave the default value.
    • 存储帐户 sku:选择一个存储帐户类型。Storage Accountsku: select a storage account type. 例如 Standard_LRS。For example, Standard_LRS.
    • 位置:保留默认值,以便资源与资源组位于相同位置。Location: Leave the default so that the resources will be in the same location as your resource group.
    • 我同意上述条款和条件:选择。I agree to the terms and conditions stated above: Select.
  3. 选择“购买”。Select Purchase.

几分钟后,应会看到一条通知指出已成功创建 Batch 帐户。After a few minutes, you should see a notification that the Batch account was successfully created.

在此示例中,使用 Azure 门户部署模板。In this example, the Azure portal is used to deploy the template. 除了 Azure 门户,还可以使用 Azure PowerShell、Azure CLI 和 REST API。In addition to the Azure portal, you can also use the Azure PowerShell, Azure CLI, and REST API. 若要了解其他部署方法,请参阅部署模板To learn other deployment methods, see Deploy templates.

验证部署Validate the deployment

可以通过导航到你创建的资源组在 Azure 门户中验证部署。You can validate the deployment in the Azure portal by navigating to the resource group you created. 在“概述”屏幕上,确认是否存在 Batch 帐户和存储帐户。In the Overview screen, confirm that the Batch account and the storage account are present.

清理资源Clean up resources

如果打算继续使用后续的教程,则可能需要保留这些资源。If you plan to continue on to work with subsequent tutorials, you may wish to leave these resources in place. 或者,如果不再需要这些资源,可以删除资源组,此操作还将删除你创建的 Batch 帐户和存储帐户。Or, if you no longer need them, you can delete the resource group, which will also delete the Batch account and the storage account that you created.

后续步骤Next steps

本快速入门创建了 Batch 帐户和存储帐户。In this quickstart, you created a Batch account and a storage account. 若要详细了解 Azure Batch,请继续学习 Azure Batch 教程。To learn more about Azure Batch, continue to the Azure Batch tutorials.