Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
IMG
 
 
 
 

Deploy Virtual Machine Scale Set using custom Windows Server images with Managed Disks

This guide will help you to deploy the VMSS using a customized image (based on Windows Server). Also this document use Managed Disks.

If you want to deploy Virtual Machine Scale Set using Linux with Managed Disks just follow the blog from (Vincent-Philippe Lauzon) .Most part of these templates and procedures described here came from his blog. Thanks Vincent!

Also I would like to thanks (Marcelo Matias) for the collaboration and the review of my scripts. Yes, Matias is "the guy" of Azure and my scripts are not so "elegant". Thanks Matias!

Requirements

Deploy the base image

Click the button bellow to deploy the first template

If you want to manually deploy this template just follow the procedures bellow

  • Open the (Azure Portal)
  • Click New and select Template Deployment
  • Select Template Deployment and click Create

template deployment1 template deployment2

  • Copy the entire content of the template 201-vmss-win-managed.json and click SAVE

template deployment3

  • Fill the form and then click PURCHASE. The deployment will start and you just need to wait few minutes.
  • After the deployment finish then connect via RDP and start to customize your application

Important Notes

  • This template deploy 1 virtual machine with a data disk (32GB). If you want to use this disk then you need to configure this disk first (this template will not format and mount this volume - you need to do this manually). If you not mount and format this volume the script will not join this disk as part of the image.

Customize your image

  • Prepare your image to be generalized with Sysprep. Remember that this virtual machine will not be available after the process bellow.
  • Open the directory bellow and execute Sysprep.exe
c:\windows\system32\sysprep\sysprep.etc
    Select the following options:
  1. Enter System Out-of-Box Experience (OOBE)
  2. Generalize
  3. Shutdown

image template4

Important Notes

Clone and create the image

After the execution of Sysprep just wait few minutes and then open PowerShell (Run as Administrator)

Important Notes

Execute the following commands to prepare your image:

  • Declare the variables
$vmName = "Demo-VM" 
$rgName = "HaraRG26" 
$location = "WestUS" 
$imageName = "myImage"

  • Ensure the VM is already stopped
Stop-AzureRmVM -ResourceGroupName $rgName -Name $vmName -Force
  • Generalize the VM
Set-AzureRmVm -ResourceGroupName $rgName -Name $vmName -Generalized
  • Declare more variables
$vm = Get-AzureRmVM -Name $vmName -ResourceGroupName $rgName

$image = New-AzureRmImageConfig -Location $location -SourceVirtualMachineId $vm.ID
  • Create the image
New-AzureRmImage -Image $image -ImageName $imageName -ResourceGroupName $rgName
  • Capture the Image ID
(Get-AzureRmImage -ResourceGroupName $rgName -ImageName $imageName).Id
  • The command will generate something like this:
/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/xxxxx/providers/Microsoft.Compute/images/xxxxx

Use this information to fill the field "Image ID" on the second template (202-vmss-win-managed.json) - instructions bellow

Important Notes

This process allow to use the Image on another Resource Group (but must be on the same region)

Remove unnecessary itens

In order to install a Scale Set in the same availability set, we need to remove the VM and other unnecessary objects.

Open PowerShell (run as Administrator) and execute these commands:

Remove-AzureRmVM -ResourceGroupName $rgName -Name $vm.Name -Force
Remove-AzureRmNetworkInterface -ResourceGroupName $rgName -Name frontNic -Force
Remove-AzureRmAvailabilitySet -ResourceGroupName $rgName -Name frontAvailSet -Force

Optionally you can remove the disks

Remove-AzureRmDisk -ResourceGroupName $rgName -DiskName Demo-VM -Force
Remove-AzureRmDisk -ResourceGroupName $rgName -DiskName Demo-VM-data -Force
Remove-AzureRmLoadBalancer -ResourceGroupName $rgName -Name PublicLB -Force

Now you are ready to deploy the VMSS using this image. Also you can use this image to deploy a single VM.

Deploy the Virtual Machine Scale Set

Click the button bellow to deploy the second template

If you want to manually deploy this template just follow the procedures bellow

  • Open the (Azure Portal)
  • Click New and select Template Deployment
  • Select Template Deployment and click Create

template deployment1 template deployment2

  • Copy the entire content of the template 202-vmss-win-managed.json and click SAVE

  • Fill the form and then click PURCHASE. The deployment will start and you just need to wait few minutes.

After the deploy finish the execution process you can access your Resource Group and check all objects created

About

Using Vitrual Machine Scale Set using custom Windows Server images with Managed Disks

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published