Azure Virtual Machine Scale Set: How to Create and Connect using SSH
Tags: cloudcomputing, azure, microsoft, tutorial
Published: 2024-06-28 07:01:36

Table of Contents <a name="content"></a>
[Overview of Virtual Machine Scale Set (VMSS)] (#overview)
[Creating Virtual Machine Scale Set] (#create)
[Connecting Virtual Machine Scale Set] (#connect)

## Overview of Virtual Machine Scale Set (VMSS) <a name="overview"></a>
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] (#content)_

## Creating Virtual Machine Scale Set <a name="create"></a>

#### 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ugwvw42atd3f3v3pu3ua.jpg)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q56lby8rquql8r8f7ma8.jpg)

#### 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6oj0jelzr8ceuykbahw8.jpg)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rydty90uirrj2jzjjg7v.jpg)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pqpn91egt7ohpel0mg5r.jpg)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0qwgb4cz083mzikz7cf2.jpg)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iq5ztg98wofrn741r7kv.jpg)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1tazfzch34gpeq9no0nu.jpg)
Ensure the condition added is selected on scaling configuration page and scale-in policy is set then save.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vilnt2jl64leoayqlq3g.jpg)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dsb4uxv5hpbnalcwwbt2.jpg)
 
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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9e4izy7tm4q1lb4m2n7o.jpg)

#### 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xokoyplvkcj246mpwem4.jpg)
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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ot7qdu74v4m49u9cw7ys.jpg)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e3unr6ferhtyuh0ree0m.jpg)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ykdpcbt7vq0083pkmker.jpg)
#### Step 5: Review and Create
Click review and create, review the details and click create. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1ooreqjg2d2yab8r17zv.jpg)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0zd7zvwvbrkbkbtbaovx.jpg)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/axwlj0oha9u97b15vgaf.jpg)

_[back to top] (#content)_

## Connecting Virtual Machine Scale Set <a name="connect"></a>
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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kivjhuyx27gkjem2ikh1.jpg)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xpwazf4cfvdutgfx9qjt.jpg)

_[back to top] (#content)_