Tutorial to Create a Virtual Machine Scale Set in Microsoft Azure.
Published: 2024-06-28 22:58:29

In the world of cloud scalability, Microsoft Azure's Virtual Machine Scale Sets (VMSS) are revolutionary. This guide will show you how to set up a VMSS using the Microsoft Azure Portal, step by step. Let's begin! 

**Step 1**
Sign in to the Azure Portal at https://portal.azure.com. 
	
**Step 2**
Go to the home page and click on the **+ Create** or use an existing resource icon.
 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3zollc8693lyfv3brogn.png)

**Step 3**
Navigate to the search bar, look for **virtual machine scale set** and select it. Click on **Create** and then select **Virtual machine scale set** to go to the **Create a virtual machine scale set** page.

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

**Step 4**
On the **Basic tab**, choose the relevant subscription and resource group under **Project details**
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hwz89ovpke6mgd6urmuq.png)

**Step 5**
Provide a name for the VMSS, select your preferred region, and choose an availability zone under **Scale set details.**

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

**Step 6**
Under **Orchestration Mode**, ensure the Uniform option is selected, security type, **Standard** is selected and Scaling to **Autoscaling**
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z5ql82j5tbwea48f1wlh.png)

**Step 7**
Scaling Configuration
Click on **Configure** to get details of scaling configuration.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2ew39q1cpc4i581cxled.png)

click **+ add a scaling condition** and create a scaling condition name 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nn8495wdhezdo71bae1t.png)

Select mode to **Autoscaling**, type your initial instance, instance limit, scale out or in, query duration and your schedule then **save**.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/238avh2vhju24cyfs0bw.png)

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

**Predictive Scaling**: click on checkbox to enable forecast for predictive autoscaling
**Scaling in policy**:  Newest VM- Balance across zone then delete the newest created VM and **save** your configuration.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/47uukwmxmfvk0w8b5yf7.png)

**Step 8**
**Instance Details**
Image, in this example, we have chosen Ubuntu Server 20.04 LTS - x64 Gen2, VM architecture, and size according to your needs

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/33vg0dt50k2v5j22mwsg.png)
Enter your desired username, and select which authentication type you prefer for administrator account

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

Select **Next**: **Spot** set as default.
Select **Next**: **Disks** to move the disk configuration options. For this quickstart, leave the default disk configurations.

Select **Next**: **Networking** to move the networking configuration options.
Edit network interface, select your inbound port **HTTP (80), SSH (22)**, then click on enable IP address and press **OK**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/18oqs35le0ttj2luahcu.png)

Click on the checkbox to the virtual network interface.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zzsl151e8zckha2eczdq.png)

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


On the Networking page, under **Load balancing**, select the Use a load balancer checkbox to put the scale set **instances behind a load balancer**. In Load balancing options, select **Azure load balancer**. In Select a load balancer, select your load balancer or **create** a new one.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9yig7u4i1hami9du6sm1.png)

**Step 9**
Click on **Review + create** to proceed. After it passes validation, select **Create** to deploy the scale set.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fei58pralrqm4gzqxs65.png)

Now you will see that the VMSS has been deployed successfully.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6hh841c6a0qnerh6fsgt.png)

**Step 10**

On a Windows machine, search for a command prompt and click Run as **administrator**

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

Click on your download to get your key file and ensure you note the download location of the .PEM file, then you right click on your .PEM File and select on **Properties** to locate your file path as you will need its path in the next step.

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

For connection you will need your command prompt, username and the IP address to run on your terminal. In your command prompt, initiate an SSH connection to your virtual machine and substitute the VM's IP address for the placeholder, and replace the file path with the actual path where the key file was downloaded.(`ssh -i "/path/to/your/private-key-file.pem" username@your-vm-public-ip`- p 50000)

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

**Clean up resources**
When no longer needed, delete the resource group, scale set, and all related resources. To do so, select the resource group for the scale set and then select **Delete**.