共用方式為


IVsProjectSecrets.AddSecretAsync(String, String, CancellationToken) Method

Definition

Adds a secret with the given name so the application built by this project can access it at runtime.

public System.Threading.Tasks.Task AddSecretAsync (string name, string value, System.Threading.CancellationToken cancellationToken = default);
abstract member AddSecretAsync : string * string * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Function AddSecretAsync (name As String, value As String, Optional cancellationToken As CancellationToken = Nothing) As Task

Parameters

name
String

The name of the secret. Must not be null or empty.

value
String

The secret itself.

cancellationToken
CancellationToken

A token that may cancel this operation.

Returns

A task that represents the asynchronous store operation.

Exceptions

Thrown if name is null.

Thrown if name is empty, contains reserved characters that GetInvalidCharactersFrom(String) would have indicated were disallowed, or collides with the name of an existing secret.

Thrown when integrity rules would be violated by this operation.

Thrown when the user does not have permission for this operation.

Thrown when the operation could not be completed due to some network or I/O failure.

Remarks

If a secret with the specified name already exists, an ArgumentException is thrown.

Applies to