-
Notifications
You must be signed in to change notification settings - Fork 21
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
Adding secrets as part of ConfigurationBuilder #57
Comments
We've also encountered this problem when trying to use Dapr Secrets with Sidekick. The fundamental problem is that some services may need access to the secrets during startup, hence the docs advising that it be configured in the Without having yet dug into this issue further, it seems that Sidekick needs to be able to start the Sidecar process inside the I'm also wondering on the health of this project considering that there has been no apparent activity on this GitHub repository in months. |
I have the same problem as well, cant see any way to start it immediately at the beginning of the Program.cs Might fork this and sort out the work dir issue as well as I would like to load secrets from local file secretstores for local dev and this doesnt allow it |
Okay I have a little update. I managed to write a working solution using the existing released version of sidekick.
|
relevant PR #59 |
Just a quick note (and apology) for tardiness of responses from the maintainers on this issue. While we do consider this project maintained and active, Sidekick has been working fine for us internally for a while so we haven't needed to make any changes and there have been workarounds for most reported issues. We'll continue to accept and review contributions/PR's and prepare point releases including those changes as needed. Additionally we are about to start evaluating newer versions of Dapr and its features which will no doubt lead to some enhancements (such as proper support for bootstrapping secrets). |
Expected Behavior
I add configuration from from secrets through ConfigurationBuilder.
var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
var configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddJsonFile($"appsettings.{environment}.json", optional: true, reloadOnChange: true)
.AddDaprSecretStore("secret-store", daprClient)
.Build();
The issue is that these seems to happen before sidekick "kicks" in. So it is unable to find the secrets configuration. Because you add sidekick as part of ConfigureServices. I was able to work around this to setup the configuration as part of the
So what this should do is load all the secrets into the configuration so if you have let's say json configuration like this:
"SimpleConfigTest": {
"ConfigValue": "Not from secrets"
}
And in the secrets you have:
"SimpleConfigTest": {
"SecretValue": "From secrets"
}
And we could have like a SimpleConfigText object that is added to DI with the IOptions pattern.
services.Configure(configuration.GetSection("SimpleConfigTest"));
The biggest point is that this works with Dapr and the objects are initialized and works without sidekick.
To reproduce, create a secret store. I have a local secret store right now for development. Setup configuration to pull from the secret store.
Below is the stack trace seen.. Thanks!
at System.Net.Http.HttpClient.HandleFailure(Exception e, Boolean telemetryStarted, HttpResponseMessage response, CancellationTokenSource cts, CancellationToken cancellationToken, CancellationTokenSource pendingRequestsCts)
at System.Net.Http.HttpClient.<g__Core|83_0>d.MoveNext()
at Dapr.Client.DaprClientGrpc.d__60.MoveNext()
at Dapr.Client.DaprClientGrpc.d__61.MoveNext()
at Dapr.Extensions.Configuration.DaprSecretStore.DaprSecretStoreConfigurationProvider.d__16.MoveNext() in //src/Dapr.Extensions.Configuration/DaprSecretStoreConfigurationProvider.cs:line 193
at Dapr.Extensions.Configuration.DaprSecretStore.DaprSecretStoreConfigurationProvider.Load() in //src/Dapr.Extensions.Configuration/DaprSecretStoreConfigurationProvider.cs:line 184
at Microsoft.Extensions.Configuration.ConfigurationRoot..ctor(IList`1 providers) in //src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationRoot.cs:line 36
at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build() in //src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationBuilder.cs:line 54
at Cmp.Api.Program.CreateWebHostBuilder(String[] args) in C:\projects\nova.api\Nova.Api\Program.cs:line 25
at Cmp.Api.Program.Main(String[] args) in C:\projects\nova.api\Nova.Api\Program.cs:line 14
The text was updated successfully, but these errors were encountered: