How to Create a Virtual Machine Scale Set in Azure
Tags: virtualmachinescaleset, vmss, azure, virtualmachine
Published: 2024-07-05 21:21:43

Creating a Virtual Machine Scale Set (VMSS) in Azure allows you to manage and automatically scale a group of [virtual machines](https://dev.to/florence_8042063da11e29d1/step-by-step-guide-to-create-deploy-and-connect-to-a-virtual-machine-on-azure-1b00). 

Here's a step-by-step guide to create a VMSS using the Azure portal:

###Step 1: Sign in to Azure Portal###
Open your web browser and go to the Azure portal.
Sign in with your [Azure](https://dev.to/florence_8042063da11e29d1/core-architectural-components-of-azure-all-you-need-to-know-2n5k) account credentials.

###Step 2: Navigate to Virtual Machine Scale Sets###
In the Azure portal, click the **"Create a resource"** button (+) in the left-hand menu.
In the **"Search the Marketplace"** box, type **"Virtual Machine Scale Sets"** and select it from the list.

![Type and select Virtual Machine Scale Set in the search box on Azure](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r1y9xg3avcnr2usvefiu.png)
Click "Create" to start the creation process.

![Click on create](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/93862rh32jkpa2eksx1k.png)

###Step 3: Configure Basic Settings###
**Subscription**: Select your Azure subscription.
**Resource Group**: Select an existing resource group or create a new one.
**Name**: Enter a name for your scale set.
**Region**: Choose the region where you want to deploy the VMSS.
**Availability Zone**: (Optional) Select an availability zone if required.

![select or create resource group, name, region, and availability zone](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fu2o5mevjfkolohut8ql.png)

**Orchestration mode**: Choose Uniform (recommended for most scenarios) or Flexible.
**Scaling mode**: Choose **Autoscaling**, there are other options.
For **Scaling configuration** click on **Configure**

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

###Step 4: Scaling Configuration###
**Scaling conditions**: Click on **Add a Scaling Condition**

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

**Configure Scaling Settings**
**Instance Count**: Set the initial number of instances (e.g., 2).
**Scaling Policy**: Configure the scaling policy to automatically increase or decrease the number of instances based on CPU usage, memory, or custom metrics. Select the conditions, then click on **Save**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6opg9qo24qkzdfx3pavv.png)
This takes us back to **Scaling Configuration** where the scale condition added appears.

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

Click on **Save**, which takes us back to where we started to **Create a virtual machine scale set** the next step is to configure instance details

###Step 5: Configure Instance Details###
**Image**: Select an operating system image for your VMs (e.g., Ubuntu Server 20.04 LTS).
**Size**: Choose a VM size (e.g., Standard DS1 v2).
For **Authentication type** select **SSH public key**

###Step 6: Configure Networking###
To **edit the network interface**, click on the icon.

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hd0l0sp7lixg28xia3m0.png)
**Select inbound ports**: Select **HTTP (80), SSH (22)

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

Also enable **Public IP address** and **Accelerated networking** then click on **Ok**

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

Select network interface and on the **Load balancing options** select **Azure load balancer**

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

On **Select a load balancer**, if there is no existing load balancer, click on **Create a load balancer**. A load balancer helps to distribute traffic across the VMs.
After creating a load balancer, click on **Review and create**

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


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

###Step 7: Download Private Key###

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/06o5dp9p0wa41jty9tth.png)
When deployment is complete, click on **Go to resource**

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

Click on **Networking** then **Load balancing**

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

**Copy IP address**

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

Go to **Command prompt** and **Run as administrator**

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

In the **Command prompt** type in "ssh -i", the file path of the **Download private key** in your file manager, username, and IP address

###Step 8: Install Web Server###
To install web server, type in **sudo apt-get update**  

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

Type **sudo apt-get install nginx -y** in the next prompt

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

View of the **Web Server**

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

###Step 9: Monitor###

Use the "Instances" tab to monitor the status of individual VM instances.
Click on **Monitoring**, and then **Metrics** to monitor the workload

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

Use the "Scaling" tab to adjust scaling policies and settings.

Conclusion
By following these steps, you can create a Virtual Machine Scale Set in Azure, which allows you to automatically scale your application based on demand, ensuring high availability and performance.