如何检查是否code为在Azure上运行的网站 [英] How to check if code is running on Azure Websites

查看:144
本文介绍了如何检查是否code为在Azure上运行的网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道,我们可以使用 RoleEnvironment.IsAvailable 来检查,如果code在网络/辅助角色运行。怎么样的 Azure的网站

I knew that we can use RoleEnvironment.IsAvailable to check if code is running in Web/Worker Role. How about Azure Websites?

我试过上述RoleEnvironment code,但它始终返回false。我需要运行在的Application_Start 一些配置code,所以我不能依赖于要求的东西。

I tried the above RoleEnvironment code but it always returns false. I need to run some configuration code in Application_Start so I cannot depend on the request stuff.

任何帮助是AP preciated。

Any help is appreciated.

推荐答案

这其实是很容易简单地检查这个环境变量的存在: WEBSITE_SITE_NAME

This is actually very easy simply check for existence of this environment variable: WEBSITE_SITE_NAME.

!String.IsNullOrEmpty(Environment.GetEnvironmentVariable("WEBSITE_SITE_NAME"))

此内容将您的网站的名称。

The content for this will be the name of your site.

要看到你有你的网站更下环境变量去以下链接:https://开头{SITENAME} .scm.azurewebsites.net / env的

To see more environment variable that you have under your site go to the following link: https://{sitename}.scm.azurewebsites.net/Env

这篇关于如何检查是否code为在Azure上运行的网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆