|
| 1 | +--- |
| 2 | +title: Azure PowerShell Samples - Create a complete virtual machine scale set | Microsoft Docs |
| 3 | +description: Azure PowerShell Samples |
| 4 | +services: virtual-machine-scale-sets |
| 5 | +documentationcenter: '' |
| 6 | +author: iainfoulds |
| 7 | +manager: jeconnoc |
| 8 | +editor: '' |
| 9 | +tags: azure-resource-manager |
| 10 | + |
| 11 | +ms.assetid: |
| 12 | +ms.service: virtual-machine-scale-sets |
| 13 | +ms.devlang: na |
| 14 | +ms.topic: sample |
| 15 | +ms.tgt_pltfrm: na |
| 16 | +ms.workload: na |
| 17 | +ms.date: 05/29/2018 |
| 18 | +ms.author: iainfou |
| 19 | +ms.custom: mvc |
| 20 | + |
| 21 | +--- |
| 22 | + |
| 23 | +# Create a complete virtual machine scale set with PowerShell |
| 24 | +This script creates a virtual machine scale set running Windows Server 2016. Individual resources are configured and created, rather than the using the [built-in resource creation options avaiable here in New-AzureRmVmss](powershell-sample-create-simple-scale-set.md). After running the script, you can access the VM instances through RDP. |
| 25 | + |
| 26 | +[!INCLUDE [sample-powershell-install](../../../includes/sample-powershell-install-no-ssh.md)] |
| 27 | + |
| 28 | +[!INCLUDE [quickstarts-free-trial-note](../../../includes/quickstarts-free-trial-note.md)] |
| 29 | + |
| 30 | +## Sample script |
| 31 | +[!code-powershell[main](../../../powershell_scripts/virtual-machine-scale-sets/complete-scale-set/complete-scale-set.ps1 "Create a complete virtual machine scale set")] |
| 32 | + |
| 33 | +## Clean up deployment |
| 34 | +Run the following command to remove the resource group, scale set, and all related resources. |
| 35 | + |
| 36 | +```powershell |
| 37 | +Remove-AzureRmResourceGroup -Name $resourceGroupName |
| 38 | +``` |
| 39 | + |
| 40 | +## Script explanation |
| 41 | +This script uses the following commands to create the deployment. Each item in the table links to command specific documentation. |
| 42 | + |
| 43 | +| Command | Notes | |
| 44 | +|---|---| |
| 45 | +| [New-AzureRmResourceGroup](/powershell/module/azurerm.resources/new-azurermresourcegroup) | Creates a resource group in which all resources are stored. | |
| 46 | +| [New-AzureRmVirtualNetworkSubnetConfig](/powershell/module/azurerm.network/new-azurermvirtualnetworksubnetconfig) | Creates a subnet configuration. This configuration is used with the virtual network creation process. | |
| 47 | +| [New-AzureRmVirtualNetwork](/powershell/module/azurerm.network/new-azurermvirtualnetwork) | Creates a virtual network. | |
| 48 | +| [New-AzureRmPublicIpAddress](/powershell/module/azurerm.network/new-azurermpublicipaddress) | Creates a public IP address. | |
| 49 | +| [New-AzureRmLoadBalancerFrontendIpConfig](/powershell/module/azurerm.network/new-azurermloadbalancerfrontendipconfig) | Creates a front-end IP configuration for a load balancer. | |
| 50 | +| [New-AzureRmLoadBalancerBackendAddressPoolConfig](/powershell/module/azurerm.network/new-azurermloadbalancerbackendaddresspoolconfig) | Creates a backend address pool configuration for a load balancer. | |
| 51 | +| [New-AzureRmLoadBalancerInboundNatRuleConfig](/powershell/module/azurerm.network/new-azurermloadbalancerinboundnatruleconfig) | Creates an inbound NAT rule configuration for a load balancer. | |
| 52 | +| [New-AzureRmLoadBalancer](/powershell/module/azurerm.network/new-azurermloadbalancer) | Creates a load balancer. | |
| 53 | +| [Add-AzureRmLoadBalancerProbeConfig](/powershell/module/azurerm.network/new-azurermloadbalancerprobeconfig) | Creates a probe configuration for a load balancer. | |
| 54 | +| [Add-AzureRmLoadBalancerRuleConfig](/powershell/module/azurerm.network/new-azurermloadbalancerruleconfig) | Creates a rule configuration for a load balancer. | |
| 55 | +| [Set-AzureRmLoadBalancer](/powershell/module/AzureRM.Network/Set-AzureRmLoadBalancer) | Update the load balancer with the provided information. | |
| 56 | +| [New-AzureRmVmssIpConfig](/powershell/module/AzureRM.Compute/New-AzureRmVmssIpConfig) | Create an IP configuration for the scale set VM instances. The VM instances are connected to the load balancer backend pool, NAT pool, and virtual network subnet. | |
| 57 | +| [New-AzureRmVmssConfig](/powershell/module/AzureRM.Compute/New-AzureRmVmssConfig) | Creates a scale set configuration. This configuration includes information such as number of VM instances to create, the VM SKU (size), and upgrade policy mode. The configuration is added to by additional cmdlets, and is used during scale set creation. | |
| 58 | +| [Set-AzureRmVmssStorageProfile](/powershell/module/AzureRM.Compute/Set-AzureRmVmssStorageProfile) | Define the image to be used for the VM instances, and add it to the scale set config. | |
| 59 | +| [Set-AzureRmVmssOsProfile](/powershell/module/AzureRM.Compute/Set-AzureRmVmssStorageProfile) Define the administrative username and password credentials, and VM naming prefix. Add these values to the scale set config. | |
| 60 | +| [Add-AzureRmVmssNetworkInterfaceConfiguration](/powershell/module/AzureRM.Compute/Add-AzureRmVmssNetworkInterfaceConfiguration) | Add a virtual network interface to the VM instances, based on the IP configuration. Add these values to the scale set config. | |
| 61 | +| [New-AzureRmVmss](/powershell/module/AzureRM.Compute/New-AzureRmVmss) | Create the scale set based on the information provided in the scale set configuration. | |
| 62 | +| [Remove-AzureRmResourceGroup](/powershell/module/azurerm.resources/remove-azurermresourcegroup) | Removes a resource group and all resources contained within. | |
| 63 | + |
| 64 | +## Next steps |
| 65 | +For more information on the Azure PowerShell module, see [Azure PowerShell documentation](/powershell/azure/overview). |
| 66 | + |
| 67 | +Additional virtual machine scale set PowerShell script samples can be found in the [Azure virtual machine scale set documentation](../powershell-samples.md). |
0 commit comments