Azure websites RoleEnvironment.IsAvailable equivalent [duplicate]

自作多情 提交于 2019-12-23 02:42:17

问题


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?


回答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.



来源:https://stackoverflow.com/questions/28998566/azure-websites-roleenvironment-isavailable-equivalent

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!