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

How to audit an Azure Cosmos DB

In this post, we will talk about how we can audit an Azure Cosmos DB database. Before jumping into the problem let us define the business requirement: As an Administrator I want to be able to audit all changes that were done to specific collection inside my Azure Cosmos DB. The requirement is simple, but can be a little tricky to implement fully. First of all when you are using Azure Cosmos DB or any other storage solution there are 99% odds that you’ll have more than one system that writes data to it. This means that you have or not have control on the systems that are doing any create/update/delete operations. Solution 1: Diagnostic Logs Cosmos DB allows us activate diagnostics logs and stream the output a storage account for achieving to other systems like Event Hub or Log Analytics. This would allow us to have information related to who, when, what, response code and how the access operation to our Cosmos DB was done. Beside this there is a field that specifies what was th...

Cloud Myths: Cloud is Cheaper (Pill 1 of 5 / Cloud Pills)

Cloud Myths: Cloud is Cheaper (Pill 1 of 5 / Cloud Pills) The idea that moving to the cloud reduces the costs is a common misconception. The cloud infrastructure provides flexibility, scalability, and better CAPEX, but it does not guarantee lower costs without proper optimisation and management of the cloud services and infrastructure. Idle and unused resources, overprovisioning, oversize databases, and unnecessary data transfer can increase running costs. The regional pricing mode, multi-cloud complexity, and cost variety add extra complexity to the cost function. Cloud adoption without a cost governance strategy can result in unexpected expenses. Improper usage, combined with a pay-as-you-go model, can result in a nightmare for business stakeholders who cannot track and manage the monthly costs. Cloud-native services such as AI services, managed databases, and analytics platforms are powerful, provide out-of-the-shelve capabilities, and increase business agility and innovation. H...