Avkash Chauhan's Blog

Windows Azure, Windows 8, Cloud Computing, Big Data and Hadoop: All together at one place.. One problem, One solution at One time...

Role Environment Variables in Full IIS Web Role and in HWC Web Role

Role Environment Variables in Full IIS Web Role and in HWC Web Role

Rate This
  • Comments 2

When you will use the following code in Page_Load function of default.aspx:

                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 =       NULL

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. 

Leave a Comment
  • Please add 1 and 5 and type the answer here:
  • Post
  • Hi Avkash

    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.

Page 1 of 1 (2 items)