如何检测 azure 应用程序正在开发结构中运行? [英] How to detect that azure application is running in development fabric?

查看:18
本文介绍了如何检测 azure 应用程序正在开发结构中运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何可靠性检测我的 Azure 应用程序是否在开发结构中运行,而不是在云"中运行?

How can I reliability detect whether my Azure application is running in development fabric and not in 'the cloud' ?

RoleEnvironment.IsAvailable 对两者都成立.我想要的东西只在一种情况下是正确的.

RoleEnvironment.IsAvailable is true for both. I want something that is true in only one case.

我之所以这么问是因为我希望我的图书馆的用户能够在开发结构中免费使用我的图书馆.因此,手动在配置文件中放置单独的标识符或标志并为 dev 和 deploy 保留两个配置是不可行的.

I'm asking this because I want users of my library to be able to use my library for free in dev fabric. Hence manually putting separate identifier or flag in config file and keeping two configs for dev and deploy is not feasible.

推荐答案

一个选项是查看 RoleEnvironment.DeploymentId - 如果您在开发结构中运行,它应该有一个名称如 'deployment(n)',其中 n 是某个序列号.如果您在生产中运行,则部署 ID 应类似于 Guid.

One option is to take a look at RoleEnvironment.DeploymentId - if you're running in the dev fabric, it should have a name like 'deployment(n)' where n is some sequential number. If you're running in production, the deployment id should resemble a Guid.

您可以做的另一件事是查看角色的实例名称.在生产中,它应该以 _0 结尾(代表实例 0).在开发结构中,它将以 .0

Another thing you can do is look at an role's instance name. In production, it should end in _0 (representing instance 0). In the dev fabric, it will end in .0

EDIT 1/8/2013 - 意识到我在 2 年前给出的这个答案已经过时了!现在还有 RoleEnvironment.IsEmulated - 查看详细信息 这里.

EDIT 1/8/2013 - realized this answer I gave over 2 years ago is quite outdated! Now there's also RoleEnvironment.IsEmulated - check out the details here.

这篇关于如何检测 azure 应用程序正在开发结构中运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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