After deploying ASP.NET Core app to azure and opening the site, I get the following error:
InvalidOperationException: Could not find \'UserSecretsIdAt
My .NET Core 3.* Worker Service required additional setup over a Web project.
In Program.cs in the CreateHostBuilder method I needed this:
.ConfigureAppConfiguration((ctx, builder) =>
{
// enable secrets in development
if (ctx.HostingEnvironment.IsDevelopment())
{
builder.AddUserSecrets();
}
})
But (unlike my Web project) I explicitly needed to add this nuget package:
install-package Microsoft.Extensions.Configuration.UserSecrets
After that I could access the secrets.