Azure 网站 Application Insights - 切换配置 [英] Azure Websites Application Insights - switching config

查看:17
本文介绍了Azure 网站 Application Insights - 切换配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Azure 网站.为了这个问题,网站的生产版本运行在 example.com,网站的测试版本运行在 sandbox.example.com.p>

两者的唯一区别是配置不同.

目前它们在不同的网站下运行,我通过git将同一个网站部署到每个azure网站.

我想分离出 Application Insights 数据.除了在部署后在沙盒环境中编辑 ApplicationInsights.config 文件之外,是否有任何人使用的技术或流程?

或者使用部署槽以某种方式处理这个问题?

解决方案

今天有一篇关于这个的新博文:Application Insights 对多种环境、邮票和应用程序版本的支持.

<块引用>

遥测的目的地由仪器确定密钥 (iKey),与每条遥测消息一起发送.在里面Application Insights 门户,类似的事件和指标具有相同的iKey 汇总后为您提供平均持续时间、事件的图表计数、用户总数等.iKey 出现在两个地方你的项目.一个在 ApplicationInsights.config 中:<InstrumentationKey>94843456-2345-3456-4567-324562759284</InstrumentationKey>

如果您的应用程序有网页,iKey 也会出现在脚本中在每个网页的头部.通常,它只编码一次母版页,例如 ViewsShared\_Layout.cshtml.

要将遥测指向不同的应用程序资源,我们可以创建具有不同 iKey 的多个资源.那么我们只需要改变应用程序生命周期中每次转换时的 iKey——连同其他配置数据,例如连接字符串,证书和订阅.

然后文章继续介绍如何在代码、配置等中做到这一点:

<块引用>

1) 在Web.config中添加iKey作为属性:

2) 我们将不使用 ApplicationInsights.config 中的 iKey,而是在代码中设置它.在 global.asax.cs.

为避免混淆,请删除 <InstrumentationKey> 节点ApplicationInsights.config.

3) 配置网页以获取 instrumentationKey: "@Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.Active.InstrumentationKey".这是该脚本通常在 ViewShared\_Layout.cshtml 中找到.

4) 不要忘记使用适当的 iKey 更新您的 Web.config部署过程中的配置.你可能想出一种方法将其适当地设置为构建的一部分,但我将把它留给你.

I have an Azure Website. For the sake of this question, the production version of the website runs on example.com, and a test version of the website runs on sandbox.example.com.

The only difference between the two is that they have different configuration.

At present, they are running under different websites, and I deploy the same website to each azure website via git.

I'd like to separate out the Application Insights data. Is there a technique or process that anyone uses - apart from editing the ApplicationInsights.config file in the sandbox environment post deploy?

Or would using a deployment slot handle this in some way?

解决方案

There was a new blog post about exactly this today: Application Insights Support for Multiple Environments, Stamps and App Versions.

The destination of the telemetry is determined by the instrumentation key (iKey), which is sent along with every telemetry message. In the Application Insights portal, similar events and metrics with the same iKey are aggregated to give you charts of average durations, event counts, the sum of users, and so on. The iKey appears in two places in your project. One is in ApplicationInsights.config: <InstrumentationKey>94843456-2345-3456-4567-324562759284</InstrumentationKey>

If your application has web pages, the iKey also appears in a script in the head of every web page. Usually, it’s only coded once in a master page such as ViewsShared\_Layout.cshtml.

To direct telemetry to different application resources, we can create several resources with different iKeys. Then we only have to change the iKeys in the application at each transition in its lifecycle – along with other configuration data such as connection strings, certificates, and subscriptions.

The article then goes on how to do this in code, confg, etc:

1) Add iKey as a property in Web.config:

2) Instead of using the iKey from ApplicationInsights.config, we’ll set it in the code. In global.asax.cs.

To avoid confusion, remove the <InstrumentationKey> node from ApplicationInsights.config.

3) Configure the web pages to pick up instrumentationKey: "@Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.Active.InstrumentationKey". This is the script usually found in ViewShared\_Layout.cshtml.

4) Don’t forget to update your Web.config with appropriate iKey configuration during the deployment process. You might devise a way of setting it appropriately as part of your build, but I’ll leave that to you.

这篇关于Azure 网站 Application Insights - 切换配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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