From f2a1c97d12ecc0339c5d0a540ee1672a947c11db Mon Sep 17 00:00:00 2001 From: Rajkumar Rangaraj Date: Mon, 26 Jan 2026 19:37:33 -0800 Subject: [PATCH 1/2] Mark cloud context internal --- .../Stable/PublicAPI.Unshipped.txt | 6 ------ .../DataContracts/TelemetryContext.cs | 16 ++++++++-------- .../Extensibility/Implementation/CloudContext.cs | 2 +- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/.publicApi/Microsoft.ApplicationInsights.dll/Stable/PublicAPI.Unshipped.txt b/.publicApi/Microsoft.ApplicationInsights.dll/Stable/PublicAPI.Unshipped.txt index 862a7bb6f..3138568ce 100644 --- a/.publicApi/Microsoft.ApplicationInsights.dll/Stable/PublicAPI.Unshipped.txt +++ b/.publicApi/Microsoft.ApplicationInsights.dll/Stable/PublicAPI.Unshipped.txt @@ -113,7 +113,6 @@ Microsoft.ApplicationInsights.DataContracts.SeverityLevel.Warning = 2 -> Microso Microsoft.ApplicationInsights.DataContracts.StackFrame Microsoft.ApplicationInsights.DataContracts.StackFrame.StackFrame(string assembly, string fileName, int level, int line, string method) -> void Microsoft.ApplicationInsights.DataContracts.TelemetryContext -Microsoft.ApplicationInsights.DataContracts.TelemetryContext.Cloud.get -> Microsoft.ApplicationInsights.Extensibility.Implementation.CloudContext Microsoft.ApplicationInsights.DataContracts.TelemetryContext.GlobalProperties.get -> System.Collections.Generic.IDictionary Microsoft.ApplicationInsights.DataContracts.TelemetryContext.Location.get -> Microsoft.ApplicationInsights.Extensibility.Implementation.LocationContext Microsoft.ApplicationInsights.DataContracts.TelemetryContext.Operation.get -> Microsoft.ApplicationInsights.Extensibility.Implementation.OperationContext @@ -133,11 +132,6 @@ Microsoft.ApplicationInsights.DataContracts.TraceTelemetry.Timestamp.set -> void Microsoft.ApplicationInsights.DataContracts.TraceTelemetry.TraceTelemetry() -> void Microsoft.ApplicationInsights.DataContracts.TraceTelemetry.TraceTelemetry(string message) -> void Microsoft.ApplicationInsights.DataContracts.TraceTelemetry.TraceTelemetry(string message, Microsoft.ApplicationInsights.DataContracts.SeverityLevel severityLevel) -> void -Microsoft.ApplicationInsights.Extensibility.Implementation.CloudContext -Microsoft.ApplicationInsights.Extensibility.Implementation.CloudContext.RoleInstance.get -> string -Microsoft.ApplicationInsights.Extensibility.Implementation.CloudContext.RoleInstance.set -> void -Microsoft.ApplicationInsights.Extensibility.Implementation.CloudContext.RoleName.get -> string -Microsoft.ApplicationInsights.Extensibility.Implementation.CloudContext.RoleName.set -> void Microsoft.ApplicationInsights.Extensibility.Implementation.LocationContext Microsoft.ApplicationInsights.Extensibility.Implementation.LocationContext.Ip.get -> string Microsoft.ApplicationInsights.Extensibility.Implementation.LocationContext.Ip.set -> void diff --git a/BASE/src/Microsoft.ApplicationInsights/DataContracts/TelemetryContext.cs b/BASE/src/Microsoft.ApplicationInsights/DataContracts/TelemetryContext.cs index b28fb0382..606c37878 100644 --- a/BASE/src/Microsoft.ApplicationInsights/DataContracts/TelemetryContext.cs +++ b/BASE/src/Microsoft.ApplicationInsights/DataContracts/TelemetryContext.cs @@ -51,14 +51,6 @@ public IDictionary GlobalProperties get { return LazyInitializer.EnsureInitialized(ref this.GlobalPropertiesValue, () => new ConcurrentDictionary()); } } - /// - /// Gets the object describing the cloud tracked by this . - /// - public CloudContext Cloud - { - get { return LazyInitializer.EnsureInitialized(ref this.cloud, () => new CloudContext()); } - } - /// /// Gets the object describing a user tracked by this . /// @@ -84,6 +76,14 @@ public LocationContext Location get { return LazyInitializer.EnsureInitialized(ref this.location, () => new LocationContext()); } } + /// + /// Gets the object describing the cloud tracked by this . + /// + internal CloudContext Cloud + { + get { return LazyInitializer.EnsureInitialized(ref this.cloud, () => new CloudContext()); } + } + /// /// Gets the object describing the component tracked by this . /// diff --git a/BASE/src/Microsoft.ApplicationInsights/Extensibility/Implementation/CloudContext.cs b/BASE/src/Microsoft.ApplicationInsights/Extensibility/Implementation/CloudContext.cs index 207613ebb..92d8c5e57 100644 --- a/BASE/src/Microsoft.ApplicationInsights/Extensibility/Implementation/CloudContext.cs +++ b/BASE/src/Microsoft.ApplicationInsights/Extensibility/Implementation/CloudContext.cs @@ -3,7 +3,7 @@ /// /// Encapsulates information about a cloud where an application is running. /// - public sealed class CloudContext + internal sealed class CloudContext { private string roleName; private string roleInstance; From 5ee13312b2b7093e1848b566e3dbc2883645b1d0 Mon Sep 17 00:00:00 2001 From: Rajkumar Rangaraj Date: Tue, 27 Jan 2026 09:40:37 -0800 Subject: [PATCH 2/2] remove cloud context from example --- examples/ClassicAspNetWebApp/Global.asax.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/examples/ClassicAspNetWebApp/Global.asax.cs b/examples/ClassicAspNetWebApp/Global.asax.cs index fe85c4f97..17954ded2 100644 --- a/examples/ClassicAspNetWebApp/Global.asax.cs +++ b/examples/ClassicAspNetWebApp/Global.asax.cs @@ -48,9 +48,6 @@ void Application_Start(object sender, EventArgs e) // // AUTHENTICATION: Azure AD (Entra ID) token-based auth // // Requires: Install-Package Azure.Identity // // telemetryConfig.SetAzureTokenCredential(new Azure.Identity.DefaultAzureCredential()); - // - // var telemetryClient = new TelemetryClient(telemetryConfig); - // telemetryClient.Context.Cloud.RoleName = "MyWebApp"; } } } \ No newline at end of file