如何通过应用程序见解为单个应用程序支持多个Azure订阅 [英] How to support multiple Azure subscriptions for a single application with application insights

查看:55
本文介绍了如何通过应用程序见解为单个应用程序支持多个Azure订阅的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行VS 2013 Update 3,并安装了带有App Insights的Cloud Service.一切都很好.但是,我有三个不同的订阅(开发,登台和生产),并且希望我的开发云服务实例向我的开发订阅报告应用洞察数据,而我的登台云服务实例向我的分段订阅报告应用洞察数据.如何配置该单个云应用程序以将数据报告给不同的订阅和/或应用程序见解应用程序名称?

I'm running VS 2013 Update 3 and have a Cloud Service with App Insights installed. That is all good and well. However, I have three different subscriptions (dev, staging, and production) and want my dev cloud service instance to report app insights data to my dev subscription while my staging cloud service instance reports app insights data to my staging subscription. How can I configure this single cloud app to report data to different subscriptions and/or app insights app names?

推荐答案

我最终想到了以下内容:

I ended up going with the following within:

public class ConfigSettings
{
    internal class AppInsights
    {
        internal static bool IsEnabled
        {
            get
            {
                return CloudConfigurationManager.GetSetting("AppInsights.IsEnabled").Cast<bool>();
            }
        }

        internal static string InstrumentationKey
        {
            get
            {
                return CloudConfigurationManager.GetSetting("AppInsights.InstrumentationKey");
            }
        }
    }
}

public class AppInsightsHelper
{
    public static void Initialize()
    {
        if(ConfigSettings.AppInsights.IsEnabled)
            TelemetryConfiguration.Active.InstrumentationKey = ConfigSettings.AppInsights.InstrumentationKey;
    }
}

// In global.asax.cs
AppInsightsHelper.Initialize();

这篇关于如何通过应用程序见解为单个应用程序支持多个Azure订阅的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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