How to deploy a Key Vault with Key, Secret and Certificate on Microsoft Azure
Published: 2023-03-11 12:46:06


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/elme5g22v9ih755yt1h1.png)

Azure Key Vault is a cloud service used to manage keys, secrets, and certificates. Key Vault eliminates the need for developers to store security information in their code. It allows you to centralize the storage of your application secrets which greatly reduces the chances that secrets may be leaked. Key Vault also allows you to securely store secrets and keys backed by Hardware Security Modules or HSMs.
In addition, key vault provides logs of all access and usage attempts of your secrets so you have a complete audit trail for compliance.

**Steps To Deploy Azure Key Vault:**

Step 1:
Create a Microsoft Azure account and login

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gnxcyoi5150rconwrc8l.png)

STEP 2:
Search for 'Key Vault' and click on it

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h6vnkoowh8kihbl7t1c2.png)

Step 3:
Click on 'Create key vault'

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gzhr68w7awsafyca9qzf.png)

Step 4:
Subscription - Choose your preferred Subscription
Resource group - It is better to name your resource group by the current month workload so it'll be easily differentiated
Key vault name - Choose a unique name
Region - your preferred location
Pricing tier - Standard
Soft delete - Clicking on this protection will automatically be enabled on this key vault. This feature allows you to recover or permanently delete a key vault and secrets for the duration of the retention period. This protection applies to the key vault and the secrets stored within the key vault.
Days to retain deleted vaults - The retention period is 7 to 90 days. This means if you purposefully or mistakenly delete a key vault, you can recover it within 7 - 90 days, depending on the number of days you chose when creating your key vault.
Purge protection - It enforces mandatory retention period and prevents the permanent deleting of key vaults prior to the retention period elapsing.
It is advisable you choose the enable purge protection so that you can recover your key vault before the end of the retention period.
Click on 'Review + Create'

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bcz158ja6j8qmfdt69ff.png)

Step 5:
Click on 'Create'

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xw91m8p3jjm4dsqaveh3.png)

Step 6:
Click on 'Go to resource'

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1n5ift2rqteblut3ehjw.png)

Step 7:
Your Key Vault is ready

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2gvfdtr627zhdhyto254.png)

Step 8:
How to create keys in key vault
Click on 'Keys'

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rz8j609joj776o920nyr.png)

Step 9:
Click on 'Generate/Import'

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ml08ii35ecw8muff99u3.png)

Step 10:
Name - Choose a unique name
Leave key type and RSA key size as default
Click on the 'Set activation date' and 'Set expiration date' boxes to determine your time frame of usage.
Enabled - Yes
Tags - Click on 'Tags' to choose a Tag Name and Tag Value for the project. Eg. Tag Name - Purple and Tag Value - Colours
Click on 'Create'

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vzddgbmgy8y439or2iij.png)

Step 11:
Key has been successfully created

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a41ixzj6g3apn5ahme8d.png)

Step 12:
How to create Secrets in key vault
Click on 'Secrets'

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/knlm8u68sywv9c29n7c9.png)

Step 13:
Click on Generate/Import

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/quecg4t2umzb0db72wbi.png)

Step 14:
Name - Choose a unique name
If you decide to set activation, deactivation date and tags, kindly go back to how it was done for 'Key' in Step 10.
Click on 'Create'

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r9tuyo1h51434k5x8izy.png)

Step 15:
Secret has been successfully created

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bv01sxsm76w931rimrpq.png)

Step 16:
How to create Certificates in key vault
Click on Certificates

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/73bohui5uonuzcr748go.png)

Step 17:
Click on Generate/Import

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5nq0uua15q77u4796o50.png)

Step 18:
Method of Certificate Creation - You can Generate or Import existing certificate
Certificate Name - a unique name
Type of Certificate Authority - Choose best option
Subject - CN here stands for Common Name. You can use any name of your choice but it must follow my format. Eg CN=mypurplecertificate.com
DNS Names - Click and fill a name of your choice
Validity Period - Set up validity period. Note that most certificates are valid for 12 months although I used 1 month for this demo
Content Type - Choose PKCS (Public-Key Cryptography Standards). It is a common standard for Microsoft environments
Lifetime Action Type - Choose the option that suits your plan
Advanced Policy Configuration - It helps to specify some Extended Key Usages (EKUs) codes and also customise other values that you want. I advice you do not change anything.
Finally click 'Create' on the bottom left of your screen.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yfqo3k5wgdm83s2dzmxz.png)

Final Step:
You have created a certificate
Click on your certificate name to view
You can delete or download a backup of your certificate whenever you want

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ncgjzf000gok0t4cufwq.png)

The Keys, Secrets and Certificates are the 3 main objects that an Azure Key Vault can generate.

Your Key Vault, Key, Secret and Certificate have been created.

NOTE: Kindly be reminded to always delete your Key Vault, Key, Secret and Certificate when you don't need them anymore in order to save your Microsoft Azure credit because of Microsoft 'per hour' billing system.

Thank you!