.NET5 Azure Function (isolated) User Secrets not working

Neil Thompson 1 Reputation point
2022-04-07T10:12:19.41+00:00

Can anyone point me to an example of how to use user secrets with a .NET5 isolated function

Given the new project out-of-the-box example, how do I get PortalStorage:ConnectionString from user secrets?

note: If I run dotnet user-secrets list from the app root I can see the secrets ok

c#
public static void Run([QueueTrigger("queue-auditlog-dev", Connection = "PortalStorage:ConnectionString")] string myQueueItem,
            FunctionContext context)

Running the function

Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.Function1'. Microsoft.Azure.WebJobs.Extensions.Storage: Storage account connection string 'AzureWebJobsPortalStorage:ConnectionString' does not exist. Make sure that it is a defined App Setting.

I have no idea where it gets AzureWebJobsPortalStorage from when the Connection is passed PortalStorage:ConnectionString.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,929 questions
{count} votes

1 answer

Sort by: Most helpful
  1. MayankBargali-MSFT 70,941 Reputation points Moderator
    2022-04-07T12:30:06.603+00:00

    @Neil Thompson Thanks for reaching out. You would need Microsoft.Extensions.Configuration.UserSecrets package for your requirement. Not the official microsoft document but I found this third party article which can help you with the steps and source code. Let me know if it helps you.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.