Skip to content

Commit

Permalink
Add extension methods for registering the SQL durability provider (#31)
Browse files Browse the repository at this point in the history
Also in this PR:
- Incremented version to v0.9.1-beta
- Updated dependencies
- Minor doc updates
  • Loading branch information
cgillum authored Jun 13, 2021
1 parent 41db91a commit d0eaeee
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 14 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

## v0.9.1-beta

### New

* Added extension method for Azure Functions service registration ([#31](https://github.com/microsoft/durabletask-mssql/pull/31))

### Updates

* Updated [Microsoft.Azure.WebJobs.Extensions.DurableTask](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.DurableTask) dependency to [v2.5.0](https://github.com/Azure/azure-functions-durable-extension/releases/tag/v2.5.0).
* Updated [Microsoft.Azure.DurableTask.Core](https://www.nuget.org/packages/Microsoft.Azure.DurableTask.Core) dependency to [v2.5.5](https://github.com/Azure/durabletask/releases/tag/durabletask.core-v2.5.5).

## v0.9.0-beta

### New
Expand Down
4 changes: 3 additions & 1 deletion docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ dotnet add package Microsoft.DurableTask.SqlServer.AzureFunctions --prerelease
JavaScript, Python, and PowerShell projects can add the [Microsoft.DurableTask.SqlServer.AzureFunction](https://www.nuget.org/packages/Microsoft.DurableTask.SqlServer.AzureFunctions) package by running the following `func` CLI command. Note that in addition to the Azure Functions Core Tools, you must also have a recent [.NET SDK](https://dotnet.microsoft.com/download/dotnet-core/3.1) installed locally.

```bash
func extensions install -p Microsoft.DurableTask.SqlServer.AzureFunctions -v 0.9.0-beta
func extensions install -p Microsoft.DurableTask.SqlServer.AzureFunctions -v 0.9.1-beta
```

?> Check [here](https://www.nuget.org/packages/Microsoft.DurableTask.SqlServer.AzureFunctions) to see if newer versions of the SQL provider package are available, and update the above command to reference the latest available version.
Expand Down Expand Up @@ -75,6 +75,8 @@ To enable diagnostic logging, you can also add the following `logging` configura

It is recommended to always configure the `DurableTask.*` log categories to at least `Warning` to ensure you have visibility into issues that might impact reliability and runtime performance.

?> By default, task hub names configured in host.json are ignored. Instead, the task hub name is inferred from the SQL database login username. For more information, see the [Task Hubs](taskhubs.md) documentation.

## Self-hosted .NET apps

The Durable SQL provider can also be used by Durable Task Framework (DTFx) apps targeting .NET Standard 2.0 and above. To reference the Durable SQL provider package for DTFx, uses the `dotnet` CLI to add a reference to the [Microsoft.DurableTask.SqlServer](https://www.nuget.org/packages/Microsoft.DurableTask.SqlServer/) package.
Expand Down
2 changes: 1 addition & 1 deletion docs/sidebar.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
* [Introduction](introduction.md "Durable Task SQL Provider")
* [Getting started](quickstart.md)
* [Getting Started](quickstart.md)
* [Architecture](architecture.md)
* [Scaling](scaling.md)
* [Task Hubs](taskhubs.md)
Expand Down
6 changes: 0 additions & 6 deletions src/DurableTask.SqlServer.AzureFunctions/AssemblyInfo.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.0.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.DurableTask" Version="2.4.3" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.DurableTask" Version="2.5.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

namespace DurableTask.SqlServer.AzureFunctions
{
using Microsoft.Azure.WebJobs.Extensions.DurableTask;
using Microsoft.Extensions.DependencyInjection;

/// <summary>
/// Extension methods for the Microsoft SQL Durable Task storage provider.
/// </summary>
public static class SqlDurabilityProviderExtensions
{
/// <summary>
/// Adds Durable Task SQL storage provider services to the specified <see cref="IServiceCollection"/>.
/// </summary>
/// <param name="services">The <see cref="IServiceCollection"/> for adding services.</param>
public static void AddDurableTaskSqlProvider(this IServiceCollection services)
{
services.AddSingleton<IDurabilityProviderFactory, SqlDurabilityProviderFactory>();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ namespace DurableTask.SqlServer.AzureFunctions
using Microsoft.Extensions.Options;
using Newtonsoft.Json;

/// <summary>
/// Microsoft SQL <see cref="IDurabilityProviderFactory"/> implementation for Durable Tasks in Azure Functions.
/// </summary>
class SqlDurabilityProviderFactory : IDurabilityProviderFactory
{
readonly Dictionary<string, DurabilityProvider> clientProviders =
Expand All @@ -25,7 +28,15 @@ class SqlDurabilityProviderFactory : IDurabilityProviderFactory
SqlOrchestrationService? service;
SqlDurabilityProvider? defaultProvider;

// Called by the Azure Functions runtime dependency injection infrastructure
/// <summary>
/// Initializes a new instance of the <see cref="SqlDurabilityProviderFactory"/> class.
/// </summary>
/// <remarks>
/// Intended to be called by the Azure Functions runtime dependency injection infrastructure.
/// </remarks>
/// <param name="extensionOptions">Durable task extension configuration options.</param>
/// <param name="loggerFactory">Logger factory registered with the Azure Functions runtime.</param>
/// <param name="connectionStringResolver">Resolver service for fetching Durable Task connection string information.</param>
public SqlDurabilityProviderFactory(
IOptions<DurableTaskOptions> extensionOptions,
ILoggerFactory loggerFactory,
Expand Down
2 changes: 1 addition & 1 deletion src/DurableTask.SqlServer/DurableTask.SqlServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<ItemGroup>
<PackageReference Include="Azure.Identity" Version="1.4.0" />
<PackageReference Include="Microsoft.Azure.DurableTask.Core" Version="2.5.1" />
<PackageReference Include="Microsoft.Azure.DurableTask.Core" Version="2.5.5" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="3.1.*" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="3.1.*" />
<PackageReference Include="Microsoft.SqlServer.SqlManagementObjects" Version="161.46041.41" />
Expand Down
2 changes: 1 addition & 1 deletion src/common.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<!-- Version settings: https://andrewlock.net/version-vs-versionsuffix-vs-packageversion-what-do-they-all-mean/ -->
<PropertyGroup>
<MajorVersion>0</MajorVersion>
<VersionPrefix>$(MajorVersion).9.0</VersionPrefix>
<VersionPrefix>$(MajorVersion).9.1</VersionPrefix>
<VersionSuffix>beta</VersionSuffix>
<AssemblyVersion>$(MajorVersion).0.0.0</AssemblyVersion>
<BuildSuffix Condition="'$(GITHUB_RUN_NUMBER)' != ''">.$(GITHUB_RUN_NUMBER)</BuildSuffix>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public IntegrationTestBase(ITestOutputHelper output)
{
webJobsBuilder.AddDurableTask(options =>
{
options.StorageProvider["type"] = SqlDurabilityProvider.Name;
options.StorageProvider["type"] = "mssql";
});
})
.ConfigureServices(
Expand All @@ -57,7 +57,7 @@ public IntegrationTestBase(ITestOutputHelper output)
services.AddSingleton<INameResolver>(this.settingsResolver);
services.AddSingleton<IConnectionStringResolver>(this.settingsResolver);
services.AddSingleton<ITypeLocator>(this.typeLocator);
services.AddSingleton<IDurabilityProviderFactory, SqlDurabilityProviderFactory>();
services.AddDurableTaskSqlProvider();
})
.Build();

Expand Down

0 comments on commit d0eaeee

Please sign in to comment.