When you will use the following code in Page_Load function of
String sRootPath = Environment.GetEnvironmentVariable("RoleRoot");
You will see different results depend on Full IIS Web Role
and HWC as below:
Full IIS Web Role - sRootPath
HWC Web Role - sRootPath = E:
This is because:
In Full IIS
configuration, the Web Role is running in WaIISHost.exe process however to Web
Site is running in w3wp.exe.
In HWC web role,
both the role and web site is running in WaWebHost.exe process.
With Full IIS the
web site process is not only a different appdomain but a different process
launched by a different service.
Because of it the
situation becomes complex to pass the role environment variables to web site.
You can write code
to pass this data via the registry or file system.
You can read service
configuration settings using the RoleEnvironment.GetConfigurationSettings.
Thanks for this post.
RoleEnvironment.GetConfigurationSettings() is an unknown method - what version of the sdk is this?
It’s been a great pleasure to thank you for this informative article. I will always recommend your article and refer to my friend too for the same.
When I am using a WebRole deployed to Azure, I can use RoleEnvironment in my RoleEntryPoint as well as my website (running in the cloud service in a w3wp). However if I add another Site this site cannot access RoleEnvironment. Why is it that one website can, but another cannot? This is with SDK 2.4