Quickstart: Een Batch-account maken met behulp van een Bicep-bestand

Ga aan de slag met Azure Batch met behulp van een Bicep-bestand om een Batch-account te maken, inclusief opslag. U hebt een Batch-account nodig om rekenresources (pools met rekenknooppunten) en Batch-taken te maken. Als u een Azure Storage-account koppelt aan uw Batch-account, kunt u toepassingen implementeren en invoer- en uitvoergegevens voor de meeste workloads uit de praktijk opslaan.

Nadat u deze quickstart hebt voltooid, begrijpt u de belangrijkste principes van de Batch-service en bent u er klaar voor om Batch op grotere schaal te gebruiken voor meer realistische workloads.

Bicep is een domeinspecifieke taal (DSL) die declaratieve syntaxis gebruikt om Azure-resources te implementeren. Deze taal voorziet in een beknopte syntaxis, betrouwbare typeveiligheid en ondersteuning voor hergebruik van code. Bicep biedt de beste ontwerpervaring voor uw infrastructuur als code-oplossingen in Azure.

Vereisten

U hebt een actief Azure-abonnement nodig.

Het Bicep-bestand controleren

Het Bicep-bestand dat in deze quickstart wordt gebruikt, is afkomstig van Azure-quickstartsjablonen.

@description('Batch Account Name')
param batchAccountName string = '${toLower(uniqueString(resourceGroup().id))}batch'

@description('Storage Account type')
@allowed([
  'Standard_LRS'
  'Standard_GRS'
  'Standard_ZRS'
  'Premium_LRS'
])
param storageAccountsku string = 'Standard_LRS'

@description('Location for all resources.')
param location string = resourceGroup().location

var storageAccountName = '${uniqueString(resourceGroup().id)}storage'

resource storageAccount 'Microsoft.Storage/storageAccounts@2023-01-01' = {
  name: storageAccountName
  location: location
  sku: {
    name: storageAccountsku
  }
  kind: 'StorageV2'
  tags: {
    ObjectName: storageAccountName
  }
  properties: {
    minimumTlsVersion: 'TLS1_2'
    allowBlobPublicAccess: false
    networkAcls: {
      defaultAction: 'Deny'
    }
    supportsHttpsTrafficOnly: true
  }
}

resource batchAccount 'Microsoft.Batch/batchAccounts@2024-02-01' = {
  name: batchAccountName
  location: location
  tags: {
    ObjectName: batchAccountName
  }
  properties: {
    autoStorage: {
      storageAccountId: storageAccount.id
    }
  }
}

output storageAccountName string = storageAccount.name
output batchAccountName string = batchAccount.name
output location string = location
output resourceGroupName string = resourceGroup().name
output resourceId string = batchAccount.id

Er worden twee Azure-resources gedefinieerd in het Bicep-bestand:

Het Bicep-bestand implementeren

  1. Sla het Bicep-bestand op als main.bicep op uw lokale computer.

  2. Implementeer het Bicep-bestand met behulp van Azure CLI of Azure PowerShell.

    az group create --name exampleRG --location eastus
    az deployment group create --resource-group exampleRG --template-file main.bicep
    

    Wanneer de implementatie is voltooid, ziet u een bericht waarin wordt aangegeven dat de implementatie is voltooid.

De implementatie valideren

Gebruik Azure Portal, Azure CLI of Azure PowerShell om de geïmplementeerde resources in de resourcegroep weer te geven.

az resource list --resource-group exampleRG

Resources opschonen

Als u van plan bent om door te gaan met meer zelfstudies, wilt u deze resources mogelijk behouden. Gebruik de Azure-portal, Azure CLI of Azure PowerShell om de resourcegroep en alle bijbehorende resources te verwijderen wanneer u deze niet meer nodig hebt.

az group delete --name exampleRG

Volgende stappen

In deze quickstart hebt u een Batch-account en een opslagaccount gemaakt met Bicep. Voor meer informatie over Azure Batch gaat u naar de Azure Batch-zelfstudies.