Windows Azure - Multiple Service Configurations For Azure in VS2010

Introduction:

In this article we are going to see how to use the new Multiple Service Configuration in Windows Azure using Visual Studio 2010.

Overview:

In our earlier article we have seen the latest release of the Azure tools V1.4 for Visual Studio 2010, Now in this article we are going to see one of the new features Multiple Service Configuration. As the name suggests, we can have Multiple Service Configuration files for an Azure ASP.Net application and use it across the environment. This feature is highly effective in reducing the consumption of time when deploying our application to the cloud like changing the configuration files and then deploying it to the cloud.

Steps:

This feature provides 2 sets of configuration files as below:
  • ServiceConfiguration.Local.cscfg - Can use it locally for debugging
  • ServiceConfiguration.Cloud.cscfg - Can use it remotely in cloud when publishing
Let us see the step by step process of how to use these 2 configuration files in our Azure Application when using it locally and when deploying to the cloud.
Open Visual Studio 2010 IDE in administrator mode and go to File -> New -> Project as shown in the screen below.

new project of windowa azuru

Now select Cloud template from the left Menu and select Windows Azure Project as shown in the screen below. Also provide a valid user-friendly name and the location to store the application and click on OK button to proceed further.

cloud project 

Now we need to select ASP.Net Web Role from the role list as shown in the screen below and click on the OK button to proceed further.

asp.net web role in windows azure 

Now the project will be opened and we can see 2 configuration files created, named as below:

  • ServiceConfiguration.Local.cscfg
  • ServiceConfiguration.Cloud.cscfg

cscfg file in windows azure 

Now right-click on the Azure project and select properties as shown in the screen below:

project property in windows azure 

Now the properties window will be opened, in the property window we can see the different options to be changed based on our configuration file selection and our requirement as shown in the screen below.

0011.gif

Now for checking the sample, we have selected Cloud from the Service Configuration drop down and keep the options standard as shown in the screen below.

0022.gif

Now select Local from the Service Configuration and increase the Instance Count to 2 just to check the configuration files created as shown in the screen below.

0033.gif

Now let us open both the configuration files (Local and Cloud) and we can see the instance count varies as shown in the screens below.

Cloud Configuration File:

0044.gif

Local Configuration File:

0055.gif

Now we can directly click the debug button or press F5 to build and debug the application as shown in the screen below.

0066.gif
 
Now when we try to publish the application to the cloud we can see the setting changes. Right-click on the application and select Publish as shown in the screen below to publish our application to the cloud.

0077.gif
 
We can see a new Publish Setting window to do the configuration changes as per our requirement to deploy it to the cloud as shown in the screen below.

asp.net web role in windows azure
 
In the Service Configuration drop down we can select which configuration we need to upload to the server. We can select Cloud or Local so that the respective configuration will be deployed to the server as shown in the screen below.

publishing setting of windows azure

Conclusion:

So in this article we have seen the Multiple Service Configuration feature introduced in Windows Azure tools V1.4 for Visual Studio 2010.


Similar Articles