1. 리소스 그룹 생성
az group create -n myResourceGroup -l koreacentral
2. Azure 자격 증명 만들기
az ad sp create-for-rbac --query "{ client_id: appId, client_secret: password, tenant_id: tenant }"
3.Azure 구독 ID를 가져오기
az account show --query "{ subscription_id: id }"
4.packer centos7.7.json 생성
{
"builders": [{
"type": "azure-arm",
"client_id": "f5b6a5cf-fbdf-4a9f-b3b8-3c2cd00225a4",
"client_secret": "0e760437-bf34-4aad-9f8d-870be799c55d",
"tenant_id": "72f988bf-86f1-41af-91ab-2d7cd011db47",
"subscription_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx",
"managed_image_resource_group_name": "myResourceGroup",
"managed_image_name": "myPackerImage",
"os_type": "Linux",
"image_publisher": "OpenLogic",
"image_offer": "CentOS",
"image_sku": "7.7",
"azure_tags": {
"dept": "Engineering",
"task": "Image deployment"
},
"location": "Korea Central",
"vm_size": "Standard_DS2_v2"
}],
"provisioners": [{
"execute_command": "chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh '{{ .Path }}'",
"inline": [
"yum update -y",
"rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm",
"yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo",
"yum install -y yum-utils device-mapper-persistent-data lvm2",
"yum install -y docker-ce-18.06.2.ce",
"setenforce 0",
"sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config"
],
"inline_shebang": "/bin/sh -x",
"type": "shell"
}]
}
참고사항
...더보기
az vm image list --output table
5. Packer로 이미지 생성 ( 10~15분 소요)
./packer build ubuntu.json
6. 생성된 이미지로 vm 생성하기
az vm create \
--resource-group myResourceGroup \
--name myVM \
--image myPackerImage \
--admin-username azureuser \
--generate-ssh-keys
7. vm의 80 포트 open
az vm open-port \
--resource-group myResourceGroup \
--name myVM \
--port 80
8. test
http://publicIpAddress
728x90
댓글