Currently,I am having an application running with autoscaled Azure VM. So, suppose my current version of application, i.e. 1.0 is being served by 4 VM's as per the current load on application.
Now, if I have a patch update and release a new version of application,i.e 2.0, then how will this new version of application updated to the currently VM's running?
If load increases, and new VM gets started, they all will be having this new version of application 2.0, but the previously running 4 VM's, will they have this new version of application? And if yes, how?
You have to launch Azure VMSS from ARM Template having Custom Image as Source Image instead of Image from Marketplace. To update application on VMs, again create a Custom image of VM having updated application and then update this new VM in VMSS with Powershell. Azure VMSS then automatically update all VMs in Scale Set with updated Image. Below is the code for Updating existing VMSS with new Custom Image.
$rgname = "myrg"
$vmssname = "myvmss"
# get the VMSS model
$vmss = Get-AzureRmVmss -ResourceGroupName $rgname -VMScaleSetName $vmssname
# set the new version in the model data
$vmss.virtualMachineProfile.storageProfile.imageReference.id = $newImageReference
# update the virtual machine scale set model
Update-AzureRmVmss -ResourceGroupName $rgname -Name $vmssname -VirtualMachineScaleSet $vmss
# now start updating instances
Update-AzureRmVmssInstance -ResourceGroupName $rgname -VMScaleSetName $vmssname -InstanceId $instanceId
Related
We’re creating a VMSS and we use a custom DNS with extending AD from on-premises, but we are not sure how to register the VMs as the scale set scales out, in azure DNS we can create a private zone and use auto registration but not with our custom DNS.
• Considering that you have registered your custom DNS in Azure successfully, and now you want to replicate your on-premises infrastructure in Azure given the options of continuous availability and scalability, you are deploying VMSS (Virtual Machine Scale Set) for that purpose. Thus, to service your applications deployed on them and better security, I would suggest you deploy AADDS (Azure Active Directory Domain Services) in your tenant in Azure and synchronize the domain data from on-premises to the AADDS by extending it in here.
Hence, once the ADDS service and its roles are setup successfully using the custom DNS that you have setup in Azure, you should be able to Azure AD domain join the VMSS deployed. Thus, after domain joining the VMSS, its DNS records will be automatically managed by the AADDS role internally in your Azure AD tenant.
To enable domain joining for the VMSS successfully, you will have to add an extension like a normal VM through powershell as below. You will have to replace the ‘user, domain, ou path and password’ and it should work fine: -
$Settings = #{
"Name" = "yourdomain.onmicrosoft.com";
"User" = "DOMAIN\USERNAME";
"Restart" = "true";
"Options" = 3;
"OUPath" = "OU=TEST,OU=My Computers,DC=yourdomain,DC=onmicrosoft,DC=com"
}
$password = 'SomeReallyComplexPassword'
$ProtectedSettings = #{
"Password" = $password
}
$rgName = "yourgname"
$scaleSetName = "yourvmssname"
$vmss = Get-AzureRmVmss -ResourceGroupName $rgName -VMScaleSetName $scaleSetName
$vmss = Add-AzureRmVmssExtension -VirtualMachineScaleSet $vmss -Publisher "Microsoft.Compute" -Type "JsonADDomainExtension" -TypeHandlerVersion 1.3 -Name "vmssjoindomain" -Setting $Settings -ProtectedSetting $ProtectedSettings -AutoUpgradeMinorVersion $true
Update-AzureRmVmss -ResourceGroupName $rgName -Verbose -Name $scaleSetName -VirtualMachineScaleSet $vmss
After adding this extension, any existing servers deployed in the VMSS will have to upgrade their model to use this extension while the new ones will use it when they are deployed with it. You will need to execute the below powershell command to ensure that further extensions can be added to the VMSS: -
az vmss update-instances --resource-group yourrgname --name yourvmssname --instance-ids *
Thus, in this way, you can ensure that your VMs in the VMSS get registered with the custom DNS that you have setup in your Azure tenant.
Azure has a number of Powershell cmdlets to work with virtual machine scale sets, such as Get-AzureRmVmss. However, I haven't found anything that enables me to determine if a vm scale set is stopped or started. Does anyone know this is possible within Powershell? I suspect it has to be but I'm at a loss to find the support.
Use below PowerShell Cmdlet to get the Status of the Virtual Machine in the Virtual Machine Scale Set(VMSS)
(Get-AzureRmVmssVM -ResourceGroupName {ResourceGroup-Name} -VMScaleSetName {VMSS-Name} -InstanceView -InstanceId "{Instance-ID}").Statuses
Example: (Get-AzureRmVmssVM -ResourceGroupName vmss-rg -VMScaleSetName myvmss -InstanceView -InstanceId "1").Statuses
im currently looking to move our VM's into a Scale Set,
But i am facing an issue with updating the VM's.
I’ve got a base Image from which I spin up a ScaleSet having 5 instances. Now I have an application update that needs to be pushed to each of these 5 servers, what will be the most suitable and convenient process to achieve this.
I had done some research on this and one of the possible solutions was to ;
Create a New image with the updated application code
Run a Powershell script in templates which replaces the old Image with the newer image and update the Vm’s accordingly.
I am using asp.net for my application. So how do i go about updating each of the VM's in a scale set when ever there is an application update.
I was advised that we could use chef/puppet, but this will work out too expensive at $120 per node
Could someone please suggest a simpler solution. Any help is much appreciated
Use a script\dsc extension to push updates to your app. the process is straight forward and work exactly the same as single VM.
https://learn.microsoft.com/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-dsc
The scale set "rolling upgrade" feature (currently in preview: https://github.com/Azure/vm-scale-sets/tree/master/preview/upgrade) could probably help; with this feature you simply create your new image, then update the scale set model with the new image, then the scale set will roll out the new image in batches over your infrastructure.
Hope this helps!
Use powershell to deploy to the scaleset. Works like a charm for me :)
$customConfig = #{
"fileUris" = #("https://$storageAccountName.blob.core.windows.net/scripts/script.ps1");
"commandToExecute" = "PowerShell -ExecutionPolicy Unrestricted .\script.ps1";
};
$vmss = Get-AzureRmVmss -ResourceGroupName $resourceGroup -VMScaleSetName $vmssname
Add-AzureRmVmssExtension -VirtualMachineScaleSet $vmss -Publisher Microsoft.Compute -Type CustomScriptExtension -TypeHandlerVersion 1.8 -Name "runscript" -Setting $customConfig
# Send the new config to Azure
Update-AzureRmVmss -ResourceGroupName $resourceGroup -Name $vmssname -VirtualMachineScaleSet $vmss
To run Azure Service Fabric on a cluster I have a vmset. I know the password, but it has to be changed. For a VM I would normally use the "reset password" function on the azure portal, but the vmset does not allow this. Adjusting the password in the resource template is also not allowed.
How to change the password of VM's in a vmset?
Update: See the VMSS FAQ:
Change the virtual machine scale set model directly. Available with Compute API 2017-12-01 and later.
Update the admin credentials directly in the scale set model (for example using the Azure Resource Explorer, PowerShell or CLI). Once the scale set is updated, all new VMs have the new credentials. Existing VMs only have the new credentials if they are reimaged.
Alternatively (and for older API versions) you can apply the VM Access extension. The Set-AzureRmVmssOSProfile cmdlet is useful when you're creating a scale set imperatively with PowerShell, but can't be used to change non-modifiable properties of an existing scale set.
Here's an example of using the VM Access extension to modify a scale set:
# Login to your azure account
Login-AzureRmAccount
# Set the scale set and resource group
$vmssName = "myvmss"
$vmssResourceGroup = "myvmssrg"
# Set the username / password
$publicConfig = #{"UserName" = "newuser"}
$privateConfig = #{"Password" = "********"}
$extName = "VMAccessAgent"
$publisher = "Microsoft.Compute"
$vmss = Get-AzureRmVmss -ResourceGroupName $vmssResourceGroup -VMScaleSetName $vmssName
$vmss = Add-AzureRmVmssExtension -VirtualMachineScaleSet $vmss -Name $extName -Publisher $publisher -Setting $publicConfig -ProtectedSetting $privateConfig -Type $extName -TypeHandlerVersion "2.0" -AutoUpgradeMinorVersion $true
Update-AzureRmVmss -ResourceGroupName $vmssResourceGroup -Name $vmssName -VirtualMachineScaleSet $vmss
Looking at the Azure PowerShell commandlets, Set-AzureRmVmssOsProfile makes sense:
PS C:\>Set-AzureRmVmssOSProfile -VirtualMachineScaleSet "ContosoVMSS" -ComputerNamePrefix "Test" -AdminUsername $AdminUsername -AdminPassword $AdminPassword
This command sets operating system profile properties for the virtual machines that belong to the VMSS named ContosoVMSS. The command sets the computer name prefix for all the virtual machine instances in the VMSS to Test and supplies the administrator username and password.
I have been browsing web regarding Azure Scale Set service and I have been able to find a lot of resources connected to scaling and deploying of scale set, however I was not able to find any information regarding deployment and update of the solutions deployed to the machines within scale set. Please what is the best practise when I want to host e.g. a web solution within scale set? How should I perform deployment and updates?
Thank you in advance.
It will depend on how you configure the scale set to be a web solution to begin with...
For example, if you create the VMSS with a template and then configured the VMSS with a custom script extension, then you could run the template deployment again and update the script.
If you used DSC (windows vm) then you could just update the artifacts source and DSC will do the update while the VMs are running.
If you want to use PowerShell for deployment to the Scale Set.
$customConfig = #{
"fileUris" = #("https://$storageAccountName.blob.core.windows.net/scripts/script.ps1");
"commandToExecute" = "PowerShell -ExecutionPolicy Unrestricted .\script.ps1";
};
$vmss = Get-AzureRmVmss -ResourceGroupName $resourceGroup -VMScaleSetName $vmssname
Add-AzureRmVmssExtension -VirtualMachineScaleSet $vmss -Publisher Microsoft.Compute -Type CustomScriptExtension -TypeHandlerVersion 2.0 -Name "runscript" -Setting $customConfig
# Send the new config to Azure
Update-AzureRmVmss -ResourceGroupName $resourceGroup -Name "$vmssname" -VirtualMachineScaleSet $vmss