3

I'm migrating an web app from an Azure Cloud Services Web Role to Azure Websites. Websites can't find Microsoft.WindowsAzure.ServiceRuntime and doesn't seem to like the Cloud Service helpers in general.

The app uses RoleEnvironment.IsAvailable in a few places to behave differently online versus on a development computer. (We ran in development outside of the Web Role emulator for speed.)

Is there an equivalent property to RoleEnvironment.IsAvailable for determining whether the app is running in the cloud?

Edward Brey
  • 40,302
  • 20
  • 199
  • 253
  • Could you describe a little bit more about your requirement? I'm afraid Azure Web Sites are not what are you looking for. – Thiago Custodio Mar 11 '15 at 22:45
  • @ThiagoCustodio It's a mostly run-of-the-mill website; however, back when it was rolled out, we had to use a Web Role because Websites didn't support web sockets or wildcard domains at the time. Now that it does, we want to migrate to Websites for simplified diagnostics and faster updating. – Edward Brey Mar 11 '15 at 22:48
  • OK, but why do you need to check if Role Environment is available? Is there any special requirement for that? I'm asking this, because you can configure your web sites to "Always On". – Thiago Custodio Mar 11 '15 at 22:54
  • 1
    @ThiagoCustodio - why does it matter what the requirement is? The OP wants to know if there's a built-in check, as there *is* a built-in check for web/worker role instances, and the OP is now migrating from web role to websites. Maybe the site runs both in the cloud and on-premises, and something is done differently in and out of Azure. In any case, seems like a perfectly valid question to me. – David Makogon Mar 12 '15 at 06:02

1 Answers1

1

There are many ways to differentiate running on Azure Websites of in a development environment.

If it's in the context of a request then I would go with checking the host if it's localhost vs mysite.com for example.

Another option is to check any of the Environment Variables that Azure websites injects in your site. You can find a list in here https://<yourSiteName>.scm.azurewebsites.net/Env

Finally you can define your own AppSetting in Azure Portal for the site, then check it's existence to know which environment you are running on.

ahmelsayed
  • 7,125
  • 3
  • 28
  • 40