How to create a Virtual Machine Scale Set with Visual Studio

This article shows you how to deploy an Azure Virtual Machine Scale Set using a Visual Studio Resource Group Deployment.

Azure Virtual Machine Scale Sets is an Azure Compute resource to deploy and manage a collection of similar virtual machines with auto-scale and load balancing. You can provision and deploy Virtual Machine Scale Sets using Azure Resource Manager Templates. Azure Resource Manager Templates can be deployed using Azure CLI, PowerShell, REST and also directly from Visual Studio. Visual Studio provides a set of example templates, which can be deployed as part of an Azure Resource Group Deployment project.

Azure Resource Group deployments are a way to group and publish a set of related Azure resources in a single deployment operation. You can learn more about them here: Creating and deploying Azure resource groups through Visual Studio.


To get started deploying Virtual Machine Scale Sets in Visual Studio, you need the following:

  • Visual Studio 2013 or later
  • Azure SDK 2.7, 2.8 or 2.9


These instructions assume you are using Visual Studio with Azure SDK 2.8.

Creating a Project

  1. Create a new project in Visual Studio by choosing File | New | Project.

    File New

  2. Under Visual C# | Cloud, choose Azure Resource Manager to create a project for deploying an Azure Resource Manager Template.

    Create Project

  3. From the list of Templates, select either the Linux or Windows Virtual Machine Scale Set Template.

    Select Template

  4. Once your project is created you see PowerShell deployment scripts, an Azure Resource Manager Template, and a parameter file for the Virtual Machine Scale Set.

    Solution Explorer

Customize your project

Now you can edit the Template to customize it for your application's needs, such as adding VM extension properties or editing load balancing rules. By default the Virtual Machine Scale Set Templates are configured to deploy the AzureDiagnostics extension, which makes it easy to add autoscale rules. It also deploys a load balancer with a public IP address, configured with inbound NAT rules.

The load balancer lets you connect to the VM instances with SSH (Linux) or RDP (Windows). The front-end port range starts at 50000. For linux this means that if you SSH to port 50000, you are routed to port 22 of the first VM in the Scale Set. Connecting to port 50001 is routed to port 22 of the second VM and so on.

A good way to edit your Templates with Visual Studio is to use the JSON Outline to organize the parameters, variables, and resources. With an understanding of the schema Visual Studio can point out errors in your Template before you deploy it.

JSON Explorer

Deploy the project

  1. Deploy the Azure Resource Manager Template to create the Virtual Machine Scale Set resource. Right-click on the project node and choose Deploy | New Deployment.

    Deploy Template

  2. Select your subscription in the “Deploy to Resource Group” dialog.

    Deploy Template

  3. From here, you can create an Azure Resource Group to deploy your Template to.

    New Resource Group

  4. Next, click Edit Parameters to enter parameters that are passed to your Template. Provide the username and password for the OS, which is required to create the deployment. If you don't have PowerShell Tools for Visual Studio installed, it is recommended to check Save passwords to avoid a hidden PowerShell command-line prompt, or use keyvault support.

    Edit Parameters

  5. Now click Deploy. The Output window shows the deployment progress. Note that the action is executing the Deploy-AzureResourceGroup.ps1 script.

    Output Window

Exploring your Virtual Machine Scale Set

Once the deployment completes, you can view the new Virtual Machine Scale Set in the Visual Studio Cloud Explorer (refresh the list). Cloud Explorer lets you manage Azure resources in Visual Studio while developing applications. You can also view your Virtual Machine Scale Set in the Azure portal and Azure Resource Explorer.

Cloud Explorer

The portal provides the best way to visually manage your Azure infrastructure with a web browser, while Azure Resource Explorer provides an easy way to explore and debug Azure resources, giving a window into the "instance view" and also showing PowerShell commands for the resources you are looking at.

Next steps

Once you’ve successfully deployed Virtual Machine Scale Sets through Visual Studio, you can further customize your project to suit your application requirements. For example, configure auto-scale by adding an Insights resource, adding infrastructure to your Template (like standalone VMs), or deploying applications using the custom script extension. Good example templates can be found in the Azure Quickstart Templates GitHub repository (search for "vmss").