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(

Azure AD and AWS Cognito side-by-side

In the last few weeks, I was involved in multiple opportunities on Microsoft Azure and Amazon, where we had to analyse AWS Cognito, Azure AD and other solutions that are available on the market. I decided to consolidate in one post all features and differences that I identified for both of them that we should need to take into account. Take into account that Azure AD is an identity and access management services well integrated with Microsoft stack. In comparison, AWS Cognito is just a user sign-up, sign-in and access control and nothing more. The focus is not on the main features, is more on small things that can make a difference when you want to decide where we want to store and manage our users.  This information might be useful in the future when we need to decide where we want to keep and manage our users.  Feature Azure AD (B2C, B2C) AWS Cognito Access token lifetime Default 1h – the value is configurable 1h – cannot be modified

What to do when you hit the throughput limits of Azure Storage (Blobs)

In this post we will talk about how we can detect when we hit a throughput limit of Azure Storage and what we can do in that moment. Context If we take a look on Scalability Targets of Azure Storage ( https://azure.microsoft.com/en-us/documentation/articles/storage-scalability-targets/ ) we will observe that the limits are prety high. But, based on our business logic we can end up at this limits. If you create a system that is hitted by a high number of device, you can hit easily the total number of requests rate that can be done on a Storage Account. This limits on Azure is 20.000 IOPS (entities or messages per second) where (and this is very important) the size of the request is 1KB. Normally, if you make a load tests where 20.000 clients will hit different blobs storages from the same Azure Storage Account, this limits can be reached. How we can detect this problem? From client, we can detect that this limits was reached based on the HTTP error code that is returned by HTTP