Objective : deploy Azure virtual machine scale set across availability zones by using the Azure portal.
1. Create VM Scale Set
Accept Default Values in Disk
Networking - Create a Vnet
Scaling -Set instance count and policy
Management - Ensure boot diagonistics is enable
Management - Create new diagnostics storage account
Health- Accept Default Values
2. Configure Azure virtual machine scale sets by using virtual machine extensions
Objective: Install Windows Server Web Server role on the instances of the Azure virtual machine scale set you deployed in the previous task by using the Custom Script virtual machine extension.
Storage account- add a new container
Validation
In the Azure portal, search for and select Load balancers and, in the list of load balancers, click az10408vmss0lb.
On the az10408vmss0lb blade, note the value of the Public IP address assigned to the frontend of the load balancer, open an new browser tab, and navigate to that IP address.
3. Scale compute and storage for Azure virtual machine scale sets
Change the size of virtual machine scale set instances, configure their autoscaling settings, and attach disks to them.
Upgrade the instances as oer the VM Scaleset
Scaling the VM Scale Set : -Custom autoscale and Scale based on a metric
Add the Rule for auto scaling
Setting | Value |
---|---|
Metric source | Current resource (az10480vmss0) |
Time aggregation | Average |
Metric namespace | Virtual Machine Host |
Metric name | Network In Total |
Operator | Greater than |
Metric threshold to trigger scale action | 10 |
Duration (in minutes) | 1 |
Time grain statistic | Average |
Operation | Increase count by |
Instance count | 1 |
Cool down (minutes) | 5 |
Validation of auto scaling
$rgName = 'az104-08-rg02' $lbpipName = 'az10408vmss0-ip' $pip = (Get-AzPublicIpAddress -ResourceGroupName $rgName -Name $lbpipName).IpAddress
while ($true) { Invoke-WebRequest -Uri "http://$pip" }
Click refresh in the list of instances after few minutes and we can see maximum 3 instances
Save the change, in the Settings section of the az10408vmss0 blade, click Instances, select the checkboxes next to the two instances of the virtual machine scale set, click Upgrade, and then, when prompted for confirmation, click Yes.
The disk attached in the previous step is a raw disks. Before it can be used, it is necessary to create a partition, create a filesystem, and mount it. To accomplish this, you will use Azure virtual machine Custom Script extension. First, you will need to remove the existing Custom Script Extension.
Uninstall the custom script extensions
In the azure power shell, click the Upload/Download files icon, in the drop-down menu, click Upload and upload the file \Allfiles\Labs\08\az104-08-configure_VMSS_disks.ps1 into the Cloud Shell home directory.
The content is as below
$rgName = 'az104-08-rg02'
$vmssName = 'az10408vmss0'
$vmss = Get-AzVmss `
-ResourceGroupName $rgName `
-VMScaleSetName $vmssName
$publicSettings = @{
"fileUris" = (,"https://raw.githubusercontent.com/Azure-Samples/compute-automation-configurations/master/prepare_vm_disks.ps1");
"commandToExecute" = "powershell -ExecutionPolicy Unrestricted -File prepare_vm_disks.ps1"
}
Add-AzVmssExtension -VirtualMachineScaleSet $vmss `
-Name "customScript" `
-Publisher "Microsoft.Compute" `
-Type "CustomScriptExtension" `
-TypeHandlerVersion 1.8 `
-Setting $publicSettings
# Update the scale set and apply the Custom Script Extension to the VM instances
Update-AzVmss `
-ResourceGroupName $rgName `
-Name $vmssName `
-VirtualMachineScaleSet $vmss
In the Settings section of the az10408vmss0 blade, click Instances, select the checkboxes next to the two instances of the virtual machine scale set, click Upgrade, and then, when prompted for confirmation, click Yes.Set-Location -Path $HOME Get-Content -Path ./az104-08-configure_VMSS_disks.ps1./az104-08-configure_VMSS_disks.ps1
Delete all resources
Get-AzResourceGroup -Name 'az104-08*' | Remove-AzResourceGroup -Force -AsJob
No comments:
Post a Comment