이 문서에서는 Terraform 구성 파일을 사용하여 Azure Machine Learning 작업 영역을 만들고 관리하는 방법을 알아봅니다. Terraform의 템플릿 기반 구성 파일을 사용하면 반복 가능하고 예측 가능한 방식으로 Azure 리소스를 정의하고, 만들고, 구성할 수 있습니다. Terraform은 리소스 상태를 추적하고 리소스를 정리 및 삭제할 수 있습니다.
Terraform 구성은 배포에 필요한 리소스를 정의하는 문서입니다. 배포 변수를 지정할 수도 있습니다. 변수는 구성을 사용할 때 입력 값을 제공하는 데 사용됩니다.
새 작업 영역을 만들 때 작업 영역에 필요한 서비스를 자동으로 만들거나 기존 서비스를 사용할 수 있습니다. 작업 영역과 다른 Azure 구독의 기존 서비스를 사용하려면 해당 서비스가 포함된 구독에 Azure Machine Learning 네임스페이스를 등록해야 합니다. 예를 들어, 구독 B의 스토리지 계정을 사용하는 구독 A에서 작업 영역을 만드는 경우 작업 영역에서 스토리지 계정을 사용하려면 먼저 Azure Machine Learning 네임스페이스를 구독 B에 등록해야 합니다.
Azure Machine Learning의 리소스 공급자는 Microsoft.MachineLearningServices입니다. 등록 여부를 확인하는 방법 및 등록하는 방법에 대한 자세한 내용은 Azure 리소스 공급자 및 형식 문서를 참조하세요.
Important
이는 Azure Storage Accounts, Azure Container Register, Azure Key Vault 및 Application Insights 등의 작업 영역을 만드는 동안 제공된 리소스에만 적용됩니다.
팁
Azure Application Insights 인스턴스는 작업 영역을 만들 때 만들어집니다. 원하는 경우 클러스터를 만든 후 Application Insights 인스턴스를 삭제할 수 있습니다. 이 인스턴스를 삭제하면 작업 영역에서 수집되는 정보가 제한되며, 문제를 해결하기가 더 어려워질 수 있습니다. 작업 영역에서 만든 Application Insights 인스턴스를 삭제하는 경우 작업 영역을 삭제하고 다시 만들어야만 인스턴스를 다시 만들 수 없습니다.
이름이 main.tf인 새 파일을 만듭니다. Azure Cloud Shell을 사용하는 경우 bash를 사용합니다.
code main.tf
다음 코드를 편집기에 붙여 넣습니다.
main.tf:
data "azurerm_client_config" "current" {}
resource "azurerm_resource_group" "default" {
name = "${random_pet.prefix.id}-rg"
location = var.location
}
resource "random_pet" "prefix" {
prefix = var.prefix
length = 2
}
resource "random_integer" "suffix" {
min = 10000000
max = 99999999
}
파일을 저장(<Ctrl>S)하고 편집기를 종료(<Ctrl>Q)합니다.
작업 영역 배포
다음 Terraform 구성을 사용하여 Azure Machine Learning 작업 영역을 만들 수 있습니다. Azure Machine Learning 작업 영역을 만들 때 다양한 다른 서비스가 종속성으로 필요합니다. 템플릿은 작업 영역에 연결된 이러한 리소스도 지정합니다. 필요에 따라 공용 또는 프라이빗 네트워크 연결로 리소스를 만드는 템플릿을 사용하도록 선택할 수 있습니다.
아래 구성은 Azure Private Link 엔드포인트를 사용하여 격리된 네트워크 환경에 작업 영역을 만듭니다. 프라이빗 DNS 영역은 가상 네트워크 내에서 도메인 이름을 확인할 수 있도록 포함됩니다.
Azure의 일부 리소스에는 전역적으로 고유한 이름이 필요합니다. 다음 템플릿을 사용하여 리소스를 배포하기 전에 resourceprefix 변수를 고유한 값으로 설정합니다.
Azure Container Registry 및 Azure Machine Learning 프라이빗 링크 엔드포인트를 사용하는 경우 Azure Container Registry 작업은 환경 이미지를 빌드하는 데 사용할 수 없습니다. 대신 Azure Machine Learning 컴퓨팅 클러스터를 사용하여 이미지를 빌드할 수 있습니다. 사용할 클러스터 이름을 구성하려면 image_build_compute_name 인수를 설정합니다. public_network_access_enabled 인수를 사용하여 프라이빗 링크 엔드포인트가 있는 작업 영역에 대한 공용 액세스를 허용하도록 구성할 수 있습니다.
variables.tf:
variable "name" {
type = string
description = "Name of the deployment"
default = "examplehost"
}
variable "environment" {
type = string
description = "Name of the environment"
default = "dev"
}
variable "location" {
type = string
description = "Location of the resources"
default = "East US"
}
variable "vnet_address_space" {
type = list(string)
description = "Address space of the virtual network"
default = ["10.0.0.0/16"]
}
variable "training_subnet_address_space" {
type = list(string)
description = "Address space of the training subnet"
default = ["10.0.1.0/24"]
}
variable "aks_subnet_address_space" {
type = list(string)
description = "Address space of the aks subnet"
default = ["10.0.2.0/23"]
}
variable "ml_subnet_address_space" {
type = list(string)
description = "Address space of the ML workspace subnet"
default = ["10.0.0.0/24"]
}
variable "dsvm_subnet_address_space" {
type = list(string)
description = "Address space of the DSVM subnet"
default = ["10.0.4.0/24"]
}
variable "bastion_subnet_address_space" {
type = list(string)
description = "Address space of the bastion subnet"
default = ["10.0.5.0/24"]
}
variable "image_build_compute_name" {
type = string
description = "Name of the compute cluster to be created and set to build docker images"
default = "image-builder"
}
# DSVM Variables
variable "dsvm_name" {
type = string
description = "Name of the Data Science VM"
default = "vmdsvm01"
}
variable "dsvm_admin_username" {
type = string
description = "Admin username of the Data Science VM"
default = "azureadmin"
}
variable "dsvm_host_password" {
type = string
description = "Password for the admin username of the Data Science VM"
default = "ChangeMe123!"
sensitive = true
}