Skip to main content

Why it is important to use Windows Azure Service Configuration Schema and not application configuration section from web.config or app.config

Knowing where to store the configuration of an application is very important. This can give the ability to a provider to switch the behavior of an application very fast and easily.
When you are developing a web application that will be hosted on Windows Azure, you have the possibility to store the configuration values in the web.config file of in the settings section of the role (from Windows Azure project). The same thing is for the case when you have a non-web application that has an app.config file. Of course we have the 3th option to put the content in a custom repository (file, database or so on), but we’ll focus on the first two options.
I saw a lot of project, where people ignored the configuration section of Windows Azure project. Also, they are used to store all the content in the web.config/app.config files, they don’t look to the new location where you can store them.
When you have the content store in the classic configuration file, you don’t have the ability to change the value of different settings without accessing remotely the machine or ISS configuration. Switching a settings from ON to OFF will required to access the machine remotely and change the configuration manually.
But what about if you have 20 instances. Well, you will need to do the same thing for 20 times or write a script. Some people will say that in this case they would put all the settings in a central repository from where all the instances can read the configuration (Azure Blobs, Azure Tables or a classic database).
All this solution are good and will work, but you need to write code, to configure in a different way all the application and from where the settings are read.
But, if we look closed to Windows Azure project we’ll see that we have a settings section for each role. We can add any kind of settings there. Above this we have another big advantage. From Windows Azure you can change the value of the settings.
This mean that you only need to go to portal, change the value of one settings key and all the instances of the roles will be able to access the new value of it. Beside this you have the possibility to export on your local system the settings configuration or import it from a custom source (you can and up with different profiles).
Another advantage of this is that the configuration settings is not ‘hardcoded’ in the package that is generated for the role.
Why is this so important? Well, when a role is reset or a new instances is created, the original package is used to deploy the application binaries. This mean that even if you change the web.config/app.config at runtime, the change will not be persisted when the role is reset or a new instance is created. To be able to persist the change, you will need to redeploy the application.
In contrast, when you have the settings in the configuration section of the role, you can reset the role, you can create as many new instances you want without changing you custom configuration. The only time when you lose this configuration is when you redeploy the project, but this is a normal behavior, because you publish a new version of the application.
In this post we saw why it is so important to use the configuration settings from Windows Azure project (roles) and not the one from the application configuration files.
In the next post we will see how we can detect automatically when the configuration settings from roles were changed.

Comments

Popular posts from this blog

Windows Docker Containers can make WIN32 API calls, use COM and ASP.NET WebForms

After the last post , I received two interesting questions related to Docker and Windows. People were interested if we do Win32 API calls from a Docker container and if there is support for COM. WIN32 Support To test calls to WIN32 API, let’s try to populate SYSTEM_INFO class. [StructLayout(LayoutKind.Sequential)] public struct SYSTEM_INFO { public uint dwOemId; public uint dwPageSize; public uint lpMinimumApplicationAddress; public uint lpMaximumApplicationAddress; public uint dwActiveProcessorMask; public uint dwNumberOfProcessors; public uint dwProcessorType; public uint dwAllocationGranularity; public uint dwProcessorLevel; public uint dwProcessorRevision; } ... [DllImport("kernel32")] static extern void GetSystemInfo(ref SYSTEM_INFO pSI); ... SYSTEM_INFO pSI = new SYSTEM_INFO(

ADO.NET provider with invariant name 'System.Data.SqlClient' could not be loaded

Today blog post will be started with the following error when running DB tests on the CI machine: threw exception: System.InvalidOperationException: The Entity Framework provider type 'System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer' registered in the application config file for the ADO.NET provider with invariant name 'System.Data.SqlClient' could not be loaded. Make sure that the assembly-qualified name is used and that the assembly is available to the running application. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information. at System.Data.Entity.Infrastructure.DependencyResolution.ProviderServicesFactory.GetInstance(String providerTypeName, String providerInvariantName) This error happened only on the Continuous Integration machine. On the devs machines, everything has fine. The classic problem – on my machine it’s working. The CI has the following configuration: TeamCity .NET 4.51 EF 6.0.2 VS2013 It see

Navigating Cloud Strategy after Azure Central US Region Outage

 Looking back, July 19, 2024, was challenging for customers using Microsoft Azure or Windows machines. Two major outages affected customers using CrowdStrike Falcon or Microsoft Azure computation resources in the Central US. These two outages affected many people and put many businesses on pause for a few hours or even days. The overlap of these two issues was a nightmare for travellers. In addition to blue screens in the airport terminals, they could not get additional information from the airport website, airline personnel, or the support line because they were affected by the outage in the Central US region or the CrowdStrike outage.   But what happened in reality? A faulty CrowdStrike update affected Windows computers globally, from airports and healthcare to small businesses, affecting over 8.5m computers. Even if the Falson Sensor software defect was identified and a fix deployed shortly after, the recovery took longer. In parallel with CrowdStrike, Microsoft provided a too