diff --git a/Microsoft.Azure.Cosmos.Samples/Usage/ApplicationInsights/AppSettings.json b/Microsoft.Azure.Cosmos.Samples/Usage/ApplicationInsights/AppSettings.json new file mode 100644 index 0000000000..028030099b --- /dev/null +++ b/Microsoft.Azure.Cosmos.Samples/Usage/ApplicationInsights/AppSettings.json @@ -0,0 +1,5 @@ +{ + "CosmosDBEndPointUrl": "https://localhost:8081", + "CosmosDBAuthorizationKey": "Super secret key", + "ApplicationInsightsConnectionString": "Super secret connection string" +} \ No newline at end of file diff --git a/Microsoft.Azure.Cosmos.Samples/Usage/ApplicationInsights/ApplicationInsights.csproj b/Microsoft.Azure.Cosmos.Samples/Usage/ApplicationInsights/ApplicationInsights.csproj index 2ade53a665..59162abaca 100644 --- a/Microsoft.Azure.Cosmos.Samples/Usage/ApplicationInsights/ApplicationInsights.csproj +++ b/Microsoft.Azure.Cosmos.Samples/Usage/ApplicationInsights/ApplicationInsights.csproj @@ -1,8 +1,10 @@ - + Exe net6.0 + Cosmos.Samples.ApplicationInsights + Cosmos.Samples.ApplicationInsights latest @@ -13,9 +15,11 @@ + - + PreserveNewest + diff --git a/Microsoft.Azure.Cosmos.Samples/Usage/ApplicationInsights/Program.cs b/Microsoft.Azure.Cosmos.Samples/Usage/ApplicationInsights/Program.cs index fbc1ae7894..288ce80c64 100644 --- a/Microsoft.Azure.Cosmos.Samples/Usage/ApplicationInsights/Program.cs +++ b/Microsoft.Azure.Cosmos.Samples/Usage/ApplicationInsights/Program.cs @@ -4,10 +4,12 @@ using System.Threading.Tasks; using Newtonsoft.Json; using Microsoft.Azure.Cosmos; + using Microsoft.Extensions.Logging; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.ApplicationInsights; using Microsoft.ApplicationInsights.WorkerService; + using Microsoft.Extensions.Logging.ApplicationInsights; internal class Program { @@ -24,13 +26,13 @@ static async Task Main() .AddJsonFile("AppSettings.json") .Build(); - string endpoint = configuration["EndPointUrl"]; + string endpoint = configuration["CosmosDBEndPointUrl"]; if (string.IsNullOrEmpty(endpoint)) { throw new ArgumentNullException("Please specify a valid CosmosDBEndPointUrl in the appSettings.json"); } - string authKey = configuration["AuthorizationKey"]; + string authKey = configuration["CosmosDBAuthorizationKey"]; if (string.IsNullOrEmpty(authKey) || string.Equals(authKey, "Super secret key")) { throw new ArgumentException("Please specify a valid CosmosDBAuthorizationKey in the appSettings.json"); diff --git a/Microsoft.Azure.Cosmos.Samples/Usage/OpenTelemetry/AppSettings.json b/Microsoft.Azure.Cosmos.Samples/Usage/OpenTelemetry/AppSettings.json new file mode 100644 index 0000000000..e0d21e3e09 --- /dev/null +++ b/Microsoft.Azure.Cosmos.Samples/Usage/OpenTelemetry/AppSettings.json @@ -0,0 +1,12 @@ +{ + "Logging": { + "OpenTelemetry": { + "LogLevel": { + "Azure.Cosmos.Operation.Request.Diagnostics": "Warning" + } + } + }, + "CosmosDBEndPointUrl": "https://localhost:8081", + "CosmosDBAuthorizationKey": "Super secret key", + "ApplicationInsightsConnectionString": "Super secret connection string" +} \ No newline at end of file diff --git a/Microsoft.Azure.Cosmos.Samples/Usage/OpenTelemetry/OpenTelemetry.csproj b/Microsoft.Azure.Cosmos.Samples/Usage/OpenTelemetry/OpenTelemetry.csproj index 20ddd0e96d..83224d4570 100644 --- a/Microsoft.Azure.Cosmos.Samples/Usage/OpenTelemetry/OpenTelemetry.csproj +++ b/Microsoft.Azure.Cosmos.Samples/Usage/OpenTelemetry/OpenTelemetry.csproj @@ -14,9 +14,11 @@ + - + PreserveNewest + diff --git a/Microsoft.Azure.Cosmos.Samples/Usage/OpenTelemetry/Program.cs b/Microsoft.Azure.Cosmos.Samples/Usage/OpenTelemetry/Program.cs index 8fb38c3fdb..b4729e41c7 100644 --- a/Microsoft.Azure.Cosmos.Samples/Usage/OpenTelemetry/Program.cs +++ b/Microsoft.Azure.Cosmos.Samples/Usage/OpenTelemetry/Program.cs @@ -28,13 +28,13 @@ static async Task Main() .AddJsonFile("AppSettings.json") .Build(); - string endpoint = configuration["EndPointUrl"]; + string endpoint = configuration["CosmosDBEndPointUrl"]; if (string.IsNullOrEmpty(endpoint)) { throw new ArgumentNullException("Please specify a valid CosmosDBEndPointUrl in the appSettings.json"); } - string authKey = configuration["AuthorizationKey"]; + string authKey = configuration["CosmosDBAuthorizationKey"]; if (string.IsNullOrEmpty(authKey) || string.Equals(authKey, "Super secret key")) { throw new ArgumentException("Please specify a valid CosmosDBAuthorizationKey in the appSettings.json"); diff --git a/Microsoft.Azure.Cosmos.Samples/Usage/appSettings.json b/Microsoft.Azure.Cosmos.Samples/Usage/appSettings.json index 8285d9b99e..64a8acc501 100644 --- a/Microsoft.Azure.Cosmos.Samples/Usage/appSettings.json +++ b/Microsoft.Azure.Cosmos.Samples/Usage/appSettings.json @@ -1,12 +1,4 @@ { "EndPointUrl": "https://localhost:8081", - "AuthorizationKey": "Super secret key", - "ApplicationInsightsConnectionString": "Super secret connection string", - "Logging": { - "OpenTelemetry": { - "LogLevel": { - "Azure.Cosmos.Operation.Request.Diagnostics": "Warning" - } - } - } + "AuthorizationKey": "Super secret key" }