3.8. Azure에서 VM 생성 및 시작

다음 단계에서는 이미지에서 관리 디스크 Azure VM을 생성하는 최소 명령 옵션을 제공합니다. 추가 옵션은 az vm create를 참조하십시오.

절차

  1. 다음 명령을 입력하여 VM을 생성합니다.

    $ az vm create \
        -g <resource-group> -l <azure-region> -n <vm-name> \
        --vnet-name <vnet-name> --subnet <subnet-name> --size Standard_A2 \
        --os-disk-name <simple-name> --admin-username <administrator-name> \
        --generate-ssh-keys --image <path-to-image>
    참고

    --generate-ssh-keys 옵션은 개인/공개 키 쌍을 생성합니다. 개인 키 및 공개 키 파일은 시스템의 ~/.ssh에 생성됩니다. 공개 키는 --admin-username 옵션으로 지정한 사용자에 대해 VM의 authorized_keys 파일에 추가됩니다. 자세한 내용은 기타 인증 방법을 참조하십시오.

    예제:

    [clouduser@localhost]$ az vm create \
    -g azrhelclirsgrp2 -l southcentralus -n rhel-azure-vm-1 \
    --vnet-name azrhelclivnet1 --subnet azrhelclisubnet1 --size Standard_A2 \
    --os-disk-name vm-1-osdisk --admin-username clouduser \
    --generate-ssh-keys --image rhel9
    
    {
      "fqdns": "",
      "id": "/subscriptions//resourceGroups/azrhelclirsgrp/providers/Microsoft.Compute/virtualMachines/rhel-azure-vm-1",
      "location": "southcentralus",
      "macAddress": "",
      "powerState": "VM running",
      "privateIpAddress": "10.0.0.4",
      "publicIpAddress": "<public-IP-address>",
      "resourceGroup": "azrhelclirsgrp2"

    publicIpAddress를 확인합니다. 다음 단계에서 VM에 로그인하려면 이 주소가 필요합니다.

  2. SSH 세션을 시작하고 VM에 로그인합니다.

    [clouduser@localhost]$ ssh -i /home/clouduser/.ssh/id_rsa clouduser@<public-IP-address>.
    The authenticity of host ',<public-IP-address>' can't be established.
    Are you sure you want to continue connecting (yes/no)? yes
    Warning: Permanently added '<public-IP-address>' (ECDSA) to the list of known hosts.
    
    [clouduser@rhel-azure-vm-1 ~]$

사용자 프롬프트가 표시되면 Azure VM을 성공적으로 배포한 것입니다.

이제 Microsoft Azure 포털로 이동하여 리소스의 감사 로그 및 속성을 확인할 수 있습니다. 이 포털에서 VM을 직접 관리할 수 있습니다. 여러 VM을 관리하는 경우 Azure CLI를 사용해야 합니다. Azure CLI는 Azure의 리소스에 강력한 인터페이스를 제공합니다. CLI에 az --help를 입력하거나 Azure CLI 명령 참조를 사용하여 Microsoft Azure에서 VM을 관리하는 데 사용하는 명령에 대한 자세한 내용을 참조하십시오.