问题
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?
回答1:
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();
来源:https://stackoverflow.com/questions/26206673/how-to-support-multiple-azure-subscriptions-for-a-single-application-with-applic