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 feature Multiple Service Configuration. As the name suggests itself, we can have Multiple Service Configuration files for an Azure ASP.Net application and use it across the environment. This feature is very much effective to reduce time-consuming when deploying our application to the cloud like changing the configuration files and then deploying it to the cloud.
[more]Steps:
This feature provides 2 set 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 on 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.
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.
Now we need to select ASP.Net Web Role from the role list as shown in the screen below and click on OK button to proceed further.
Now the project will be opened and we can see 2 configuration files created named as below
- ServiceConfiguration.Local.cscfg
- ServiceConfiguration.Cloud.cscfg
Now right click on the Azure project and select properties as shown in the screen below
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.
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.
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.
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.
Now we can directly click the debug button or press F5 to build and debug the application as shown in the screen below.
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 cloud.
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.
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.
Conclusion:
So in this article we have seen the Multiple Service Configuration feature introduced in Windows Azure tools V1.4 for Visual Studio 2010.