Search code examples
azureazure-role-environment

Detect Azure Stage or Production by Microsoft.WindowsAzure.ServiceRuntime


I know this question has been asked before, like this one. But they all very old, the method is very complex and I tried cannot really get it work. So I wonder if the new Azure SDK gives something easy, I guess should from Microsoft.WindowsAzure.ServiceRuntime namespace.

I need this because I use a worker role that mount CloudDrive, keep checking it and share to the network, then build a lucene.net on it.

This deployment works very well.

Since only 1 instance can mount the CloudDrive, so when I do VIP swap, I have to stop/(or delete) the stage deployment, then the new production deployment can successfully mount the drive. This cause the fulltext search stop for awhile (around 1-2 minutes if everything well and I click the button fast enough). So I wonder if I can detect current status, and only mount when production and unmount when stage.


Solution

  • I figured out one way to solve this, please see my answer here:

    https://stackoverflow.com/a/18138700/1424115