Publishing a Windows Azure Application using the Windows Azure Tools
Using the Windows Azure Tools for Microsoft Visual Studio, you can publish your Windows Azure application to Windows Azure directly from Visual Studio.
Before you can publish a Windows Azure application, you must have a Windows Azure subscription. In addition, you must set up a hosted service and a storage account in the Windows Azure Platform Management Portal to be used by your application. This hosted service that you create is a container that is used to host your application by running the roles of your Windows Azure application on virtual machines. When you publish your application from Visual Studio, a service package is created and this package is used to deploy your application to this hosted service.
Important |
|---|
When you publish, you can select the Windows Azure environment for your hosted service. You must also select a storage account that is used to store the application package for deployment. After deployment, the application package is removed from the storage account. For more information about how to set up these services, see Setting Up Services Required to Publish a Windows Azure Application from Visual Studio. |
When you are developing and testing a Windows Azure application, you can use Web Deploy to publish changes incrementally for your web roles. After you publish your application to a deployment environment, Web Deploy lets you deploy changes directly to the virtual machine that is running the web role. You do not have to package and publish your entire Windows Azure application each time you want to update your web role to test out the changes. With this approach, you can have your web role changes available in the cloud for testing without waiting to have your application published to a deployment environment.
Important |
|---|
Web Deploy is not for use in a production environment. To enable Web Deploy, you must use the latest version of the Windows Azure Tools for Microsoft Visual Studio and the Windows Azure SDK. Download the latest version of the Windows Azure Tools and SDK. |
Use the following procedures to accomplish publishing tasks using Visual Studio tools for Windows Azure:
To publish your application directly to Windows Azure, you must provide Visual Studio with your subscription ID and a valid certificate. This is necessary so that Visual Studio can authenticate your credentials with Windows Azure when you publish your application. For more information about these credentials, see Setting Up Named Authentication Credentials.
The following illustration shows the key steps to publish your application to Windows Azure.
To publish a Windows Azure Application from Visual Studio
-
To publish your application, open the shortcut menu for the Windows Azure Project that contains your roles in Solution Explorer and choose Publish.
The Publish Windows Azure Application dialog box is displayed.
-
If you have not published this Windows Azure application before, you must choose the credentials that you want to use from Credentials or create credentials. If you have not created any credentials, use the following topic to create these credentials: Setting Up Named Authentication Credentials.
Note
After you have selected or created a set of credentials, the drop-down lists for the Windows Azure environment and the Publish storage account are populated based on the subscription ID used for these credentials.
-
After you have selected or created credentials, choose the environment to which you want to publish from Windows Azure environment. This is the environment that is used to host your Windows Azure application.
You can deploy to an environment that is currently used by another deployment or an environment that is empty.
-
Choose the storage account to use to upload the service package from the Publish storage account list box. The service package is uploaded to this account as part of the deployment process.
Note
This storage account does not have to be the storage account that you plan to use for the data for your application. This storage account is also used to store profiling, IntelliTrace and diagnostics data. You can change the storage account that you use for diagnostics data, but not for profiling and IntelliTrace data. For more information about how to change the diagnostics storage account, see Collect diagnostics.
Note
To set up the storage account to use for your data, you must update the connection strings in your service configurations. For more information about this, see To Configure Your Application to Use Services Provided by the Storage Account.
-
If you do not want to automatically overwrite an existing deployment when you publish a new build of your application, you must set the Prompt before deleting an existing deployment property to true. For more information about how to set this property, see How to: Configure a Windows Azure Project with Visual Studio.
-
A default name is created for your deployment. To change this name, you can type a new name or amend the default name in Publish Label. This name is used in the Management Portal.
-
To append the date and time to the label for the deployment, select the Append date and time check box.
-
To enable IntelliTrace for this deployment, select the Enable IntelliTrace for .NET 4 roles check box. IntelliTrace provides debugging information for your application that you can use to step through your code from Visual Studio Ultimate. For more information about IntelliTrace and the settings for IntelliTrace, see Debugging a Published Hosted Service with IntelliTrace and Visual Studio.
-
To enable profiling for this deployment to determine the performance of your Windows Azure application, select the Enable profiling check box. Profiling provides performance information for your application. For more information about how to configure the settings for profiling, see Profiling a Windows Azure Application.
Important
You can enable either IntelliTrace or profiling when you publish your Windows Azure application. You cannot enable both.
-
(Optional) If you are publishing from Visual Studio 2010 and you have installed the latest version of the Windows Azure tools, you can also enable Web Deploy for all your web roles. For the requirements and the detailed steps to do this, see the following section: Update a Web Role as Part of Your Development and Testing Cycle.
-
To configure remote desktop connections for this deployment environment so that you can connect to the virtual machine that is running each instance of a role, choose the Configure Remote Desktop connections hyperlink. For more information about how to configure this, see Using Remote Desktop with Windows Azure Roles.
-
To publish your Windows Azure application, choose the Publish button. Visual Studio starts the deployment process. You can see the progress of the deployment from the Windows Azure Activity Log window. This log is automatically displayed when the deployment process starts. You can expand the line item in the activity log to show detailed information, as shown in the following illustration:
-
(Optional) To cancel the deployment process, open the shortcut menu for the line item in the activity log and choose Cancel and remove. This stops the deployment process and deletes the deployment environment from Windows Azure.
Note
To remove this deployment environment after it has been deployed, you must use the Management Portal.
-
(Optional) After your role instances have started, Visual Studio automatically shows the deployment environment in the Windows Azure Compute node in Server Explorer. From here you can see the status of the individual role instances. For more information on the Windows Azure Compute node in Server Explorer, see Viewing the State of an Azure Application using Server Explorer.
The following illustration shows the role instances while they are still in the Initializing state:
-
To access your application after deployment, choose the arrow next to your deployment when a status of Completed is displayed in the Windows Azure Activity log. To start a browser with your application, choose the hyperlink that is displayed in the deployment details.
You can use this package and the service configuration file to publish your application to a deployment environment from the Management Portal. You can create a service package as shown in the following illustration:
To create a service package
-
To create a service package, open the shortcut menu for the Windows Azure Project that contains your roles in Solution Explorer and choose Package.
The Package Windows Azure Application dialog box is displayed.
-
In the Service configuration list, choose the service configuration that you want to use to create this package. For more information about service configurations, see Configuring a Windows Azure Application.
-
In the Build configuration list, choose the build configuration that you want to use to create this package.
-
If you need to configure remote desktop connections for the virtual machines that are created in Windows Azure with this package, choose the Configure Remote Desktop connections hyperlink. For more information about how to configure remote desktop connections, see Using Remote Desktop with Windows Azure Roles.
-
To create this package, choose the Package button.
A Windows Explorer window that shows the file location of the newly created package is displayed. You can copy this location so that you can use this location to deploy the application from the Windows Azure Platform Management Portal.
When you create a hosted service with the Management Portal, you can use this location as the Package location. For more information about how to do this, see How to Create a Hosted Service.
Caution
|
|---|
|
Web Deploy is not for use in a production environment with Windows Azure. To enable Web Deploy, you must use the latest version of the Windows Azure Tools for Microsoft Visual Studio and the Windows Azure SDK. Download the latest version of the Windows Azure Tools and SDK. |
These are the requirements to use Web Deploy to update your web role:
-
For development and testing purposes only: The changes are made directly to the virtual machine where the web role is running. If this virtual machine has to be recycled, the changes are lost because the original package that you published is used to recreate the virtual machine for the role. You must republish your application to get the latest changes for the web role.
-
Only web roles can be updated: Worker roles cannot be updated. In addition, you cannot update the RoleEntryPoint in WebRole.cs.
-
Can only support a single instance of a web role: You cannot have multiple instances of any web role in your deployment environment. However, multiple web roles each with only one instance are supported.
-
You must enable remote desktop connections: This is required so that Web Deploy can use the user and password to connect to the virtual machine to deploy the changes to the IIS server. In addition, you might need to connect to the virtual machine to add a trusted certificate to IIS on this virtual machine. (This enables the remote connection for IIS that is used by Web Deploy to be secure.)
The following procedure assumes that the Deploy Windows Azure Project dialog box to publish a Windows Azure application is displayed.
To Enable Web Deploy When You Publish Your Application
-
To enable the Enable Web Deploy for all Web Roles check box, you must first configure remote desktop connections. To do this, choose the Configure Remote Desktop connections hyperlink. For information about how to configure remote desktop connections, see Using Remote Desktop with Windows Azure Roles.
Important
To configure remote desktop connections, you must upload the certificate that you use for remote desktop to the Management Portal before you can connect to the virtual machines.
-
To enable Web Deploy for all the web roles in your application, select Enable Web Deploy for all Web Roles.
A yellow warning triangle is displayed. Web Deploy uses an untrusted, self-signed certificate by default, which is not recommended for uploading sensitive data. If you need to secure this process for sensitive data, you can add a SSL certificate to be used for Web Deploy connections. This certificate needs to be a trusted certificate. For information about how to do this, see: To Make Web Deploy Secure
-
Choose the Publish button to publish.
The Windows Azure application is published. The virtual machine that is created has remote connections enabled for IIS so that Web Deploy can be used to update your web roles without republishing.
Note
If you have more than one instance configured for a web role, a warning message is displayed that each web role will be limited to one instance only in the package that is created to publish your application. Choose the OK button to continue.
To Update Your Web Role by Using Web Deploy
-
To use Web Deploy, you must make code changes to the project for any of your web roles in Visual Studio that you want to publish. Open the shortcut menu for the project node for this web project, and then choose Publish.
Caution
Make sure that you open the shortcut menu for a web project in your solution and not the Windows Azure project.
The Publish Web dialog box is displayed.
-
(Optional) If you added a trusted SSL certificate to use for remote connections for IIS, you can clear Allow untrusted certificate. For information about how to add a certificate to make Web Deploy secure, see To Make Web Deploy Secure.
-
To use Web Deploy, the publish mechanism needs the user name and password that you set up for your remote desktop connection when you first published the package.
-
In User name type the user name.
-
In Password type the password.
-
(Optional) If you want to save this password in this profile, select Save password.
-
-
To publish out the changes to your web role, choose Publish.
The status line displays Publish started. When the publishing has completed, Publish succeeded is displayed. The changes have now been deployed to the web role on your virtual machine. Now you can start your Windows Azure application to test out your changes in the Windows Azure environment.
To Make Web Deploy Secure
-
Web Deploy uses an untrusted, self-signed certificate by default, which is not recommended for uploading sensitive data. If you need to secure this process for sensitive data, you can add a SSL certificate to be used for Web Deploy connections. This certificate needs to be a trusted certificate.
To make Web Deploy secure for each virtual machine for each of your web roles, you must upload the trusted certificate that you want to use for web deploy to the Management Portal. This makes sure that the certificate is added to the virtual machine that is created for the web role when you publish your application.
-
To add a trusted SSL certificate to IIS to use for remote connections, follow these steps:
-
To connect to the virtual machine that is running the web role, from the Management Portal, select the instance of the web role and choose Connect. For the detailed steps about how to connect to the virtual machine, see Using Remote Desktop with Windows Azure Roles.
Your browser will prompt you to download an .RDP file.
-
Open the .RDP file and enter the user and password that you set up when you configured your remote desktop connection.
-
To add a SSL certificate, open the management service in IIS manager. Then in the Connections group box select an SSL certificate from SSL certificate. For more detailed steps about how to do this, see Configure Connection Settings for the Management Service.
-
You might need to include specific files in your service package so that they are available on the virtual machine that is created for a role. For example, you might want to add an .exe or an .msi file that is used by a startup script to your service package. Or you might need to add an assembly that a web role or worker role project requires. To include files they must be added to the solution for your Windows Azure application.
To include files in the service package
-
To add an assembly to a service package, use the following steps:
-
In Solution Explorer open the project node for the project that is missing the referenced assembly.
-
To add the assembly to the project, open the shortcut menu for the References folder and then choose Add Reference.
The Add Reference dialog is displayed.
-
Choose the reference that you want to add and then choose the OK button.
The reference is added to the list under the References folder.
-
Open the shortcut menu for the assembly that you added and choose Properties.
The Properties window is displayed.
-
To include this assembly in the service package, in the Copy Local list choose True.
-
-
To include files in the service package that have been added to your web role project, open the shortcut menu for the file, and then choose Properties. From the Properties window, choose Content from the Build Action list box.
-
To include files in the service package that have been added to your worker role project, open the shortcut menu for the file, and then choose Properties. From the Properties window, choose Copy if newer from the Copy to output directory list box.
