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
Related
Few days ago I moved my service from Azure Cloud Services classic to Cloud Services extended support. The latest doesn't have Production/Staging slots. There is a new swap mechanism that is activated if during a deploy we configured the "swappable cloud service". I can do it using Visual Studio publish magic and it works fine.
Now I want to make a deploy using powershell script. The code below just creates a new deploy without activated swap. It works fine.
New-AzCloudService -Name $stagingName `
-ResourceGroupName $resourceGroupName `
-Location $location `
-ConfigurationFile $cscfgFilePath `
-DefinitionFile $csdefFilePath `
-PackageFile $cspkgFilePath `
-StorageAccount $storageAccount `
-KeyVaultName $keyVaultName
I didn't find any samples or clues of how to add the "swappable cloud service" to the New-AzCloudService. I figured out there is such settings in
NetworkProfile.SwappableCloudService.Id but I can't understand how to set it up properly. For example, if I add:
$production= Get-AzCloudService -ResourceGroup $resourceGroupName -CloudServiceName $productionName
$production.NetworkProfile.SwappableCloudService.Id = $production.Name # just to reuse the object
$loadBalancerConfig = CreateLoadBalancerConfig
$networkProfile = #{loadBalancerConfiguration = $loadBalancerConfig; swappableCloudService = $production.NetworkProfile.SwappableCloudService }
New-AzCloudService -Name $stagingName `
...
-NetworkProfile $networkProfile `
I got the error:
New-AzCloudService : Parameter set cannot be resolved using the specified named parameters
Is it possible to set the "swappable cloud service" for New-AzCloudService? How to do it?
Is it possible to set the "swappable cloud service" after the deploy (in any way, Azure portal, API, powershell, etc.)?
I suspect the issue relates to the -NetworkProfile not being supported when -ConfigurationFile, -DefinitionFile, and -PackageFile are used.
In the documentation, -NetworkProfile is used with -PackageUrl and -Configuration instead.
I've asked Microsoft about this as I am having the same issue.
Try $production.Id instead of $production.Name. Or $production.id (I am not sure if the case is important).
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
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 developing deployment scripts to create and automate Azure Web Apps and those are working well.
Today I am trying to move these into an App Service Environment in preparation for production.
I find out that the command used for creating Web Apps doesn't work with an ASE.
New-AzureRmWebApp -ResourceGroupName $ResourceGroupName -Name $SiteName -Location $location -AppServicePlan $AppServicePlan
New-AzureRmWebApp : Server farm with name ASE01 not found.
However when I view in Azure Resource Explorer I can see that the 'Server Farm' is there, along with the normal Web App Service Plans.
Microsoft.Web/serverfarms/ASE01
It's extremely frustrating to spend weeks developing scripts to automate stuff and then find that the App Service Plan simply does not interface with these scripts.
Anyone have any ideas on how I can move forward?
James,
To create WebApps in ASE you need to use the following command
New-AzureRmWebApp -ResourceGroupName WebAppResourceGroup -Name webappname -Location "North Central US" -AppServicePlan WebApp-AppServicePlan -ASEName ASEName -ASEResourceGroupName ASEResourceGroupName
Note that the location parameter is required though not used - just need to be a valid Azure location.