Creating a virtual machine for a website with Visual Studio
When you create a web project for an Azure website, you can provision a virtual machine in Azure. You can then configure the virtual machine with additional software, or use the virtual machine for diagnostic or debugging purposes.
To create a virtual machine when you create a website, follow these steps:
- In Visual Studio, choose File, New Project, choose Web, and then choose ASP.NET Web Application.
In the New ASP.NET Project dialog box, select the type of web application you want, and in the Azure section of the dialog box (in the lower-right corner), make sure that the Host in the cloud check box is selected (this check box is labeled Create remote resources in some installations).
Choose Virtual Machine, and then choose the OK button.
If prompted, sign in to Azure. The Create Virtual Machine dialog box appears.
In the DNS name box, type a name for the virtual machine. The DNS name must be unique in Azure. If the name you entered isn't available, a red exclamation point appears.
In the Image list, choose the operating system image you want on the virtual machine. You can choose any of the standard images or your own image that you've uploaded to Azure.
Leave the Enable IIS and Web Deploy check box selected unless you plan to install a different web server. You won't be able to publish from Visual Studio if you disable Web Deploy. You can add IIS and Web Deploy to any of the packaged Windows Server images, including your own custom images.
In the Size list, choose the size of the virtual machine.
Specify the login credentials for this virtual machine. Make a note of them, because you'll need them to access the machine through Remote Desktop.
In the Location list, choose the region, virtual network, or affinity group that will host the virtual machine. You can use affinity groups to make sure that Azure resources that have a lot of network traffic between them stay together in the same datacenter, or you can use regions to specify the exact datacenter location.
Choose OK to start the process of creating the virtual machine. You can follow progress in the **Output ** window.
When the virtual machine is provisioned, publish scripts are created in a PublishScripts node in your solution. The publish script runs and provisions a virtual machine in Azure. The Output window shows the status. The script performs the following actions to set up the virtual machine:
- Creates the virtual machine if it doesn't already exist.
- Creates a storage account with a name that begins with
devtest, but only if there isn't already such a storage account in the specified region.
- Creates a cloud service as a container for the virtual machine, and creates a web role for the website.
- Configures Web Deploy on the virtual machine.
- Configures IIS and ASP.NET on the virtual machine.
13. (Optional) In Server Explorer, expand the Virtual Machines node, choose the node for the virtual machine you created, and then choose Connect with Remote Desktop to connect to the virtual machine.
If you want to customize the publish scripts you created, see more in-depth information here.