Skip to content

Commit fba7686

Browse files
authored
Add client authentication code sample to Monitor Query README (#24311)
1 parent 6e51f6c commit fba7686

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

sdk/monitor/Azure.Monitor.Query/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ dotnet add package Azure.Monitor.Query
3232

3333
An authenticated client is required to query Logs or Metrics. To authenticate, create an instance of a [TokenCredential](https://docs.microsoft.com/dotnet/api/azure.core.tokencredential?view=azure-dotnet) class. Pass it to the constructor of your `LogsQueryClient` or `MetricsQueryClient` class.
3434

35+
To authenticate, the following examples use `DefaultAzureCredential` from the [Azure.Identity](https://www.nuget.org/packages/Azure.Identity) package:
36+
37+
```C# Snippet:CreateLogsClient
38+
var client = new LogsQueryClient(new DefaultAzureCredential());
39+
```
40+
41+
```C# Snippet:CreateMetricsClient
42+
var metricsClient = new MetricsQueryClient(new DefaultAzureCredential());
43+
```
44+
3545
### Execute the query
3646

3747
For examples of Logs and Metrics queries, see the [Examples](#examples) section.

0 commit comments

Comments
 (0)