Using the new Windows Azure Tools v1.4 for VS2010

The new Windows Azure Tools for v1.4 (August 2011) for VS2010 have just been released.  You can download them using Web Platform Installer here. This latest version of the tools introduces several new features as follows:
  1. Support for Multiple Service Configurations
  2. Profiling support for Windows Azure apps running in Windows Azure
  3. MVC 3 web role support
  4. Package validation
Note: Profiling is only supported in VS 2010  Ultimate+Premium.  All others are available from Visual Web Developer 2010 and up.
This post will take a brief look at the benefits each of these new features bring to you – the developer :)


Multiple Service Configurations

Gone are the days of having to change your settings in your ServiceConfiguration.cscfg when you switch from debugging your local cloud+storage emulator to publishing up to Windows Azure.  For example in your development environment for:
  1. local debug you may want to:
    • utilize 1 instance of your web/worker role
    • use the local storage emulator
  2. whereas in Windows Azure you may want to:
    • utilize 4 instances of your web/worker role
    • use a production Windows Azure storage account
To achieve this using the new multiple service configurations is easy.
  1. Create a new Windows Azure project with an arbitrary web or worker role.
    • File > New Project > Cloud > Windows Azure Project
    • Select a web or worker role and press OK
  2. Observe that the ServiceConfiguration.cscfg is now split by default into two files:
    • ServiceConfiguration.Local.cscfg – default used when debugging in VS
    • ServiceConfiguration.Cloud.cscfg – a config you can use on publish
  3. To configure each individual configuration with the settings we desired above.
    • Double click on the WorkerRole1 in the roles folder of the cloud project
    • then and select the Service Configuration dropdown for Cloud
    • Select Service Configuration Profile

    • Set the desired settings for your Cloud profile ServiceConfiguration.Cloud.cscfg

  4. You can then repeat the above for your Local configuration profile to setup and set the desired settings for ServiceConfiguration.Local.cscfg
  5. The net result is that both ServiceConfiguration.Cloud.cscfg and ServiceConfiguration.Local.cscfg will now have their independent settings as follows:
      Independent config in ServiceConfiguration.Cloud.cscfg

      Independent config in ServiceConfiguration.Cloud.cscfg

      Independent config in ServiceConfiguration.Local.cscfg

      Independent config in ServiceConfiguration.Local.cscfg

  6. When you hit debug now the ServiceConfiguration.Local.cscfg is used and when you hit publish you can select which Config you would like to use:

Overall its quite an easy experience to configure and use multiple Service Configuration profiles for your different environments.  Please note that you can also rename and add additional Service Configuration profiles perhaps such that you would have a config for Local, Staging and Prod.  For more detail on how to work with Service Configuration files please see Configuring a Windows Azure Application.

Profiling Support

This is an incredibly useful tool for any Windows Azure developer as it enables you to profile your Windows Azure application that’s running up in Windows Azure.  The information gathered can help analyze any performance issues you may be facing.  When you publish your application from VS you are able to specify your profiling options that will apply for the profiling session and results can be pulled for each instance.
The supported profiling options are as follows:
  1. CPU Sampling – Monitor CPU-bound applications with low overhead
  2. Instrumentation – Measure function call counts and timing
  3. .NET Memory Allocation (Sampling) – Track managed memory allocation
  4. Concurrency -Detect threads waiting for other threads
In this segment I will demonstrate how to configure a profiling session for a Windows Azure Application:
  1. Open your existing cloud project and right click on the windows azure cloud project and select Publish
  2. Select the Enable profiling option on the publish page and click settings
  3. Select the type of profiling you wish to perform in this case .NET Memory Allocation
  4. Note: Checking the Enable Tier Interaction Profiling option captures additional information about execution times of synchronous ADO.NET calls in functions of multi-tiered applications that communicate with one or more databases.  With the absence of a SQL Profiler in SQL Azure this feature is useful for those developers who want to gain some insight into what queries or stored procedures are running slowly.
  5. Press OK.
  6. Once the deployment is complete and the application has been running for a period of time you can go and download the captured profiling report.
  7. To download the profiling report
    • Select View > Server Explorer
    • Expand Windows Azure Compute
    • Expand the hosted service
    • Right click on the Instance that you want do download the profiling report from and press View Profiling Report
  8. Once the report is downloaded it will open in VS and as you can see the CPU is maxing out
  9. If we change the Current View dropdown to Allocation we can quickly identy a problem method that is using excessive amounts of memory
  10. and finally if we right click and select View Source on the method of interest we can see the offending line causing the allocations
What an awesome tool.  I look forward to digging deeper into the capabilities provided by for Windows Azure Profiling. In the meantime for more information please see – Profiling a Windows Azure Application


MVC 3 Web Role Support

ASP .NET MVC 3 web roles are now supported out of the box with the new tools.  You can select ASP .NET MVC 3 from the new Windows Azure project dialog and the required assemblies used by ASP .NET MVC 3 are set to copy local for you.  This results in these assemblies being deployed up to windows azure when you publish your application thus ensuring your MVC 3 application will start when deployed. I know a lot of you are probably thinking Eureka right now and those that may get a little bit too excited may even verbalize it, I know I did :)

To create a new Windows Azure ASP .NET MVC 3 application:

  1. File > New Project > Cloud > Windows Azure Project
  2. Select ASP .NET MVC 3 Web Role, press the > button followed by OK
  3. In the ASP .NET MVC 3 project dialog select settings to suit your preferences and press ok
  4. In solution explorer observe that all the references assemblies for ASP .NET MVC 3 that are not in the GAC in the current Windows Azure gues OS have had their Copy Local property set to true.  The below image shows and example of one of the required reference assemblies that is automatically set to copy local so you dont actually have to do anything :)

From here on in all you have to do is start coding :) – For more information on ASP .NET MVC 3 see this and for a detailed walkthrough of ASP .NET MVC 3 on Windows Azure see this post by Nathan Totten

Package Validation

Last but definitely not least is improved package validation. When you select to create a package or publish your Windows Azure application. Additional warnings or errors are now provided in VS to enable you to fix the problem before you package or publish it.  This as you know will be a great timesaver for details of what package validations are performed please see Troubleshooting Package Validation Errors and Warnings

Time to Download

All in all its an excellent new set of features that focus on improving your productivity and make your dev life a whole lot easier. If you have not already then now would be the time to download using Web Platform Installer :)

happy coding,