Compartir a través de


Using RoleEnviornment.IsAvailable and RoleEnviornment.IsEmulated properties in Windows Azure Applications

RoleEnviornment.IsAvailable is used to determine whether the role environment is available or not no matter the role is running in devFabric or cloud. RoleEnviornment.IsAvailable is available with Windows Azure SDK 1.4 and SDK 1.5.

 

RoleEnvironment.IsEmulated, which is a supported method of determining if you are running in the Compute Emulator. This property is only available in Windows Azure SDK 1.5.

 

So if you want to check if you code is running in cloud or in development fabric, first you can use RoleEnviornment.IsAvailable property to validate it is true. Only after that you could call Role.IsEmulated to decide whether it is running at devFabric or cloud. In every case, you should be blocking on RoleEnvironment.IsAvaliable returning a true value before accessing any runtime API.

 

Steve Marx has written a nice article on RoleEnviornment.IsEmulated property:

https://blog.smarx.com/posts/skipping-windows-azure-startup-tasks-when-running-in-the-emulator