![](/img/trans.png)
[英]Application Insights No data since deployed to Azure web app
[英]VS Application Insights for a Web App deployed to multiple environments
我正在试验部署到Azure的Web应用程序上的MS Application Insgihts。
似乎没有开箱即用的一件事是按部署环境隔离统计数据/分析。
只是想知道有没有人已经这样做了,以及如何实现它?
这就是我的想法。
在AI中创建4个单独的“应用程序”(每个都有自己的应用程序名称和组件ID)
将单个ApplicationInsights.config添加到Web应用程序项目
手动将App.Config转换为应用程序,以在构建时基于Configuratoin(QA,UAT或Prod)替换ComponentName和ComponentId
将条件编译符号添加到Web应用程序构建配置(QA,UAT,PROD)
将“#if QA”预处理器指令添加到razor _layout视图,以便在构建时将正确的ComponentId交换到javascript代码段中。
思考?
这就是我们所做的。
在布局javascript获取appId:
appInsights.start("@ServerAnalytics.ApplicationInsightsId");
我在2015年1月7日的msdn博客上发现了这个问题, Application Insights支持多种环境,邮票和应用版本 。
基本上,您可以从ApplicationInsights.config
删除检测密钥,并将其作为appSetting放在Web.config
中,然后在启动时进行设置。
这意味着您可以直接在azure中保留每个环境的配置。
我的步骤:
ApplicationInsights.config
删除<InstrumentationKey>
在Web.config中添加设置
<add key="appInsightsInstrumentationKey" value="id_from hre"/>
在启动时:
var aiInstrumentationKey = System.Web.Configuration.WebConfigurationManager.AppSettings["appInsightsInstrumentationKey"]; if( string.IsNullOrEmpty(aiInstrumentationKey)) { throw new ApplicationException("appInsightsInstrumentationKey missing in web.config"); } Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.Active.InstrumentationKey = aiInstrumentationKey;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.