In today's digital world, data security has become a top priority for businesses and organizations.
Microsoft Azure, one of the world's leading cloud computing platforms, has introduced a powerful solution to this problem, which is a KeyVault.
What is KeyVault?
KeyVault is a Microsoft Azure service used to store and manage "secrets" such as passwords, API keys, and certificates...
KeyVault helps protect data by storing it encrypted and providing flexible access control mechanisms.
Applications and services can securely access the "secrets" in KeyVault without knowing the details of the specific data.
This provides increased security and easy management for applications and services on the Azure platform.
For example, when saving database information such as host, username, and password, we often save it in the source code's configuration file, which can risk revealing the information, but if we save it in KeyVault, it will help keep the information more secure.
How to use it?
1. Create a KeyVault on Microsoft Azure.
Follow these steps to create a KeyVault
- Sign in to Azure Portal (https://portal.azure.com).
- Select "Create a resource" and search for "Key Vault" in Marketplace.
- Click "Key Vault" and select "Create".
- Fill in the necessary information such as name, region, and security settings.
- Once completed, press "Review + create" and then "Create" to create the KeyVault.
We can refer to the "https://learn.microsoft.com/en-us/azure/key-vault/general/quick-create-portal" for more details.
2. Obtain the value of the KeyVault from the source code.
After that, to get the value of KeyVault from an Application or service, we need to use Azure Key Vault SDK or REST API.
However, Azure Key Vault SDK is currently only available for a few popular languages and is limited. So let's learn how to get values through REST API.
So that we can get the value from Keyvault, we need to implement 2 APIs.
Execute the first API to log into Microsoft Azure and receive an access key to execute the 2nd API.
We will do the following:
Step 1. Set parameters to implement the first API.

In the first API, parameters such as $tenantId, $clientId, and $clientSecret will be obtained after we create KeyVault successfully.
After successful implementation, we will receive an access token and this access token only lasts for 10 minutes.
Step 2. Use the access token from the above API to execute the second API.

In the second API, we have 2 parameters we need to know as follows:
-
- $accessToken: we will receive after successfully executing the first API.
- $url: we will also get after we create KeyVault successfully.
- $key: That is the key name whose value we want to get.
In the above examples, we use REST API to authenticate information and then use SecretClient to access and retrieve secrets from KeyVault.
Conclusion
Using KeyVault on the Microsoft Azure platform can help you manage and protect your secrets and sensitive information safely and effectively.
Following the steps above, you can integrate KeyVault into your app for enhanced security.