Canarys | IT Services

Blogs

VMSS deployment Using Custom VM Image

Share

In this blog we will see the VMSS update by using an image with Rolling upgrade policy.

Prerequisites:

Create a VM image in the portal to update the VMSS with that image.

VMSS needs to be created with the custom image.

Step 1

Creation of VM image to be used while creating a VMSS. Select capture to create a VM image.

1

Provide the details and create the image of VM as shown below.

2

After creating the VM image, wait for some time to load the image. So that your captured image will be available, search for images in portal

3

Step 2

Create a VMSS, search for VMSS in search box. Create a VMSS

4

In the basics section add the required fields and use the captured image to create VMSS for that, AT IMAGE blade select browse all public and private images.

5

It will pop up for selecting the images and click on my items blade and the select the image

6Add the authentication type as password

7

Click on next and leave the disks as default and click on networking, enable load balancer

8In scaling section, select the scaling policy as custom and add values based on requirement or leave it default.

9

In the management section opt for rolling upgrade policy.

10

11

In the health section enable the monitor and from application health monitor drop down select the load balancer probe and set the protocol to TCP and port number as 22

12

Skip the next sections and create the VMSS

Once your VMSS is created, now we will update the VMSS using a new image, for that we will create new VM and will create sample files or directories inside the new VM and capture the image.

 

 

Once VM is created, go the serial console of it and add directory and create sample file with some text.

13

So I used following commands to create some files in my VM using serial console.

14

Now capture this vm to create a new image and get the image.reference.id

15

Click on newly created image to get imge.reference.id nothing but resource.id copy it paste it on notepad

16

Create a sample project of any name and create a release a pipeline by choosing an empty job.

17

And select stage 1 job and add tasks to that stage.

18

Then configure the agent job with agent pool and agent specification by giving name to that job.

19

The add a task called azure cli and configure it for VMSS update by using an image.

20

Select the right subscription to establish service connection to azure resources, where you have deployed the Azure VMSS. Select the script type as shell using dropdown and choose inline script and add the Az cli script.

21

Az cli for updating the VMSS is as follows.

echo "*******************"

az vmss show –name (VMSSNAME) –resource-group (RGName) | grep images;

 

##here imageReference.id   needs to be given to update the  vmss.  Use the copied  resource.id from the newly created image and use it in the below command.

 

az vmss update –resource-group RGname –name VMSSname –set virtualMachineProfile.storageProfile.imageReference.id=/subscriptions/xxxxxxxxxxxxxxxf788a44c3b2d/resourceGroups/xxxxx/providers/Microsoft.Compute/images/anothervm-image

az vmss show –name VMSSname –resource-group RGname | grep images;

echo "***************"

Now create release, after completing the release, go for serial console of VMSS and check for the created sample file and directory.

Since we opted for Rolling upgrade policy each instance will update in a manner of condition’s we set that is one instance followed by another.

Leave a Reply

Your email address will not be published. Required fields are marked *

Reach Us

With Canarys,
Let’s Plan. Grow. Strive. Succeed.