Getting Started with the Azure Tools for Visual Studio

Getting Started with the Azure Tools for Visual Studio

Updated: May 12, 2015

By following this walkthrough, you’ll learn how to use the Microsoft Azure Tools for Visual Studio to develop an Azure cloud service. The Azure Tools for Visual Studio help you to be more productive when you develop Azure projects such as Azure cloud and mobile services and ASP.NET web applications. You can use the tools to run and debug projects locally before you publish them to Azure. You’ll use the following procedures to develop the Azure cloud service.

The Azure tools work with several versions of Visual Studio. This walkthrough shows UI from one version of Visual Studio. You might find that the UI differs slightly from illustrations in this topic, depending on your versions of Visual Studio and the Azure tools.

If you haven’t already installed the Azure tools, this procedure will help you do so. If you've already installed the Azure tools, you can go to the next procedure.

  1. To install the Azure tools, on the menu bar, choose File, New, Project. From Installed Templates choose either the Visual Basic or Visual C# node, and then choose the Cloud node that contains a project template named Get Microsoft Azure SDK for .NET.

    This template only appears if you haven’t installed the Azure Tools.

  2. To download the tools, choose the OK button.

    An Azure Tools tab appears.

  3. To start the download, choose the Download Azure Tools button to open the web installer. Follow the instructions provided by the web installer to install the latest version of the Azure tools and the Azure SDK.

    Azure Tools requires Internet Information Services (IIS) version 7, 7.5, 8, or Express. To install IIS or IIS Express, use the Microsoft Web Platform Installer.

You might have to restart Visual Studio before the Azure project templates appear.

An Azure cloud service consists of roles that perform the actions required by the application. When you publish the cloud service to Azure, each role runs on a virtual machine in the cloud. For more information about how to develop an Azure cloud service, see Planning and Designing Applications for Azure.

  1. Start Visual Studio as an administrator.

  2. On the menu bar, choose File, New, Project.

  3. In the Visual C# and Visual Basic project templates that are displayed in Installed Templates, choose the Cloud template type that was updated. Choose Azure Cloud Service. In the .NET Framework list, choose the target framework that you want to use.

    Create a new project
    Visual Studio 2012 and Visual Studio 2013 support both the .NET Framework 4.5 and the .NET Framework 4.

  4. In the Name text box, enter the name for your project and choose the OK button.

    The New Project dialog box appears.

    Create a new Windows Azure project.
  5. To add a web role to the solution, choose ASP.NET Web Role and then choose the right arrow (>) in the middle of the dialog. You can add multiple web and worker roles to your Azure solution.

    The roles appear in the Azure solution pane of the dialog box.

  6. To rename WebRole1 to MyWebRole, move the pointer over WebRole1and choose the pencil icon on the right side. Type the new name and then choose the Enter button. (Keyboard: Tab to move the focus to WebRole1 and press F2 to edit.)

  7. Choose the OK button. The New ASP.NET Project dialog appears. Choose Web Forms.

    Choose Web Forms.
  8. To create the new Azure project, choose the OK button.

    You now have a solution with the following two projects:

    • An Azure cloud service project

    • A web role project that is an ASP.NET web application

    The Solution Explorer view should look similar to the following illustration.


In the following procedure, you add code to the web role project. This web project adds data to blob storage and writes a diagnostics message to help you debug an application. You can then run this code locally to test it before you publish it to Azure.

  1. To open default.aspx in design view, open the shortcut menu for the default.aspx file and then choose View Designer.

  2. To open the toolbox, choose the Toolbox icon. To add a button to the page, open the shortcut menu for Button in the Toolbox view and choose Copy. In the editor window for Default.aspx choose Design, then open the shortcut menu and choose Paste. To add a click event handler for the button, double-click the new button that you added to the page.

  3. In the click event handler named Button1_Click, add code that will upload some text to the blob service and add a diagnostics message. To add the required Azure types, add the following using statements to default.aspx.cs.

    using Microsoft.WindowsAzure;
    using Microsoft.WindowsAzure.Storage;
    using Microsoft.WindowsAzure.ServiceRuntime;
  4. Add the following code to accomplish these tasks.

    • Create a CloudStorageAccount instance from a connection string in the configuration settings

    • Create a blob container

    • Upload a text blob to that container

    • Add a diagnostics message for a web role

    protected void Button1_Click(object sender, EventArgs e)
        // Setup the connection to Azure Storage
        var storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("MyConnectionString"));
        var blobClient = storageAccount.CreateCloudBlobClient();
        // Get and create the container
        var blobContainer = blobClient.GetContainerReference("quicklap");
        // upload a text blob
        var blob = blobContainer.GetBlockBlobReference(Guid.NewGuid().ToString());
        byte[] data = new byte[] { 0, 1, 2, 3, 4, 5 };
        blob.UploadFromByteArray(data, 0, data.Length);
        // log a message that can be viewed in the diagnostics tables called WADLogsTable
        System.Diagnostics.Trace.WriteLine("Added blob to Azure Storage");

  5. To add a breakpoint to the line of code you just added in the Button1_Click event handler, open the shortcut menu for the line of code blob.UploadFromByteArray(data, 0, data.Length); and then choose Breakpoint, Insert Breakpoint (Keyboard: F9).

  6. In WebRole.cs, add the following code to the beginning of the OnStart() method.

    public override bool OnStart()
            // For information on handling configuration changes
            // see the MSDN topic at
            //Get the configuration object
            DiagnosticMonitorConfiguration diagObj = DiagnosticMonitor.GetDefaultInitialConfiguration();
            //Set the service to transfer logs every second to the storage account
            diagObj.Logs.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);
            //Start Diagnostics Monitor with the new storage account configuration
            DiagnosticMonitor.Start("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString", diagObj);
            return base.OnStart();

    This code causes the diagnostics monitor to transfer the logs every second and start the monitor. The diagnostics monitor uses a connection string that is added when you create the Azure project.

As part of the role templates, an Azure trace listener is added to the web.config. The trace listener will route trace and debug messages to the Azure Diagnostics system.

You can build your application and then you can run and debug this application locally using the compute and storage emulators that are provided as part of the Azure tools. This allows you to develop your application locally before you publish it to Azure. You can view the data that you add to storage and any diagnostics messages using the emulators.

  1. To build the project, open the shortcut menu for the Azure project and then choose Build.

  2. To see the build output, open the shortcut menu for the Azure project and then choose Open Folder in File Explorer. Go to the bin\Debug directory to view the build output.


  1. To change settings for the role, choose a role under the Roles node for your cloud service project (not the role node) in Solution Explorer, open the shortcut menu for the role and then choose Properties.

    This shows the property pages for the web role. Every role-level element and attribute in the service definition and service configuration files can be edited using the property pages.

    Web role properties
    If you want to run your Azure cloud service locally to debug it and you also want to publish it to Azure, this typically requires different values for the settings for your roles. For example, you might want to run four instances of a role in Azure, but only one instance when you debug it in your local environment. You can now save different service configurations in your cloud service project that enable you to define these different values. You can then choose the one you want to use. See Configuring an Azure Project for more information.

  2. To change all of the service configurations at once, in the Service Configuration list choose All Configurations.

  3. To change the instance count, in the Instance count text box type 2.

    When you do this, you’ll get a warning that you need to switch from using the express emulator to the full emulator. Ignore this warning for now. This is done later in this procedure.

  4. To configure Visual Studio to use the local storage emulator when you run or debug your Azure cloud service, you have to add the connection string that you used in the button’s click event handler. Use the following steps to do this.

    1. On the Settings tab choose the Add Setting button.

    2. In the Name text box, type MyConnectionString.

    3. In the Type combo box, choose Connection String.

    4. Choose the ellipsis (..) in the Value text box. The Create Storage Connection String dialog box appears. Choose the Microsoft Azure storage emulator option and then choose OK.

      Azure storage account connection string
  5. At the end of this walkthrough when you’re ready to publish your cloud service to Azure, you can use this Settings tab to change the value for this connection string for the Cloud service configuration (called ServiceConfiguration.Cloud.cscfg) to use your actual Azure storage account, rather than the local storage emulator. You can then use this service configuration when you publish the Azure cloud service.

  6. To debug multiple instances of the role (since you specified two instances earlier), you need to switch the Azure cloud project from using Emulator Express to the Full Emulator. On the shortcut menu of the Azure cloud service, choose Properties.

  7. Choose the Web tab, and then select the Use Full Emulator option.

    Azure full emulator option
  8. On the toolbar, choose the Save icon.

  1. On the menu bar, choose Debug, Start Debugging (Keyboard: F5).

    If the Azure cloud service project is not set as the startup project, the following error occurs when you click the button to trigger the breakpoint: External component has thrown an exception. The reason that the error occurs is because the development fabric must be initialized in order to invoke the Azure API calls. To set the cloud service project as the startup project, open the shortcut menu for your cloud service project and choose Set as Startup Project.

    The storage emulator and the compute emulator for Visual Studio are started. These emulators let you run and debug your cloud service locally on your system before you publish it to Azure.

    An Azure icon is displayed in the notification area that enables you to view the compute emulator UI and the storage emulator UI, or to shut down these services.

    There are two versions of the compute emulator, Full and Express. In some cases when you are using one the emulators, an error message might be displayed: "Unable to determine the emulator running mode. Please ensure you have sufficient permissions." If you see this error, it is an indication that the emulator is running with a different set of permissions than you are currently using in Visual Studio. This could happen, for example, if you restart Visual Studio with a different set of permissions but don't stop the emulator. To resolve this issue, simply restart the compute emulator. You can stop and start the emulator by using the shortcut menu for the Azure icon on the task bar.

  2. If you are using the storage emulator for the first time, the Development Storage Initialization dialog box is displayed. When the initialization process is complete, choose the OK button to close the dialog box.

    The browser starts automatically and points to the ASP.NET web site.

    New ASP.NET web page in browser.
  3. To manage your local deployments, open the shortcut menu for the Azure icon in the notification area and then choose Show Compute Emulator UI.

    Show the Azure compute emulator

    The Azure Compute Emulator appears.

  4. Choose MyWebRole to display the instances of the web role, as shown in the following illustration. Choose a specific instance to view only that individual instance.

    There are two instances of the web role because the instance count was set to 2 for the role. Either instance can process a request.

    Azure Compute Emulator runing 2 Web Roles
  5. To trigger the breakpoint that you set in the debugger, choose the button that you created.

  6. To step through the lines of code until you have uploaded the data to the blob and logged the message to the diagnostics table, press F10 three times.

  7. To view the data that you added to the blob, on the menu bar choose View, Server Explorer. Open the Azure node in the tree, and then choose the Storage, Development, Blobs node. If you are prompted to sign in, close the dialog box. Double-click the quicklap node, as displayed in the following illustration:


    The data in the blob is displayed in the quicklab tab.

  8. To view the data, double-click an entry displayed in the list.

  9. To view the diagnostics messages that you logged, on the menu bar choose View, Server Explorer if it is not already visible. Open the Azure node in the tree, and then choose the Storage, Development, Tables node. Double-click the WADLogsTable node.

    The diagnostics messages appear in the WADLogsTable tab. The data for the message is the last column in the table.

  10. To view the activity log for Azure, on the menu bar choose View, Other Windows, Azure Activity Log. The activity log lets you track the status of long-running operations. You’ll see an entry corresponding to the text blob you downloaded.

  11. If you’re using the storage emulator, open the shortcut menu for the Azure icon in the notification area and then choose Show Storage Emulator UI to show the following command window, which lets you control the running storage services.

    Azure storage emulator

By using the Azure Tools for Visual Studio, you can use Visual Studio to publish your cloud service directly to Azure.

Before you can publish an Azure cloud service, you must have a Microsoft account and an Azure subscription. In addition, you must set up a cloud service and storage account in the Azure Management Portal that will be used by your application. For more information about how to set up these services, see Setting Up Services Required to Publish a Cloud Service from Visual Studio.

When you publish your cloud service, you select the deployment environment for it. 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.

You can connect to your Azure subscription from Server Explorer to simplify the process of publishing to Azure. In versions of the Azure SDK prior to 2.2, it was necessary to download a subscription file (.publishsettings file) and then reference it when publishing a cloud service or connecting to storage accounts or other resources. If you’re using subscription files, you can still use them in Azure SDK 2.2, but if you connect to Azure by using the steps in the next procedure, you no longer have to manage subscription files.

  1. In Server Explorer, choose the Azure node, open its shortcut menu, and choose Connect to Azure.

    Connect to Windows Azure
  2. Sign in to Azure using the same credentials you use to sign in to the Management Portal. To minimize the number of times you have to provide your password, select the checkbox for Keep me signed in.

    Visual Studio saves your connection when you close it, so you’ll still be signed in when you start Visual Studio again.

  3. (Optional) If you want to sign out from Azure, open the shortcut menu for the Azure node in Server Explorer and choose Manage Subscriptions. The Manage Azure Subscriptions dialog box appears. To sign out, choose the Sign Out button, and then choose the Close button. You don’t have to sign out unless you want to sign in with another subscription.

  1. Follow these steps if you have to change any connection strings in your application to use Azure storage services:

    1. In Solution Explorer, open the shortcut menu for the web role in your Azure cloud service project that accesses the storage services (as you did earlier in this walkthrough) and choose Properties.

    2. In the property pages for the role, choose the Settings tab.

    3. To change the service configuration settings only for the Cloud configuration, in the Service Configuration list choose Cloud. You can then use this service configuration when you publish your Azure application.

    4. To change the connection string settings for the Cloud configuration, choose the button next to the setting.

      If you aren’t signed in to Azure, you’ll be asked to do so.

      The Create Storage Connection String dialog box appears.

      Azure storage account cloud connection string
    5. Under Connect using, choose the Your subscription option.

    6. In the Subscription list, choose your subscription. If the list doesn't contain the subscription that you want, choose the Download Publish Settings link.

    7. In the Account name list, choose your storage account name.

      The Azure tools get the storage account credentials automatically when you connect to Azure, or by using a subscription file (.publishsettings file). To specify your storage account settings manually, get your storage account name and primary key from the Management Portal, and then choose Manually entered credentials.

    8. You can decide how you want the service to access your storage account. If you want to connect to your storage account connect by using your subscription, the only setting you can change is whether to use HTTPS for your storage connection string. However, if you choose to connect using manually-entered credentials, you can choose the following settings.

      • Use HTTP. This is the standard option. For example, http://<account name>

      • Use HTTPS for a secure connection. For example, https://<accountname>

      • Specify custom endpoints for each of the three services. You can then enter these endpoints into the field for the specific service.

        You might choose to create custom endpoints if you need additional functionality. For example, you can specify storage service endpoints that include a custom domain name that you’ve registered for your storage account with the blob service. In addition, you can grant access only to blob resources in a single container through a shared access signature. For more information about how to create custom endpoints, see How to Configure Connection Strings.

      For the purposes of this exercise, connect by using the Your subscription option.

    9. Save the connection string changes by choosing the OK button.

      After you save these changes, you can build and run your Azure application from within Visual Studio by using this service configuration that you updated. You can then verify that it works as expected against the Azure storage services. For more information about how to select a service configuration to run and debug locally, see How to: Configure an Azure Cloud Service Project with Visual Studio.

  2. To publish your cloud service, open the shortcut menu for the Azure project that contains your role in Solution Explorer. Then choose Publish, as shown in the following illustration.


    The Publish Azure Application dialog box appears.

  3. If you haven't signed in, choose the Sign In button and provide your Azure user name and password.

    This is one of the publishing wizard screens
  4. In the Choose your subscription list, choose the subscription to use for this deployment.

    If you choose <Manage…>, you can create, edit, or delete subscriptions.

  5. When you're satisfied with your subscription information, choose the Next button to open the Settings page, and then choose the Common Settings tab.

    Publishing Wizard Common Settings
  6. In the Environment list, choose Production. This is the deployment environment that's used to host your cloud service. By default, these include Staging and Production.

    You can deploy to an environment that's empty or that another deployment is using.

  7. In the Build configuration list, choose the configuration you want, such as Release.

  8. In the Service configuration list, choose Cloud.

  9. To configure remote desktop connections for this deployment environment so that you can connect to the virtual machine that's running each instance of a role, select the Enable Remote Desktop for all roles checkbox and create account credentials to use when you log on to the virtual machines.

    For more information, see Using Remote Desktop with Azure Roles.

  10. Choose the Advanced Settings tab.

    Publish Wizard Advanced Settings
  11. On the Storage account list, choose the account to use to upload the service package to this account as part of the deployment process.

    This storage account doesn't have to be the storage account that you plan to use for the data for your application.

  12. If you don't want to automatically overwrite an existing deployment when you publish a new build of your application, select the Deployment update check box.

    For more information about deployment update settings, see Publish Azure Application Wizard.

  13. A default name is created for your deployment. To change this name, you can enter a new name or amend the default name in Deployment label. This name is used in the Azure Management Portal.

  14. To append the date and time to the label for the deployment, select the Append current date and time check box.

  15. To enable IntelliTrace for this deployment, select the Enable IntelliTrace 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, see Debugging Using IntelliTrace.

    You can enable IntelliTrace only when you publish your application from Visual Studio Ultimate.

  16. To enable profiling for this deployment to determine the performance of your Azure cloud service, select the Enable profiling check box. Profiling provides performance information for your applications. For more information about how to configure the settings for profiling, see Testing the Performance of a Cloud Service.

    You can enable either IntelliTrace or profiling when you publish your Azure cloud service. You cannot enable both.

  17. (Optional) If you are publishing from Visual Studio and you have installed the latest version of the Azure tools, you can also enable Web Deploy for all your web roles. For the requirements and the detailed steps to do this, see To Enable Web Deploy When You Publish Your Application.

  18. Choose the Next button to review your settings.

    Publish Wizard summary page
  19. To publish your Azure cloud service, choose the Publish button. Visual Studio starts the deployment process. You can see the progress of the deployment from the Azure Activity Log window. This log automatically appears when the deployment process starts. You can expand line items in the activity log to show detailed information, as shown in the following illustration.

  20. (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 Azure.

    To remove this deployment environment after it has been deployed, you must use the Management Portal.

  21. (Optional) After your role instances have started, Visual Studio automatically shows the deployment environment node in Server Explorer. From here you can see the status of the individual role instances. For more information about how to use Server Explorer to view your deployments, see Viewing the State of a Cloud Service using Server Explorer.

    The following illustration shows the role instances while one of the instances is still in the Busy state, because it’s still being initialized.

  22. To access your cloud service after deployment, choose the arrow next to your deployment when a status of Completed is displayed in the Azure Activity log. To start a browser with your cloud service, choose the hyperlink that’s displayed in the deployment details.

See Also

© 2015 Microsoft