DEV Community

Cover image for Azure Virtual Machine Scale Set: How to Create and Connect using SSH
Celestina Odili
Celestina Odili

Posted on • Updated on

Azure Virtual Machine Scale Set: How to Create and Connect using SSH

Table of Contents
Overview of Virtual Machine Scale Set (VMSS)
Creating Virtual Machine Scale Set
Connecting Virtual Machine Scale Set

Overview of Virtual Machine Scale Set (VMSS)

Azure Virtual Machine Scale Set is a service that makes it possible to create and manage a group of load balanced VMs. Tt can be configured manually or automatically to scale out (increase the number of VMs) or scale in (decrease the number of VMs) based on demand or a defined schedule. The benefits of scale sets include:

  • Easy to create and manage multiple VMs.

Scale sets allow all VM instances to be created from the same base OS image and configuration. This makes it easy to create and manage many VMs without having to do extra configuration or network management.

  • Provides high availability and application resiliency.

Running multiple VM instances and distribution across availability zones or fault domains makes the application highly available and fault tolerant. There will be little or no down time if any of the VMs have problem.

  • Allows your application to automatically scale as resource demand changes.

With the auto scaling configuration, scale set can scale your application in or out in response to demand or schedule. This help to reduce cost for business owner and improve performance of the application leading to users' satisfaction.

  • Works at large-scale

With scale set, you can have up to 600 VM instances for managed images and 1000 for standard marketplace images and custom images through the Azure Compute Gallery.

back to top

Creating Virtual Machine Scale Set

Step 1: Sign to portal.azure.com

Step 2: Create Virtual Machine Scale Set

Search for virtual machine scale set in the search box and select virtual machine scale sets.

Image description

Click Create on the virtual machine scale sets page. This will open the create a virtual machine scale set basic page.

Image description

Step 3: Fill the basic tab parameters.

Fill the information in the following category
Project detail
Scale set detail
Orchestration
Instance details
Administration account

Under Project details, select the subscription and resource group. Create a new resource group if you do not have existing one. Under scale set details, type a name for the scale set and select a region of your choice.

Image description

Under Orchestration, select the Uniform Orchestration mode, set security type to standard and set scaling mode to autoscaling and click configure.

Image description

On the scaling configuration page that opens, click add a scaling condition.

Image description

Give it a name, fill the conditions as needed and click save.

Image description

Image description

Image description
Ensure the condition added is selected on scaling configuration page and scale-in policy is set then save.

Image description

Under instance details, Select a marketplace image for Image. An example is Ubuntu Server 22.04 LTS-x64 Gen2. choose a size for the VM instance.

Image description

Under administrator account, select ssh public key, input your desired username and key pair name. You can use the default if you wish.

Image description

Step 4: Network Configuration

Go to networking tab, configure network interface and create a load balancer. A virtual network and network interface is created by default. Under network interface, click the edit icon to edit the network interface created for you.

Image description
Set the public inbound ports to allow selected ports and select ssh 22 and HTTP 80. Enable public IP address and click ok.

Image description

Ensure you check the editted network interface. Select Azure load balancer and click create a load balancer

Image description

Type a name for the load balancer. Take note of the start value for frontend port range under inbound NAT rules then click create.

Image description

Step 5: Review and Create

Click review and create, review the details and click create.

Image description

After it has been validated, a Generate new key pair window will open. Select Download Private key and create resource. This will download the .pem key pair to your local computer.

Image description

When deployment is completed, clicking Go to resource will take you straight to the VMSS. You can carry out additional configurations if need be and view the instances that are running.
Image description

back to top

Connecting Virtual Machine Scale Set

On your local computer, open ssh connection through the in-built app for writing command. Find out the right one for your computer OS and open it. Use command prompt or PowerShell for window. For MacOS, the default app is called terminal. In this guide, command prompt is used.

Step 1: Open Command Prompt

Search for CMD and run as an administrator. Running as an administrator will help to prevent restriction.

Step 2: Type SSH Command

At the prompt, type
ssh space -i space path to the private key (.pem file downloaded) space username@public IP address and press enter.

example,
ssh -i "C:\Users\HP\Documents\Tina files\Project_key.pem" azureuser@52.232.125.22

If you experience idle time out add -p and 50000 (frontend port starting value) to the command. When connecting for the first time, you will be prompted to check and verify the host keys fingerprint. type yes to continue.

Image description

When your connection is successful, you will get a welcome message.

Image description

back to top

Top comments (0)