DEV Community

Tracy Chinedu
Tracy Chinedu

Posted on

Creating a Virtual Machine Scale Set on Azure Portal

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"

Image description

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 Image description

Scaling Configuration

  • Select an image
  • Select size
  • Click on configure to setup scaling configuration Image description

Add Scaling Conditions

  • Click add scaling condition

Image description

  • 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

Image description

  • Select condition
  • Save

Authentication

  • Select SSH key
  • Username - azureuser
  • SSH Keytype - RSA SSH format
  • Azure automatically generates a key pair name Image description

Networking

  • Select virtual network: Azure automatically generated one, you can also select an existing virtual network.
  • Edit Network Interface Image description

Edit Network Interface

  • Leave all as default
  • Public inbound ports - allow all
  • Select HTTP 80,SSH 22
  • Enable public IP address
  • OK

Image description

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 Image description

Create Virtual Machine Scale Set

  • Validation passed
  • Click create

Image description

Download Private key and create resource

  • Download private key pair to your computer Image description

Deployment

  • Once deployment is complete
  • Go to resources

Image description
Image description

Virtual Machine Scale Set

  • Overview of the VMSS
  • Copy the Public IP address to connect. Image description

Instances

  • We can see 2 instances running at the same time. Image description

Inbound NAT Rules
Image description

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

Image description

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
Image description

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)