빠른 시작: Bicep 파일을 사용하여 배치 계정 만들기

Bicep 파일을 사용하여 스토리지를 포함한 배치 계정을 만들어 Azure Batch를 시작합니다. 컴퓨팅 리소스(컴퓨팅 노드의 풀) 및 Batch 작업을 만들려면 배치 계정이 필요합니다. Azure Storage 계정을 배치 계정과 연결할 수 있습니다. 이는 애플리케이션을 배포하고 대부분의 실제 작업에 대한 입력 및 출력 데이터를 저장하는 데 유용합니다.

이 빠른 시작을 완료하면, Batch 서비스의 주요 개념을 이해하고 더 큰 규모의 더 실제적인 작업으로 Batch를 시도할 준비가 됩니다.

Bicep은 선언적 구문을 사용하여 Azure 리소스를 배포하는 DSL(도메인 특정 언어)입니다. 간결한 구문, 신뢰할 수 있는 형식 안전성 및 코드 다시 사용에 대한 지원을 제공합니다. Bicep은 Azure에서 코드형 인프라 솔루션에 대한 최고의 제작 환경을 제공합니다.

필수 조건

활성 Azure 구독이 있어야 합니다.

Bicep 파일 검토

이 빠른 시작에서 사용되는 Bicep 파일은 Azure 빠른 시작 템플릿에서 나온 것입니다.

@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

Bicep 파일에는 두 개의 Azure 리소스가 정의되어 있습니다.

Bicep 파일 배포

  1. Bicep 파일을 main.bicep으로 로컬 컴퓨터에 저장합니다.

  2. Azure CLI 또는 Azure PowerShell을 사용하여 Bicep 파일을 배포합니다.

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

    배포가 완료되면 배포에 성공했음을 나타내는 메시지가 표시됩니다.

배포 유효성 검사

Azure Portal, Azure CLI 또는 Azure PowerShell을 사용하여 리소스 그룹에 배포된 리소스를 나열합니다.

az resource list --resource-group exampleRG

리소스 정리

더 많은 자습서를 계속 진행하려는 경우 이러한 리소스를 그대로 유지하는 것이 좋습니다. 더 이상 필요 없으면 Azure Portal, Azure CLI 또는 Azure PowerShell을 사용하여 리소스 그룹 및 모든 해당 리소스를 삭제합니다.

az group delete --name exampleRG

다음 단계

이 빠른 시작에서는 Bicep을 사용하여 배치 계정과 스토리지 계정을 만들었습니다. Azure Batch에 대한 자세한 내용은 Azure Batch 자습서로 계속 진행하세요.