Create a ticket
Sign in Sign up
Locker support Locker support
Results

No results found.

Home Locker Secrets Manager Developer tools Secrets - SDK .Net Usages Get a secret value
Vietnamese English
Get a secret value

This function will get the secret value by a key. If the key does not exist, SDK will return the default_value

// Get a secret value by secret key.
// If they Key does not exist, SDK will return the defaultValue
var secretValue = service.GetSecret(
    name: "REDIS_CONNECTION",
    defaultValue: "Default Value"
    )
Console.WriteLine(secretValue);

// Get a secret value by secret key and specific environment name.
// If the Key does not exist, SDK will return the defaultValue
secretValue = service.GetSecret(
    name: "REDIS_CONNECTION",
    environmentName: "staging",
    defaultValue: "Default Value"
    )
Console.WriteLine(secretValue);

// Get a secret value by secret key.
// If they Key does not exist, SDK will throw exception
var options = new SecretRetrieveOptions();
var requestOptions = new RequestOptions();
var secretValue = service.Get(
    name: "REDIS_CONNECTION",
    retrieveOptions: options,
    requestOptions:requestOptions
    )
Console.WriteLine(secretValue);

// Get a secret value by secret key and specific environment name.
// If the Key does not exist, SDK will throw exception
var options = new SecretRetrieveOptions();
var requestOptions = new RequestOptions();
var secretValue = service.Get(
    name: "REDIS_CONNECTION",
    environmentName: "staging",
    retrieveOptions: options,
    requestOptions:requestOptions
    )
Console.WriteLine(secretValue);
Was this page helpful?
No
Yes
Join Our Community