views:

240

answers:

3

How can I reliability detect whether my Azure application is running in development fabric and not in 'the cloud' ?

RoleEnvironment.IsAvailable is true for both. I want something that is true in only one case.

I'm asking this because I want users of my library to be able to use my library for free in dev fabric. Hence manually putting separate identifier or flag in config file and keeping two configs for dev and deploy is not feasible.

A: 

For example:

The development fabric does not fully simulate the behavior of the Windows Azure load balancer. For example, if code running in a web role instance calls the SetBusy method from within the RoleEnvironment.StatusCheck event handler to indicate that the role instance should be taken out of the load balancer's rotation, you will still be able to access your role from your browser while its status is RoleInstanceStatus.Busy.

Also azure fabric normally runs under one of the few fixed OS Images. So you can also investigate System.Environment. for some patterns that occur only in azure fabric (i.e. specific OS version matching to Windows Azure OS or something like this).

Rinat Abdullin
+3  A: 

One option is to take a look at RoleEnvironment.DeploymentId - if you're running in the dev fabric, it should have a name like 'deployment(n)' where n is some sequential number. If you're running in production, the deployment id should resemble a Guid.

Another thing you can do is look at an role's instance name. In production, it should end in _0 (representing instance 0). In the dev fabric, it will end in .0

David Makogon
A: 

Use RoleEnvironment.IsAvailable :)

Edit: This detects if it is running on Azure vs. something like IIS.

Josh