IUserSecretsManager Methods
InterfaceMethods4 members
Defines an interface for managing user secrets with support for read and write operations.
GetOrSetSecret(IConfigurationManager, string, Func<string>)Section titled GetOrSetSecret(IConfigurationManager, string, Func<string>)abstract Gets a secret value if it exists in configuration, or sets it using the value generator if it doesn't.
public interface IUserSecretsManager{ public abstract void GetOrSetSecret( IConfigurationManager configuration, string name, Func<string> valueGenerator) { // ... }}Parameters
configurationIConfigurationManagerThe configuration manager to check and update.namestringThe name of the secret.valueGeneratorFunc<string>Function to generate the value if it doesn't exist.SaveStateAsync(JsonObject, CancellationToken)Section titled SaveStateAsync(JsonObject, CancellationToken)abstractTask Saves state to user secrets asynchronously (for deployment state manager). If multiple callers save state concurrently, the last write wins.
public interface IUserSecretsManager{ public abstract Task SaveStateAsync( JsonObject state, CancellationToken cancellationToken = default(CancellationToken)) { // ... }}Parameters
stateJsonObjectThe state to save as a JSON object.cancellationTokenCancellationTokenoptionalCancellation token. Attempts to delete a user secret value synchronously.
public interface IUserSecretsManager{ public virtual bool TryDeleteSecret( string name) { // ... }}Parameters
namestringThe name of the secret.Returns
boolTrue if the secret was deleted successfully; otherwise, false.Remarks
The default implementation returns
false so existing implementations remain compatible. Attempts to set a user secret value synchronously.
public interface IUserSecretsManager{ public abstract bool TrySetSecret( string name, string value) { // ... }}Parameters
namestringThe name of the secret.valuestringThe value of the secret.Returns
boolTrue if the secret was set successfully; otherwise, false.