-
Notifications
You must be signed in to change notification settings - Fork 272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow custom connection string names when creating a DurableClient in an ASP.NET Core app #1895
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is very close.
I have a couple of minor production code suggestions, and a few questions/suggestions about the tests.
src/WebJobs.Extensions.DurableTask/AzureStorageDurabilityProviderFactory.cs
Outdated
Show resolved
Hide resolved
@@ -41,7 +41,7 @@ public static IServiceCollection AddDurableClientFactory(this IServiceCollection | |||
} | |||
|
|||
serviceCollection.TryAddSingleton<INameResolver, DefaultNameResolver>(); | |||
serviceCollection.TryAddSingleton<IConnectionStringResolver, StandardConnectionStringProvider>(); | |||
serviceCollection.TryAddSingleton<IConnectionStringResolver, WebJobsConnectionStringProvider>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am a little concerned about changing this, just because some customers will be running in non-webjobs scenario.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I initially changed it because of this comment in the linked issue:
In addition when consuming this service via non web job (standard aspnet application) the extention method defaults to using the implementation of IConnectionStringProvider as StandardConnectionStringProvider.
After looking the source code it appears that the standard implementation would be better suited using WebJobsConnectionStringProvider this will locate connection string via both local.settings.json:Values:ConnString in webjob and appsettings.json:ConnectionStrings:ConnString in standard ASP.NET application and therefore feels like the naming convention of these implementations are reversed.
I can change it back to StandardConnectionStringProvider
. I looked through StandardConnectionStringProvider
and WebJobsConnectionStringProvider
to understand this comment and the only difference I see is that WebJobsConnectionStringProvider
evaluates configuration.GetConnectionString(connectionName)
first before configuration[connectionName]
. I'm not exactly clear on what configuration.GetConnectionString(connectionName)
does/where it looks for connection strings. Let me know if you think WebJobsConnectionStringProvider
is fine otherwise I'll change it to StandardConnectionStringProvider
Line 31 in cc7f8b2
return this.configuration[connectionStringName]; |
Line 29 in cc7f8b2
return this.hostConfiguration.GetWebJobsConnectionString(connectionStringName); |
src/WebJobs.Extensions.DurableTask/AzureStorageDurabilityProviderFactory.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
This PR allows customers to use custom app setting names to create a DurableClient in an ASP.NET Core app.
Currently, customers have to set
ConnectionName
to "Storage" inDurableClientOptions
because of this line in AzureStorageDurabilityProviderFactory.cs.connectionName
is always set to null which means that it's always set to thethis.defaultConnectionName
.this.defaultConnectionName
defaults to usingConnectionStringNames.Storage
which is "Storage" because this.azureStorageOptions.ConnectionStringName` is null in this flow.This PR passes the
ConnectionName
andTaskHub
name fromDurableClientOptions
toGetAzureStorageOrchestrationServiceSettings()
to create anAzureStorageDurabilityProvider
using the configured values instead of default values.Resolves #1656
Pull request checklist
pending_docs.md
release_notes.md