-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Azure.Monitor.Query] Add Extensions (#34968)
* wip * wip * wip
- Loading branch information
1 parent
296af20
commit a9a133a
Showing
6 changed files
with
83 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
sdk/monitor/Azure.Monitor.Query/src/LogsQueryClientBuilderExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using Azure.Core.Extensions; | ||
using Azure.Monitor.Query; | ||
|
||
namespace Microsoft.Extensions.Azure | ||
{ | ||
/// <summary> Extension methods to add <see cref="LogsQueryClient"/> to client builder. </summary> | ||
public static class LogsQueryClientBuilderExtensions | ||
{ | ||
/// <summary> Registers a <see cref="LogsQueryClient"/> instance. </summary> | ||
/// <param name="builder"> The builder to register with. </param> | ||
/// <param name="endpoint"> The resource manager service endpoint to use. For example <c>https://management.azure.com/</c> for public cloud. </param> | ||
public static IAzureClientBuilder<LogsQueryClient, LogsQueryClientOptions> AddLogsQueryClient<TBuilder>(this TBuilder builder, Uri endpoint) | ||
where TBuilder : IAzureClientFactoryBuilderWithCredential | ||
{ | ||
return builder.RegisterClientFactory<LogsQueryClient, LogsQueryClientOptions>((options, cred) => new LogsQueryClient(endpoint, cred, options)); | ||
} | ||
|
||
/// <summary> Registers a <see cref="LogsQueryClient"/> instance. </summary> | ||
/// <param name="builder"> The builder to register with. </param> | ||
/// <param name="configuration"> The configuration values. </param> | ||
public static IAzureClientBuilder<LogsQueryClient, LogsQueryClientOptions> AddLogsQueryClient<TBuilder, TConfiguration>(this TBuilder builder, TConfiguration configuration) | ||
where TBuilder : IAzureClientFactoryBuilderWithConfiguration<TConfiguration> | ||
{ | ||
return builder.RegisterClientFactory<LogsQueryClient, LogsQueryClientOptions>(configuration); | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
sdk/monitor/Azure.Monitor.Query/src/MetricsQueryClientBuilderExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using Azure.Core.Extensions; | ||
using Azure.Monitor.Query; | ||
|
||
namespace Microsoft.Extensions.Azure | ||
{ | ||
/// <summary> Extension methods to add <see cref="MetricsQueryClient"/> to client builder. </summary> | ||
public static class MetricsQueryClientBuilderExtensions | ||
{ | ||
/// <summary> Registers a <see cref="MetricsQueryClient"/> instance. </summary> | ||
/// <param name="builder"> The builder to register with. </param> | ||
/// <param name="endpoint"> The resource manager service endpoint to use. For example <c>https://management.azure.com/</c> for public cloud. </param> | ||
public static IAzureClientBuilder<MetricsQueryClient, MetricsQueryClientOptions> AddMetricsQueryClient<TBuilder>(this TBuilder builder, Uri endpoint) | ||
where TBuilder : IAzureClientFactoryBuilderWithCredential | ||
{ | ||
return builder.RegisterClientFactory<MetricsQueryClient, MetricsQueryClientOptions>((options, cred) => new MetricsQueryClient(endpoint, cred, options)); | ||
} | ||
|
||
/// <summary> Registers a <see cref="MetricsQueryClient"/> instance. </summary> | ||
/// <param name="builder"> The builder to register with. </param> | ||
/// <param name="configuration"> The configuration values. </param> | ||
public static IAzureClientBuilder<MetricsQueryClient, MetricsQueryClientOptions> AddMetricsQueryClient<TBuilder, TConfiguration>(this TBuilder builder, TConfiguration configuration) | ||
where TBuilder : IAzureClientFactoryBuilderWithConfiguration<TConfiguration> | ||
{ | ||
return builder.RegisterClientFactory<MetricsQueryClient, MetricsQueryClientOptions>(configuration); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters