3.11. Launching and connecting to a RHEL VM in Azure
You need to create a managed disk Azure VM from the image.
Prerequisites
- You have completed the uploading of Azure VHD image to Azure Blob storage.
Procedure
Create the 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>Example:
$ az vm create \ -g azrhelclirsgrp2 -l southcentralus -n rhel-azure-vm-1 \1 --vnet-name azrhelclivnet1 --subnet azrhelclisubnet1 --size Standard_A2 \ --os-disk-name vm-1-osdisk --admin-username clouduser \2 --generate-ssh-keys --image rhel10 { "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" }-
--generate-ssh-keysoption creates a private and public key pair files in the~/.sshdirectory. The public key is added to the
authorized_keysfile on the VM for the user specified by the--admin-usernameoption.For details, see Types of SSH authentication methods. Note the
publicIpAddress, which you will need to log in to the VM in the following step.
-
Start an SSH session and log in to the Azure 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.
Verification
- If you successfully connected to the VM, you see a user prompt.
- Use the Microsoft Azure portal to check the audit logs, assigned resources properties, and manage virtual machines. For details, see Tutorial: Create and manage Linux VMs with the Azure portal.
-
You can also use the Azure CLI if you are managing many VMs. For details, enter
az --helpin the CLI or see Azure CLI command reference.