Key Vault

// Setting

Azure Key vaults

1. Azure portal
2. Entry App Services, find, and entry a API app
3. Under settings, click on Identity
4. Change the status to On

5. Entry Key Vaults, Create a key vault, in Objects, Secrets, Generate a secret key 
6. In Access policies
7. Click Create
8. Under the Secret Permission, select Get and List
9. Click Next, then, search the app resource of the API, click Next
11. Click Create
// Some setting in API app

1. Install package Azure.Security.KeyVault.Secrets

2. appsettings.json

{
  "Authentication": {
    "ApiKeyName": "portal-api-key",
    "ApiKeyUrl": "https://aaaa.vault.azure.net/",
    "ApiKeyHeaderName": "Api-Key"
  },
}

3. startup.cs
	// API key authentication
	services.AddMemoryCache();
	services.AddScoped<IKeyVaultService, KeyVaultService>();
	
4.  public class KeyVaultResponseViewModel
    {
        public string Value { get; set; }
    }

Last updated

Was this helpful?