Επεξεργασία

Κοινή χρήση μέσω


Quickstart: Create a Batch account by using ARM template

Get started with Azure Batch by using an Azure Resource Manager template (ARM template) to create a Batch account, including storage. You need a Batch account to create compute resources (pools of compute nodes) and Batch jobs. 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.

After completing this quickstart, you'll understand the key concepts of the Batch service and be ready to try Batch with more realistic workloads at larger scale.

An Azure Resource Manager template is a JavaScript Object Notation (JSON) file that defines the infrastructure and configuration for your project. The template uses declarative syntax. You describe your intended deployment without writing the sequence of programming commands to create the deployment.

If your environment meets the prerequisites and you're familiar with using ARM templates, select the Deploy to Azure button. The template will open in the Azure portal.

Button to deploy the Resource Manager template to Azure.

Prerequisites

You must have an active Azure subscription.

Review the template

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",
  "metadata": {
    "_generator": {
      "name": "bicep",
      "version": "0.26.54.24096",
      "templateHash": "5620168434409602803"
    }
  },
  "parameters": {
    "batchAccountName": {
      "type": "string",
      "defaultValue": "[format('{0}batch', toLower(uniqueString(resourceGroup().id)))]",
      "metadata": {
        "description": "Batch Account Name"
      }
    },
    "storageAccountsku": {
      "type": "string",
      "defaultValue": "Standard_LRS",
      "allowedValues": [
        "Standard_LRS",
        "Standard_GRS",
        "Standard_ZRS",
        "Premium_LRS"
      ],
      "metadata": {
        "description": "Storage Account type"
      }
    },
    "location": {
      "type": "string",
      "defaultValue": "[resourceGroup().location]",
      "metadata": {
        "description": "Location for all resources."
      }
    }
  },
  "variables": {
    "storageAccountName": "[format('{0}storage', uniqueString(resourceGroup().id))]"
  },
  "resources": [
    {
      "type": "Microsoft.Storage/storageAccounts",
      "apiVersion": "2023-01-01",
      "name": "[variables('storageAccountName')]",
      "location": "[parameters('location')]",
      "sku": {
        "name": "[parameters('storageAccountsku')]"
      },
      "kind": "StorageV2",
      "tags": {
        "ObjectName": "[variables('storageAccountName')]"
      },
      "properties": {
        "minimumTlsVersion": "TLS1_2",
        "allowBlobPublicAccess": false,
        "networkAcls": {
          "defaultAction": "Deny"
        },
        "supportsHttpsTrafficOnly": true
      }
    },
    {
      "type": "Microsoft.Batch/batchAccounts",
      "apiVersion": "2024-02-01",
      "name": "[parameters('batchAccountName')]",
      "location": "[parameters('location')]",
      "tags": {
        "ObjectName": "[parameters('batchAccountName')]"
      },
      "properties": {
        "autoStorage": {
          "storageAccountId": "[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]"
        }
      },
      "dependsOn": [
        "[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]"
      ]
    }
  ],
  "outputs": {
    "storageAccountName": {
      "type": "string",
      "value": "[variables('storageAccountName')]"
    },
    "batchAccountName": {
      "type": "string",
      "value": "[parameters('batchAccountName')]"
    },
    "location": {
      "type": "string",
      "value": "[parameters('location')]"
    },
    "resourceGroupName": {
      "type": "string",
      "value": "[resourceGroup().name]"
    },
    "resourceId": {
      "type": "string",
      "value": "[resourceId('Microsoft.Batch/batchAccounts', parameters('batchAccountName'))]"
    }
  }
}

Two Azure resources are defined in the template:

Deploy the template

  1. Select the following image to sign in to Azure and open a template. The template creates an Azure Batch account and a storage account.

    Button to deploy the Resource Manager template to Azure.

  2. Select or enter the following values.

    Resource Manager template, Batch account creation, deploy portal

    • 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, Central US.
    • Batch Account Name: Leave the default value.
    • Storage Accountsku: select a storage account type. For example, Standard_LRS.
    • Location: Leave the default so that the resources will be in the same location as your resource group.
  3. Select Review + create, then select Create.

After a few minutes, you should see a notification that the Batch account was successfully created.

In this example, the Azure portal is used to deploy the template. 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

You can validate the deployment in the Azure portal by navigating to the resource group you created. In the Overview screen, confirm that the Batch account and the storage account are present.

Clean up resources

If you plan to continue on with more of our tutorials, you may wish to leave these resources in place. 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

In this quickstart, you created a Batch account and a storage account. To learn more about Azure Batch, continue to the Azure Batch tutorials.