VMSS with custom image preparation

sns 9,226 Reputation points
2023-07-29T12:31:55.3933333+00:00

I have created a VM scale set with uniform orchaestration

Now I want all of VM instances to be avaialble with following softwares.

  1. Build manager
  2. VS studio build tools.
  3. Nant tool
  4. MS build
  5. VS build tools
  6. Nugget package restore.

I have VM scale set is ready now with load balancer, autoscaling, upgrade policy disabled.

I am not sure how to proceed from where to prepare VM with above softwares and use it in the all instances of VMSS.

I followed below document, but I am still not clear from where proceed once VMSS is ready.

https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/scale-set-agents?view=azure-devops#create-a-scale-set-with-custom-image-software-or-disk-size

Kindly suggest further.

Azure Virtual Machine Scale Sets
Azure Virtual Machine Scale Sets
Azure compute resources that are used to create and manage groups of heterogeneous load-balanced virtual machines.
348 questions
{count} votes

4 answers

Sort by: Most helpful
  1. Luke Murray 10,526 Reputation points MVP
    2023-07-30T07:54:25.39+00:00

    Hi, sns

    Your best bet is to use Azure Image Builder. Azure Image Builder will allow you to create a custom image, which is then stored in a Compute Gallery.

    With Azure Image Builder, you can create a golden image, then every month re-run the same creation process, to install the latest updates, and application changes.

    Then once you have the latest updates, you can roll out the virtual machine image across your scaleset.

    Azure Image Builder is commonly used for Azure Virtual Desktop images, but can be used for anything, including Windows Server builds.

    1 person found this answer helpful.

  2. Konstantinos Passadis 17,286 Reputation points MVP
    2023-07-29T16:19:57.53+00:00

    Hello @sns !

    There are approaches to apply in your situation , it really is your choice

    1.

    Use the Custom Script Extension

    https://medium.com/microsoftazure/vm-scale-set-with-a-local-azure-custom-script-pushed-via-terraform-c4196329657a

    2, Shared Image

    In this case , which i prefer

    Create a VM with all the required software installed. You can do this by creating a VM from a marketplace image and then installing the software using a custom script extension or manually.

    Generalize the VM using the "sysprep" command. This prepares the VM for use as a shared image by removing any unique system-specific information.

    Create an image from the generalized VM using the "az image create" command. This creates a copy of the VM as an image that can be used to create new VM instances.

    Create a VM scale set using the image you created in step 3. You can specify the image using the "imageReference" property in the VM scale set template or using the "az vmss create" command.

    When you create new VM instances using the shared image, they will already have the required software installed. This can save time and effort compared to installing the software using a custom script extension on each VM instance.

    https://learn.microsoft.com/en-us/azure/virtual-machine-scale-sets/tutorial-use-custom-image-cli


    I hope this helps!

    Kindly mark the answer as Accepted and Upvote in case it helped!

    Regards


  3. Konstantinos Passadis 17,286 Reputation points MVP
    2023-08-01T07:41:14.7566667+00:00

    Hello @sns !

    I would go from Azure Shared Images , sinc your are not On Premses

    https://learn.microsoft.com/en-us/azure/virtual-machines/create-gallery?tabs=portal%2Cportaldirect%2Ccli2

    An Azure Compute Gallery (formerly known as Shared Image Gallery) simplifies sharing resources, like images and application packages, across your organization.

    The Azure Compute Gallery lets you share custom VM images and application packages with others in your organization, within or across regions, within a tenant. Choose what you want to share, which regions you want to make them available in, and who you want to share them with. You can create multiple galleries so that you can logically group resources.

    The gallery is a top-level resource that can be shared in multiple ways:

    An image can be created from a VM and then used to create multiple VMs.

    For images stored in an Azure Compute Gallery (formerly known as Shared Image Gallery), you can use VMs that already have accounts created on them (specialized) or you can generalize the VM before creating the image to remove machine accounts and other machines specific information. To generalize a VM, see Generalized a VM. For more information, see Generalized and specialized images.

    I hope this helps!

    Kindly mark the answer as Accepted and Upvote in case it helped!

    Regards

    0 comments No comments

  4. Konstantinos Passadis 17,286 Reputation points MVP
    2023-09-06T10:31:24.1133333+00:00

    Hello @sns !

    1. RDP into VMSS Instances:
      • VM instances created in a VM Scale Set (VMSS) can be RDP'ed into just like a regular VM, provided they have a public IP and the Network Security Group (NSG) rules allow RDP access. By default, VMSS does not assign a public IP to individual instances.
        • One way to access a VMSS instance is to give it a public IP temporarily. Alternatively, you can set up a jump box (a VM with RDP access) in the same virtual network and use it to connect to the VMSS instances.
          • You can also create a Load Balancer with NAT Rules 2 different rules and assign the inbound ports , for example 23389 for the first instance and 33389 for the second instance.
    2. Updating the VMSS with New Software:
      • The typical approach for updating a VMSS with new software or changes is to capture a new image and then update the VMSS to use the new image. The process involves:
           1. Creating a VM with your desired configurations and software.
        
                 1. Generalize the VM.
        
                       1. Capture an image of the VM.
        
                             1. Update the VMSS to use the new image.
        
        • An in-place upgrade on the VMSS instances is not recommended because any changes will be lost when the instance is scaled in or out.
    3. Update the VMSS with a Custom Image:
      • The parameter you highlighted in the screenshot seems to refer to the ID of the image you want the VMSS to use.
        • If your image is in the shared image gallery, you'll find the ID for the image version in the properties of that version. This ID will look something like: /subscriptions/{subscription-id}/resourceGroups/{rg-name}/providers/Microsoft.Compute/galleries/{gallery-name}/images/{image-name}/versions/{version-number}
          • If you've captured a managed image (not in the shared image gallery), you can find its ID in the properties of the image in the Azure portal.
            • Once you have the image ID, you can update the VMSS model to use the new image. When you update the VMSS model, existing instances will not automatically be updated. For existing instances to pick up the changes, they need to be manually upgraded or re-imaged.

    I hope i helped

    Kindly set the answer that helped as Accepted !

    Regards

    0 comments No comments