Skip to content

Commit

Permalink
fix appsettings
Browse files Browse the repository at this point in the history
  • Loading branch information
sourabh1007 committed Aug 9, 2023
1 parent 833e5bd commit 567ca55
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 43 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<AssemblyName>Cosmos.Samples.ApplicationInsights</AssemblyName>
<RootNamespace>Cosmos.Samples.ApplicationInsights</RootNamespace>
<LangVersion>latest</LangVersion>
</PropertyGroup>

Expand All @@ -15,11 +13,9 @@
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.2.0" />
</ItemGroup>

<ItemGroup>
<None Include="AppSettings.json" Link="AppSettings.json">
<None Include="..\AppSettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@
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
{
Expand All @@ -26,13 +24,13 @@ static async Task Main()
.AddJsonFile("AppSettings.json")
.Build();

string endpoint = configuration["CosmosDBEndPointUrl"];
string endpoint = configuration["EndPointUrl"];
if (string.IsNullOrEmpty(endpoint))
{
throw new ArgumentNullException("Please specify a valid CosmosDBEndPointUrl in the appSettings.json");
}

string authKey = configuration["CosmosDBAuthorizationKey"];
string authKey = configuration["AuthorizationKey"];
if (string.IsNullOrEmpty(authKey) || string.Equals(authKey, "Super secret key"))
{
throw new ArgumentException("Please specify a valid CosmosDBAuthorizationKey in the appSettings.json");
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
Expand All @@ -12,9 +12,8 @@
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.0" />
</ItemGroup>

<ItemGroup>
<None Include="AppSettings.json" Link="AppSettings.json">
<None Include="..\AppSettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
namespace Cosmos.Samples.ApplicationInsights
{
using System.Net;
using Microsoft.Azure.Cosmos;
using Microsoft.Extensions.Configuration;
using Newtonsoft.Json;
Expand All @@ -17,13 +16,13 @@ static async Task Main()
.AddJsonFile("AppSettings.json")
.Build();

string endpoint = configuration["CosmosDBEndPointUrl"];
string endpoint = configuration["EndPointUrl"];
if (string.IsNullOrEmpty(endpoint))
{
throw new ArgumentNullException("Please specify a valid CosmosDBEndPointUrl in the appSettings.json");
}

string authKey = configuration["CosmosDBAuthorizationKey"];
string authKey = configuration["AuthorizationKey"];
if (string.IsNullOrEmpty(authKey) || string.Equals(authKey, "Super secret key"))
{
throw new ArgumentException("Please specify a valid CosmosDBAuthorizationKey in the appSettings.json");
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@
<PackageReference Include="Microsoft.Extensions.Azure" Version="1.6.3" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.2.0" />
</ItemGroup>

<ItemGroup>
<None Include="AppSettings.json" Link="AppSettings.json">
<None Include="..\AppSettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions Microsoft.Azure.Cosmos.Samples/Usage/OpenTelemetry/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ static async Task Main()
.AddJsonFile("AppSettings.json")
.Build();

string endpoint = configuration["CosmosDBEndPointUrl"];
string endpoint = configuration["EndPointUrl"];
if (string.IsNullOrEmpty(endpoint))
{
throw new ArgumentNullException("Please specify a valid CosmosDBEndPointUrl in the appSettings.json");
}

string authKey = configuration["CosmosDBAuthorizationKey"];
string authKey = configuration["AuthorizationKey"];
if (string.IsNullOrEmpty(authKey) || string.Equals(authKey, "Super secret key"))
{
throw new ArgumentException("Please specify a valid CosmosDBAuthorizationKey in the appSettings.json");
Expand Down
10 changes: 9 additions & 1 deletion Microsoft.Azure.Cosmos.Samples/Usage/appSettings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
{
"EndPointUrl": "https://localhost:8081",
"AuthorizationKey": "Super secret key"
"AuthorizationKey": "Super secret key",
"ApplicationInsightsConnectionString": "Super secret connection string",
"Logging": {
"OpenTelemetry": {
"LogLevel": {
"Azure.Cosmos.Operation.Request.Diagnostics": "Warning"
}
}
}
}

0 comments on commit 567ca55

Please sign in to comment.