ConfigurationManager has AppSettings name-value collection but CloudConfigurationManager has only GetSetting(string) method where you can get the config settings 1 by 1 if you know the key.
Is there a way to get the whole config of the role runtime?
The root cause is that I want to make strong typed configuration in order to abstract it away and make my code more testable. Using CloudConfigurationManager directly is implicit dependency which I want to remove with an abstraction which I want to stub in tests. So I find this practical. Which brings me to my question.
I do not want to use library like fx.configuration.azure because I will have to carry its dependency altogether because it requires inheritance of a base class.
AFAIK, there's no direct method available which will give you this information.
However there's a workaround that you can use. It involves making use of Service Management API's
Get Deployment
operation. This operation will return an XML and one of the element there isConfiguration
which contains your service configuration file in Base64 encoded format. You can read this element, convert it into string and parse the XML to get toConfigurationSettings
elements. It's child elements contains all the settings.For this, you could either write your own wrapper over Service Management REST API or make use of
Azure Management Library
.UPDATE
So here's a sample code for listing all configuration settings from
Service Configuration File
usingAzure Management Library
. It's a simple console app hacked together in very short amount of time thus has a lot of scope of improvement :). For management certificate, I have used the data from Publish Setting File.You just have to install
Azure Management Library
Nuget Package in your console application: