The previous article describes how to create a standard mirrored VMSS cluster with PowerShell. Http://www.cnblogs.com/hengwei/p/7391178.html
This article describes how to create a custom mirrored VMSS cluster with PowerShell.
1 Create VMS, personalize them, such as install httpd, add date disk, etc., and capture this VM as an image
2 Create a VMSS cluster with this image
Create and capture an image
This operation is also described in the previous article:
Http://www.cnblogs.com/hengwei/p/7348453.html
Implemented with the Azure CLI tools.
The customized work includes:
1 Installed the httpd
2 configured Fstab auto mount/DEV/SDC1 to/var/www/html
3 Creating a index.html file in/var/www/html
4 shutting down firewalls and SELinux
The principle is the same, there is not much to introduce. Just introduce the relevant commands for PowerShell to capture the image:
Set-azurermvm-resourcegroupname hwvmssp-name hwimage-generalized-Verbose$vm$VM = Get-azurermvm-resourcegroupname HWVMSSP-Name hwimage$image$vm. Idnew$image
or capture directly on the Portal:
II Create a custom mirrored VMSS cluster
In the previous article, we created the corresponding vnet, SLB, and we also used the original network resources. To create a specific method, you can refer to:
Http://www.cnblogs.com/hengwei
The specific script is as follows:
$loc=' Chinanorth ';$rgname=' HWVMSSP ';$vnet= Get-azurermvirtualnetwork-name$rgname-resourcegroupname$rgname;$subnetName=' Vlan1 '$subnetId=$vnet. Subnets[0]. Id;$pubip= Get-azurermpublicipaddress-name (' Pubip ' +$rgname)-resourcegroupname$rgname;$lbName= ' VMSSLB ' +$rgname$actualLb= Get-azurermloadbalancer-name$lbName-resourcegroupname$rgname$vmssName=$rgname;$adminUsername=' Hengwei ';$adminPassword="xxxx";$vmNamePrefix=' Centosvmss '$IPCFG= New-azurermvmssipconfig-Name ' Nic '-loadbalancerinboundnatpoolsid$actualLb. Inboundnatpools[0]. Id '-loadbalancerbackendaddresspoolsid$actualLb. Backendaddresspools[0]. Id '-subnetid$subnetId;$numberofnodes= 2$image= Get-azurermimage-resourcegroupname HWVMSSP-ImageName vmssimage$vmss= New-azurermvmssconfig-location$loc-skucapacity$numberofnodes`
-skuname ' Standard_d1 '-upgradepolicymode ' Automatic '
| Add-azurermvmssnetworkinterfaceconfiguration-name$subnetName`
-primary$true-ipconfiguration$IPCFG `
| Set-azurermvmssosprofile-computernameprefix$vmNamePrefix`
-adminusername$adminUsername-adminpassword$adminPassword `
| Set-azurermvmssstorageprofile-osdiskcreateoption ' FromImage '
-osdiskcaching ' None '-osdiskostype Linux
-manageddisk Standardlrs-imagereferenceid$image. Id New-azurermvmss-resourcegroupname$rgname-name$vmssName·
-virtualmachinescaleset$vmss
Once created, sign in to instance, and you can see that the client work done in the previous image is also in:
Web pages can also be opened:
Summarize:
Creating a VMSS with a custom image makes it very easy to customize.
Azure VMSS----PowerShell Create a custom mirrored VMSS cluster