The VaultHelper function helps you fetch the KeyVault details for an application. The IVaultHelper instance returned when GetVaultHelper() is called fetches KeyVault values using the following method:

Method

Task<Dictionary<string, object>> GetValue(string AppName);
CODE

Example

var vaultHelper = GetVaultHelper();
var logHelper = GetLogHelper();

var vault = await vaultHelper.GetValue("MyApp");
logHelper.LogDebug(vault["AppKey"]);
logHelper.LogDebug(vault["AppSecrets"]);
CODE

Console Output

"Your_Key"
"Your_Secrets"
CODE

To set and update value in vault

Using the Vault API, you can set and update value in vault, which is stored in encrypted format. You cannot retrieve vault value using any API. You can retrieve vault values only using the VaultHelper function.

  1. Create: POST: /pricing/api/admin/Vault

    It creates an application with the specified key value name and application name.

    Body:

    {
        "AppName": "MyApp",
        "Secrets": {
        	"MySecretsKey1" : "MyValue1",
        	"MySecretsKey2" : "MyValue2"
        }
    }
    CODE

    You can create multiple applications and store multiple secrets as KeyValue in a single application using the POST API and retrieve those secrete values using the VaultHelper function by passing AppName.

  2. Update: PUT /pricing/api/admin/Vault/{appName}

    It updates an existing application vault information with a new value.

    Body:

    {
        "AppName": "MyApp",
        "Secrets": {
        	"MySecretsKey1" : "MyNewValue1",
        	"MySecretsKey2" : "MyNewValue2"
        }
    }
    CODE
  3. Remove: DELETE /pricing/api/admin/Vault/{appName}

It removes secretes from the vault storage.