Skip to content

Commit 3dc7276

Browse files
author
Connor McMahon
authored
Expose AddDurableTaskFactory methodss to .NET Framework release (#1653)
* Expose AddDurableTaskFactory methodss to .NET Framework release Some customers with .NET Framework apps may be using the IServiceCollection dependency injection model for their applications, so these extension methods should be exposed for that scenario. For a future release, we should expose a simple static method to create an instance of IDurableClientFactory so .NET Framework apps using other dependency injection methods can still take advantage of the new external client work. * Add PR number to release notes
1 parent 1793866 commit 3dc7276

File tree

4 files changed

+46
-44
lines changed

4 files changed

+46
-44
lines changed

release_notes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<!-- Please put your changes into the appropriate category (or categories) below. -->
22

33
## New Features
4+
- Exposed IServiceCollection extension methods AddDurableTaskFactory() for net461 releases so classic .NET Framework apps using the .NET Core model of dependency injection can create their own Durable Clients. (#1653)
45

56
## Bug fixes
67
- Remove incorrect information from C# docs summary for IDurableEntityClient.ReadEntityStateAsync() regarding states large than 16KB (#1637)
78
- Fix a NullReferenceException in IDurableClient.SignalClient() for IDurableClient objects created by the new DurabilityClientFactory (#1644)
89

9-
1010
## Breaking changes
1111

1212

src/WebJobs.Extensions.DurableTask/DurableTaskJobHostConfigurationExtensions.cs

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@
1313
using Microsoft.Extensions.Hosting;
1414
using Microsoft.Extensions.Options;
1515
#else
16+
using Microsoft.Azure.WebJobs.Extensions.DurableTask.ContextImplementations;
17+
using Microsoft.Azure.WebJobs.Extensions.DurableTask.Options;
1618
using Microsoft.Azure.WebJobs.Host;
1719
using Microsoft.Azure.WebJobs.Host.Config;
20+
using Microsoft.Extensions.DependencyInjection;
21+
using Microsoft.Extensions.DependencyInjection.Extensions;
1822
#endif
1923

2024
namespace Microsoft.Azure.WebJobs.Extensions.DurableTask
@@ -24,36 +28,6 @@ namespace Microsoft.Azure.WebJobs.Extensions.DurableTask
2428
/// </summary>
2529
public static class DurableTaskJobHostConfigurationExtensions
2630
{
27-
#if !FUNCTIONS_V1
28-
/// <summary>
29-
/// Adds the Durable Task extension to the provided <see cref="IWebJobsBuilder"/>.
30-
/// </summary>
31-
/// <param name="builder">The <see cref="IWebJobsBuilder"/> to configure.</param>
32-
/// <returns>Returns the provided <see cref="IWebJobsBuilder"/>.</returns>
33-
public static IWebJobsBuilder AddDurableTask(this IWebJobsBuilder builder)
34-
{
35-
if (builder == null)
36-
{
37-
throw new ArgumentNullException(nameof(builder));
38-
}
39-
40-
var serviceCollection = builder.AddExtension<DurableTaskExtension>()
41-
.BindOptions<DurableTaskOptions>()
42-
.Services.AddSingleton<IConnectionStringResolver, WebJobsConnectionStringProvider>();
43-
44-
serviceCollection.TryAddSingleton<IDurableHttpMessageHandlerFactory, DurableHttpMessageHandlerFactory>();
45-
serviceCollection.TryAddSingleton<IDurabilityProviderFactory, AzureStorageDurabilityProviderFactory>();
46-
serviceCollection.TryAddSingleton<IMessageSerializerSettingsFactory, MessageSerializerSettingsFactory>();
47-
serviceCollection.TryAddSingleton<IErrorSerializerSettingsFactory, ErrorSerializerSettingsFactory>();
48-
serviceCollection.TryAddSingleton<IApplicationLifetimeWrapper, HostLifecycleService>();
49-
#if !FUNCTIONS_V1
50-
serviceCollection.AddSingleton<ITelemetryActivator, TelemetryActivator>();
51-
#endif
52-
serviceCollection.TryAddSingleton<IDurableClientFactory, DurableClientFactory>();
53-
54-
return builder;
55-
}
56-
5731
/// <summary>
5832
/// Adds the Durable Task extension to the provided <see cref="IServiceCollection"/>.
5933
/// </summary>
@@ -88,6 +62,34 @@ public static IServiceCollection AddDurableClientFactory(this IServiceCollection
8862
return serviceCollection;
8963
}
9064

65+
#if !FUNCTIONS_V1
66+
/// <summary>
67+
/// Adds the Durable Task extension to the provided <see cref="IWebJobsBuilder"/>.
68+
/// </summary>
69+
/// <param name="builder">The <see cref="IWebJobsBuilder"/> to configure.</param>
70+
/// <returns>Returns the provided <see cref="IWebJobsBuilder"/>.</returns>
71+
public static IWebJobsBuilder AddDurableTask(this IWebJobsBuilder builder)
72+
{
73+
if (builder == null)
74+
{
75+
throw new ArgumentNullException(nameof(builder));
76+
}
77+
78+
var serviceCollection = builder.AddExtension<DurableTaskExtension>()
79+
.BindOptions<DurableTaskOptions>()
80+
.Services.AddSingleton<IConnectionStringResolver, WebJobsConnectionStringProvider>();
81+
82+
serviceCollection.TryAddSingleton<IDurableHttpMessageHandlerFactory, DurableHttpMessageHandlerFactory>();
83+
serviceCollection.TryAddSingleton<IDurabilityProviderFactory, AzureStorageDurabilityProviderFactory>();
84+
serviceCollection.TryAddSingleton<IMessageSerializerSettingsFactory, MessageSerializerSettingsFactory>();
85+
serviceCollection.TryAddSingleton<IErrorSerializerSettingsFactory, ErrorSerializerSettingsFactory>();
86+
serviceCollection.TryAddSingleton<IApplicationLifetimeWrapper, HostLifecycleService>();
87+
serviceCollection.AddSingleton<ITelemetryActivator, TelemetryActivator>();
88+
serviceCollection.TryAddSingleton<IDurableClientFactory, DurableClientFactory>();
89+
90+
return builder;
91+
}
92+
9193
/// <summary>
9294
/// Adds the Durable Task extension to the provided <see cref="IWebJobsBuilder"/>.
9395
/// </summary>

src/WebJobs.Extensions.DurableTask/Microsoft.Azure.WebJobs.Extensions.DurableTask.xml

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/Common/InterfaceOverloadTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace Microsoft.Azure.WebJobs.Extensions.DurableTask.Tests
1111
/// Tests to make sure that calls to interface methods with closely related overloads
1212
/// do not change as we add/tweak methods on the interfaces.
1313
///
14-
/// TODO: Add more tests: https://github.com/Azure/azure-functions-durable-extension/issues/1500
14+
/// TODO: Add more tests: https://github.com/Azure/azure-functions-durable-extension/issues/1500.
1515
/// </summary>
1616
public class InterfaceOverloadTests
1717
{

0 commit comments

Comments
 (0)