Aspirerelease/17.0
Watch Aspire live streamsDocsTry Aspire

UserSecretsManager

Interface
📦 Aspire.Hosting v17.0.0

Defines an interface for managing user secrets with support for read and write operations.

type UserSecretsManager interface{}

Properties

propertyFilePathstringget
Gets the path to the user secrets file.
FilePath() (string, error)
propertyIsAvailableboolget
Gets a value indicating whether user secrets are available.
IsAvailable() (bool, error)

Methods

Gets a secret value if it exists in configuration, or sets it to the provided value if it does not.
GetOrSetSecret(
resourceBuilder Resource,
name string,
value string,
) error
resourceBuilderResourceA resource builder from the target application.
namestringThe secret name.
valuestringThe value to persist when the secret is missing.
error

Returns error.

Saves state to user secrets from a JSON string.
SaveStateJson(
json string,
options ...*SaveStateJsonOptions,
) error
jsonstringThe JSON object payload to persist.
options...*SaveStateJsonOptionsOptional settings, described under Options.

Optional parameters are passed in a trailing options ...*SaveStateJsonOptions argument.

CancellationToken*CancellationTokenThe cancellation token.
error

A task that completes when the state is saved.

Returns error.

Attempts to delete a user secret value synchronously.
TryDeleteSecret(name string) (bool, error)
namestringThe name of the secret.
(bool, error)

True if the secret was deleted successfully; otherwise, false.

Returns (bool, error).

Attempts to set a user secret value synchronously.
TrySetSecret(
name string,
value string,
) (bool, error)
namestringThe name of the secret.
valuestringThe value of the secret.
(bool, error)

True if the secret was set successfully; otherwise, false.

Returns (bool, error).

Applies to

This interface applies to the following types: