title: Detecting if a .NET app is running in Azure or on a non-Azure environment
body: <p>We are currently moving some instances of our application to Azure, but will still maintain backwards compatibility with existing instances which are not Azure hosted.</p>
  
  <p>Is there a good way to detect the environment without installing the SDK on the non-Azure production server?</p>
  
  <p>I've tried using:</p>
  
  <pre><code>if (RoleEnvironment.IsAvailable)
  </code></pre>
  
  <p>from Microsoft.WindowsAzure.ServiceRuntime, and it works perfectly locally, and in Azure. However, I need to set the Microsoft.WindowsAzure.ServiceRuntime.dll to CopyLocal, and even then I get:</p>
  
  <blockquote>
    <p>Could not load file or assembly 'msshrtmi, Version=2.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies</p>
  </blockquote>
  
  <p>There doesn't seem to be a NuGet package, and I don't want to manually copy the msshrtmi dll about.</p>
  
  <p>Perhaps there's a way of detecting without the dependency on Microsoft.WindowsAzure.ServiceRuntime?</p>