microsoft / durabletask-mssql

Microsoft SQL storage provider for Durable Functions and the Durable Task Framework
MIT License
87 stars 32 forks source link

Add extension methods for registering the SQL durability provider #31

Closed cgillum closed 3 years ago

cgillum commented 3 years ago

Resolves #30

This PR adds an extension method to register the Durable Task SQL storage provider for Azure Functions (and Azure Web Jobs).

Here is an example of how we register the SQL provider in our integration tests.

this.functionsHost = new HostBuilder()
    .ConfigureLogging(
        loggingBuilder =>
        {
            loggingBuilder.AddProvider(this.logProvider);
            loggingBuilder.SetMinimumLevel(LogLevel.Information);
        })
    .ConfigureWebJobs(
        webJobsBuilder =>
        {
            webJobsBuilder.AddDurableTask(options =>
            {
                options.StorageProvider["type"] = "mssql";
            });
        })
    .ConfigureServices(
        services =>
        {
            services.AddSingleton<INameResolver>(this.settingsResolver);
            services.AddSingleton<IConnectionStringResolver>(this.settingsResolver);
            services.AddSingleton<ITypeLocator>(this.typeLocator);
            services.AddDurableTaskSqlProvider();
        })
    .Build();

Also in this PR: