Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Internal] Usage: Add README.md for usage samples #4069

Merged
merged 27 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ecddd95
issues/1238 add README.md for ApplicationInsights usage
Sep 5, 2023
b3f00c2
issues/1238 add README.md for ApplicationInsights usage
Sep 5, 2023
d55850c
Merge branch 'users/v-dchaava/add-usage-readmi/1238' of https://githu…
Sep 6, 2023
2631f35
Merge branch 'master' into users/v-dchaava/add-usage-readmi/1238
tangerinous Sep 6, 2023
f112e18
modified: Microsoft.Azure.Cosmos.Samples/Usage/AzureFunctions/READ…
Sep 7, 2023
9c82e1f
Update Microsoft.Azure.Cosmos.Samples/Usage/AzureFunctions/README.md
tangerinous Sep 7, 2023
e1dbd07
add BulkExecutorMigration README.md
Sep 7, 2023
5ee6d2e
Merge branch 'users/v-dchaava/add-usage-readmi/1238' of https://githu…
Sep 7, 2023
694d416
add BulkSupport README
Sep 7, 2023
a0c554d
add BulkSupport README
Sep 7, 2023
22b8500
Async main requires c# 7.1 which is set in the csproj with the LangVe…
Sep 11, 2023
86927de
add README.md for usage projects
Sep 12, 2023
efa1cf7
Update Microsoft.Azure.Cosmos.Samples/Usage/AzureFunctions/README.md
tangerinous Sep 12, 2023
fd49959
Merge branch 'master' into users/v-dchaava/add-usage-readmi/1238
tangerinous Sep 13, 2023
6dceb14
Update Microsoft.Azure.Cosmos.Samples/Usage/CustomSerialization/READM…
tangerinous Sep 13, 2023
d1e575a
Update Microsoft.Azure.Cosmos.Samples/Usage/CustomDiagnosticAndEventL…
tangerinous Sep 13, 2023
dfea0c2
Update Microsoft.Azure.Cosmos.Samples/Usage/AzureFunctions/README.md
tangerinous Sep 13, 2023
d3ee849
Update Microsoft.Azure.Cosmos.Samples/Usage/CustomSerialization/READM…
tangerinous Sep 13, 2023
a1ce384
Update Microsoft.Azure.Cosmos.Samples/Usage/BulkSupport/README.md
tangerinous Sep 13, 2023
7e87de2
Update Microsoft.Azure.Cosmos.Samples/Usage/AzureFunctions/README.md
tangerinous Sep 13, 2023
db329f3
Update Microsoft.Azure.Cosmos.Samples/Usage/BulkExecutorMigration/REA…
tangerinous Sep 13, 2023
cf29a71
Update Microsoft.Azure.Cosmos.Samples/Usage/ContainerManagement/READM…
tangerinous Sep 13, 2023
ae8c880
Update README.md
ealsur Oct 11, 2023
cf59db8
Merge branch 'master' into users/v-dchaava/add-usage-readmi/1238
ealsur Oct 11, 2023
ba13375
Merge branch 'master' into users/v-dchaava/add-usage-readmi/1238
kirankumarkolli Sep 13, 2024
8694f0a
Merge branch 'master' into users/v-dchaava/add-usage-readmi/1238
kirankumarkolli Oct 6, 2024
65851ba
Merge branch 'master' into users/v-dchaava/add-usage-readmi/1238
kirankumarkolli Oct 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Integrate ApplicationInsights with Cosmos DB

This project provides a demo showcasing the usage of the integrating ApplicationInsights with Cosmos DB. The goal is to trace requests.

## Prerequisites

- Azure Cosmos DB NoSQL Account
- Create a DataBase and Container
- Azure ApplicationInsights Account
- Create a Azure ApplicationInsights account

## Run

Before running the application you need fill out `CosmosDBEndPointUrl`, `CosmosDBAuthorizationKey` and `ApplicationInsightsConnectionString` params in the [AppSettings.json](AppSettings.json)

```PowerShell
dotnet run
```

## Getting Started

### Configure Application Insights Telemetry

```C#
// <SetUpApplicationInsights>
ealsur marked this conversation as resolved.
Show resolved Hide resolved
IServiceCollection services = new ServiceCollection();
services.AddApplicationInsightsTelemetryWorkerService((ApplicationInsightsServiceOptions options) => options.ConnectionString = aiConnectionString);

IServiceProvider serviceProvider = services.BuildServiceProvider();
_telemetryClient = serviceProvider.GetRequiredService<TelemetryClient>();
// </SetUpApplicationInsights>
```

### Prepare Client, Database and Container

```C#
using (CosmosClient client = new CosmosClient(endpoint, authKey, options))
{
Console.WriteLine($"Getting container reference for {containerName}.");

ContainerProperties properties = new ContainerProperties(containerName, partitionKeyPath: "/id");

await client.CreateDatabaseIfNotExistsAsync(databaseName);
Container container = await client.GetDatabase(databaseName).CreateContainerIfNotExistsAsync(properties);

await Program.RunCrudDemo(container);
}
```

### Flush telemetry data

```C#
_telemetryClient?.Flush();
```

### Check captured telemetry in Application Insights

![Alt text](image.png)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading