aspire secret command

Name

aspire secret - Manage AppHost user secrets.

Synopsis

aspire secret [command] [options]

Description

The aspire secret command manages user secrets for an Aspire AppHost project. User secrets provide a safe way to store sensitive configuration values—such as passwords, API keys, and connection strings—outside of your project files during local development.

Aspire uses user secrets to persist values that resources need across restarts, such as auto-generated passwords for database containers. When you add a persistent resource that requires a password, Aspire automatically initializes user secrets for the AppHost and saves the generated password. On subsequent runs, the saved password is reused so that the resource retains its state.

Options

The following options are available:

  • --apphost <apphost>

    The path to the Aspire AppHost project file.

            • Commands

The following commands are available:

Command Function
aspire secret set <key> <value> Set a secret value.
aspire secret get <key> Get a secret value.
aspire secret list List all secrets.
aspire secret delete <key> Delete a secret.
aspire secret path Show the secrets file path.

Examples

  • Set a secret value for the current AppHost:

    aspire secret set Parameters:postgres-password MySecretPassword123
    
  • List all secrets for a specific AppHost:

    aspire secret list --apphost ./src/MyApp.AppHost/MyApp.AppHost.csproj
    
  • Get the value of a specific secret:

    aspire secret get Parameters:postgres-password
    
  • Show the path to the secrets file:

    aspire secret path