-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
App builder extension method to register extension options (#1843)
--------- Co-authored-by: Jacob Viau <[email protected]>
- Loading branch information
1 parent
c1ee4a0
commit 170945f
Showing
14 changed files
with
131 additions
and
42 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
35 changes: 35 additions & 0 deletions
35
.../Worker.Extensions.CosmosDB/src/Extensions/FunctionsWorkerApplicationBuilderExtensions.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,35 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
||
using Microsoft.Extensions.Azure; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.DependencyInjection.Extensions; | ||
using Microsoft.Extensions.Options; | ||
|
||
namespace Microsoft.Azure.Functions.Worker | ||
{ | ||
/// <summary> | ||
/// Provides extension methods to work with a <see cref="IFunctionsWorkerApplicationBuilder"/>. | ||
/// </summary> | ||
public static class FunctionsWorkerApplicationBuilderExtensions | ||
{ | ||
/// <summary> | ||
/// Configures the CosmosDB extension. | ||
/// </summary> | ||
/// <param name="builder">The <see cref="IFunctionsWorkerApplicationBuilder"/> to configure.</param> | ||
/// <returns>The same instance of the <see cref="IFunctionsWorkerApplicationBuilder"/> for chaining.</returns> | ||
public static IFunctionsWorkerApplicationBuilder ConfigureCosmosDBExtension(this IFunctionsWorkerApplicationBuilder builder) | ||
{ | ||
if (builder is null) | ||
{ | ||
throw new System.ArgumentNullException(nameof(builder)); | ||
} | ||
|
||
builder.Services.AddAzureClientsCore(); // Adds AzureComponentFactory | ||
builder.Services.AddOptions<CosmosDBBindingOptions>(); | ||
builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IConfigureOptions<CosmosDBBindingOptions>, CosmosDBBindingOptionsSetup>()); | ||
|
||
return builder; | ||
} | ||
} | ||
} |
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
35 changes: 35 additions & 0 deletions
35
...er.Extensions.Storage.Blobs/src/Extensions/FunctionsWorkerApplicationBuilderExtensions.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,35 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
||
using Microsoft.Extensions.Azure; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.DependencyInjection.Extensions; | ||
using Microsoft.Extensions.Options; | ||
|
||
namespace Microsoft.Azure.Functions.Worker | ||
{ | ||
/// <summary> | ||
/// Provides extension methods to work with a <see cref="IFunctionsWorkerApplicationBuilder"/>. | ||
/// </summary> | ||
public static class FunctionsWorkerApplicationBuilderExtensions | ||
{ | ||
/// <summary> | ||
/// Configures the CosmosDB extension. | ||
/// </summary> | ||
/// <param name="builder">The <see cref="IFunctionsWorkerApplicationBuilder"/> to configure.</param> | ||
/// <returns>The same instance of the <see cref="IFunctionsWorkerApplicationBuilder"/> for chaining.</returns> | ||
public static IFunctionsWorkerApplicationBuilder ConfigureBlobStorageExtension(this IFunctionsWorkerApplicationBuilder builder) | ||
{ | ||
if (builder is null) | ||
{ | ||
throw new System.ArgumentNullException(nameof(builder)); | ||
} | ||
|
||
builder.Services.AddAzureClientsCore(); // Adds AzureComponentFactory | ||
builder.Services.AddOptions<BlobStorageBindingOptions>(); | ||
builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IConfigureOptions<BlobStorageBindingOptions>, BlobStorageBindingOptionsSetup>()); | ||
|
||
return builder; | ||
} | ||
} | ||
} |
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
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
36 changes: 36 additions & 0 deletions
36
...ns/Worker.Extensions.Tables/src/Extensions/FunctionsWorkerApplicationBuilderExtensions.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,36 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
||
using Microsoft.Azure.Functions.Worker.Extensions.Tables.Config; | ||
using Microsoft.Extensions.Azure; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.DependencyInjection.Extensions; | ||
using Microsoft.Extensions.Options; | ||
|
||
namespace Microsoft.Azure.Functions.Worker | ||
{ | ||
/// <summary> | ||
/// Provides extension methods to work with a <see cref="IFunctionsWorkerApplicationBuilder"/>. | ||
/// </summary> | ||
public static class FunctionsWorkerApplicationBuilderExtensions | ||
{ | ||
/// <summary> | ||
/// Configures the CosmosDB extension. | ||
/// </summary> | ||
/// <param name="builder">The <see cref="IFunctionsWorkerApplicationBuilder"/> to configure.</param> | ||
/// <returns>The same instance of the <see cref="IFunctionsWorkerApplicationBuilder"/> for chaining.</returns> | ||
public static IFunctionsWorkerApplicationBuilder ConfigureTablesExtension(this IFunctionsWorkerApplicationBuilder builder) | ||
{ | ||
if (builder is null) | ||
{ | ||
throw new System.ArgumentNullException(nameof(builder)); | ||
} | ||
|
||
builder.Services.AddAzureClientsCore(); // Adds AzureComponentFactory | ||
builder.Services.AddOptions<TablesBindingOptions>(); | ||
builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IConfigureOptions<TablesBindingOptions>, TablesBindingOptionsSetup>()); | ||
|
||
return builder; | ||
} | ||
} | ||
} |
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