© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•12mo ago•
5 replies
Angius

Aspire user secrets not available in prod environment

I created a prod profile in launchsettings of my apphost:
{
    "$schema": "https://json.schemastore.org/launchsettings.json",
    "profiles": {
        "dev": {
            "commandName": "Project",
            "dotnetRunMessages": true,
            "launchBrowser": true,
            "applicationUrl": "https://localhost:17226;http://localhost:15203",
            "environmentVariables": {
                "ASPNETCORE_ENVIRONMENT": "Development",
                "DOTNET_ENVIRONMENT": "Development",
                "DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21252",
                "DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22080"
            }
        },
        "prod": {
            "commandName": "Project",
            "dotnetRunMessages": true,
            "launchBrowser": true,
            "applicationUrl": "https://localhost:17226;http://localhost:15203",
            "environmentVariables": {
                "ASPNETCORE_ENVIRONMENT": "Production",
                "DOTNET_ENVIRONMENT": "Production",
                "DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21252",
                "DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22080"
            }
        }
    }
}
{
    "$schema": "https://json.schemastore.org/launchsettings.json",
    "profiles": {
        "dev": {
            "commandName": "Project",
            "dotnetRunMessages": true,
            "launchBrowser": true,
            "applicationUrl": "https://localhost:17226;http://localhost:15203",
            "environmentVariables": {
                "ASPNETCORE_ENVIRONMENT": "Development",
                "DOTNET_ENVIRONMENT": "Development",
                "DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21252",
                "DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22080"
            }
        },
        "prod": {
            "commandName": "Project",
            "dotnetRunMessages": true,
            "launchBrowser": true,
            "applicationUrl": "https://localhost:17226;http://localhost:15203",
            "environmentVariables": {
                "ASPNETCORE_ENVIRONMENT": "Production",
                "DOTNET_ENVIRONMENT": "Production",
                "DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21252",
                "DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22080"
            }
        }
    }
}

and everything works when I run the
dev
dev
profile, but
prod
prod
profile throws
Unhandled exception. Aspire.Hosting.DistributedApplicationException: Parameter resource could not be used because configuration key 'Parameters:postgres-username' is missing and the Parameter has no default value.
Unhandled exception. Aspire.Hosting.DistributedApplicationException: Parameter resource could not be used because configuration key 'Parameters:postgres-username' is missing and the Parameter has no default value.

at me, on the last line here
var builder = DistributedApplication.CreateBuilder(args);

var sqlPassword = builder.AddParameter("postgres-password", secret: true);
var sqlUsername = builder.AddParameter("postgres-username", secret: true);

Console.WriteLine($"{sqlUsername.Resource.Value} / {sqlPassword.Resource.Value}");
var builder = DistributedApplication.CreateBuilder(args);

var sqlPassword = builder.AddParameter("postgres-password", secret: true);
var sqlUsername = builder.AddParameter("postgres-username", secret: true);

Console.WriteLine($"{sqlUsername.Resource.Value} / {sqlPassword.Resource.Value}");

Those values come from usersecrets, could that be the issue?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

dotnet user secrets not working
C#CC# / help
2y ago
✅ How do you guys handle user secrets for GitHub, Docker, or in prod?
C#CC# / help
8mo ago
User Secrets in Blazor Web Assembly
C#CC# / help
17mo ago
User-secrets per machine?
C#CC# / help
2y ago