dapr / dotnet-sdk

Dapr SDK for .NET
Apache License 2.0
1.11k stars 331 forks source link

AddDaprSecretStore always times out #983

Open lsoft-bho opened 1 year ago

lsoft-bho commented 1 year ago

I have services deployed in Azure Container Apps with Dapr enabled. I'm trying to add a secrret store to the configuration like this:

builder.Services.AddDaprClient();

if (!string.IsNullOrEmpty(builder.Configuration["SecretStore"]))
{
    var timeout = builder.Configuration.GetValue("DaprSidecarTimeout", 5);
    using var sp = builder.Services.BuildServiceProvider();
    builder.Configuration.AddDaprSecretStore(builder.Configuration["SecretStore"], sp.GetRequiredService<DaprClient>(), TimeSpan.FromSeconds(timeout));
}

This works locally running with docker compose, but in the container app this always creates the following exception:

Unhandled exception. System.Threading.Tasks.TaskCanceledException: A task was canceled.
at Dapr.Client.DaprClientGrpc.WaitForSidecarAsync(CancellationToken cancellationToken)
at Dapr.Extensions.Configuration.DaprSecretStore.DaprSecretStoreConfigurationProvider.LoadAsync()
at Dapr.Extensions.Configuration.DaprSecretStore.DaprSecretStoreConfigurationProvider.Load()
at Microsoft.Extensions.Configuration.ConfigurationManager.AddSource(IConfigurationSource source)
at Microsoft.Extensions.Configuration.ConfigurationManager.Microsoft.Extensions.Configuration.IConfigurationBuilder.Add(IConfigurationSource source)
...

I have tried with timeouts of up to one minute.

Is there some configuration I am missing that I should have set?

m1t0k commented 1 year ago

I had the same issue, fixed in docker-compose.yml file by adding network_mode:

test-api: ... ... test-api-dapr: ..... depends_on:

lsoft-bho commented 1 year ago

Thank you for your answer @m1t0k, but you misunterstood my problem. It is working with docker-compose - it is not working in Azure Container Apps.

dmitriy-pisarevskiy commented 1 year ago

@isoft-bho locally too, when I use dapr init --slim or local install

Exception thrown: 'System.Threading.Tasks.TaskCanceledException' in System.Private.CoreLib.dll
An exception of type 'System.Threading.Tasks.TaskCanceledException' occurred in System.Private.CoreLib.dll but was not handled in user code
A task was canceled.