question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Loading settings from User Secrets doesn't work

See original GitHub issue

User Secrets are supposed to be working but they don’t.

When trying to move settings from local.settings.json to User Secrets, the following error is happening:

image

Azure Functions Core Tools Core Tools Version: 3.0.3233 Commit hash: d1772f733802122a326fa696dd4c086292ec0171 Function Runtime Version: 3.0.15193.0

[2021-01-29T01:13:59.792Z] Found C:\github\djpool\mdc\Cloud\src\Endpoints\Integration\Integration.csproj. Using for user secrets file configuration. Missing value for AzureWebJobsStorage in local.settings.json and User Secrets. This is required for all triggers other than httptrigger, kafkatrigger. You can run ‘func azure functionapp fetch-app-settings <functionAppName>’ or specify a connection string in local.settings.json or User Secrets.

Context: https://twitter.com/sfeldman/status/1354567460532285442

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:27 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
RCSandbergcommented, Dec 7, 2021

Just to also iterate, kind of what’s already been said… the problem is also present running isolated processes in .NET 6

public async Task Run(
  [BlobTrigger($"{ContainerName}/{{blobName}}", Connection = "MySpecialAppSettingConnectionString")]
...

Having MySpecialAppSettingConnectionString set correctly in local.settings.json will work just fine.

But it will not get picked up correctly from user secrets.

3reactions
karpikplcommented, Feb 10, 2022

Not sure if that helps anyone, but I to get a message saying Using for user secrets file configuration..

  1. <UserSecretsId>898cd92a-e4a0-46ff-9296-2fef4b6b9a14</UserSecretsId>
  2. dotnet user-secrets list gives:
ServiceBusConnection = Endpoint=sb://xxx
AppConfigConnectionString = Endpoint=https://xxxx

And app fails because none of those values are there.

I’ve modified startup.cs and solved the issue by adding:

public override void ConfigureAppConfiguration(IFunctionsConfigurationBuilder builder)
{
            if (System.Environment.GetEnvironmentVariable("AZURE_FUNCTIONS_ENVIRONMENT") == "Development")
            {
                builder.ConfigurationBuilder.AddUserSecrets<Startup>();
            }

but I was expecting default builder to do it…

Read more comments on GitHub >

github_iconTop Results From Across the Web

ASP.NET Core 2 web application isn't loading user secrets ...
So I moved my user secrets to environment variables (e.g. in my connection string example, adding a system environment variable ...
Read more >
Using User Secrets Configuration In .NET - NET Core Tutorials
Right click your entry project and select “Manage User Secrets”. Visual Studio will then work out the rest, installing any packages you require...
Read more >
Safe storage of app secrets in development in ASP.NET Core
In Visual Studio, right-click the project in Solution Explorer, and select Manage User Secrets from the context menu. This gesture adds a ...
Read more >
ASP.NET Core (not that secret) User Secrets Explained
CreateDefaultBuilder method, ASP.NET Core automatically picks up your configuration from the secrets. json file.
Read more >
Visual Studio - User Secrets
Provides a developer's overview on how to get started with using Visual Studio's User Secrets.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found