A Virtual Machine Scale Set lets us easily create and manage multiple virtual machines.
All VMs in a scale set are identical, meaning they are created from the same base operating system image and configuration. Obviously, this approach lets us easily manage hundreds of VMs without additional configuration.
For traffic distribution, an Azure Load Balancer is also deployed along with the virtual machines in a scale set.With the auto-scale feature, the number of virtual machines can automatically increase or decrease in response to demand.
Log in to Azure
- Sign in to the Azure portal.
- Search for Virtual Machine Scale Set
- Click on "Virtual machine scale sets" and then "Create"
Create a virtual machine scale set
In the Basics tab, under Project details, make sure the correct subscription is selected and select NetworkwatcherRG from my resource group list.
- Type_VMSS_as the name for your scale set.
- In Region, select a region that is close to your area.
- Under Orchestration, ensure the Uniform option is selected for Orchestration mode.
- Select Autoscaling for scaling mode
Scaling Configuration
- Select an image
- Select size
- Click on configure to setup scaling configuration
Add Scaling Conditions
- Click add scaling condition
- Condition name -VMSS-COND
- Scale Mode - Autoscaling
- Initial instance count - 2
- Instance limit Minimum- 2 ,Maximum- 4
- Scale out CPU threshold greater than - 75%
- Increase instance count by - 1
- CPU threshold less than - 25%
- Decrease count by - 1
- Query duration - 5 minutes
- Click save
- Select condition
- Save
Authentication
- Select SSH key
- Username - azureuser
- SSH Keytype - RSA SSH format
- Azure automatically generates a key pair name
Networking
- Select virtual network: Azure automatically generated one, you can also select an existing virtual network.
- Edit Network Interface
Edit Network Interface
- Leave all as default
- Public inbound ports - allow all
- Select HTTP 80,SSH 22
- Enable public IP address
- OK
Create a Load Balancer
- Load balancing options: Select Azure load balancer
- Click on create load balancer
- Load balancer name -VMSS-LB
- leave everything as default
- Click create
- Review + Create
Create Virtual Machine Scale Set
- Validation passed
- Click create
Download Private key and create resource
- Download private key pair to your computer
Deployment
- Once deployment is complete
- Go to resources
Virtual Machine Scale Set
- Overview of the VMSS
- Copy the Public IP address to connect.
Instances
- We can see 2 instances running at the same time.
Connecting to the VMSS using Command Prompt
- Navigate to Command Prompt on a PC.
- Run this command the command below
ssh -i "path to the private key on the pc" username@publicIP -p 50000
After connecting to the VM,we run some sudo commands to test
sudo apt-get -y update
sudo apt-get -y install nginx
Testing Public IP on a Browser
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.
Top comments (0)