I have a small executable I run as part of the startup tasks of my Azure web role. I used RoleEnvironment.GetConfigurationSettingValue to read some settings from the cscfg inside the executable, which worked fine. I was given feedback that it is recommended to use CloudConfigurationManager.GetSetting instead, but when I tried it, the method returned null (setting not found). I can see the settings I'm trying to read are there in the portal.
I saw that some people had a similar issue with CloudConfigurationManager and asked about it: 1. here: CloudConfigurationManager.GetSetting returning null 2. and here: CloudConfigurationManager.GetSetting returns empty string in production?
But the solutions were always about updating the Azure SDK and all references, which doesn't work for me.
(We use Azure SDK v2.0 and all references point to the same version. I also validated this is the version loaded at runtime on the VM)
Thanks in advance for any clues!
My problem was that the StartUp Project of my solution changed to the WebRole project. This resulted in solution being started as a web project that didn't run inside the Azure emulator. Since CloudConfigurationManager.GetSetting
tries to get setting by contacting Azure (or Azure emulator in this case), and it is not running, it returns null
.
The solution was to change the StartUp project to the Azure project by right-clicking it and selecting Set as StartUp Project
. After this, your web role will start running under Azure emulator and everything will work correctly..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With