DEV Community

Cover image for HOW TO CREATE A KEYVAULT ON AZURE WITH CMD STEP BY STEP GUIDE
Ajayi Daniel
Ajayi Daniel

Posted on

HOW TO CREATE A KEYVAULT ON AZURE WITH CMD STEP BY STEP GUIDE

WHAT IS KEYVAULT
Azure Key Vault is a cloud service from Microsoft that helps you store and protect sensitive information like: Secrets (e.g., passwords, connection strings, API keys) Keys (e.g., encryption keys)
Certificates (e.g., SSL/TLS certificates) Instead of hardcoding secrets in your app or keeping them in plain text, you put them in Key Vault. Your app can then fetch them securely when needed.

STEP BY STEP GUIDE ON CMD
STEP 1 LONGIN INTO AZURE ON CMD WITH AZ LOGIN

az login
click on the email registered on azure

NEXT STEP YOU WILL TYPE 1 TO LOG IN PERFECTLY DUE TO SUBSCRIPTION IS 1

Image 1
TYPE 1

STEP 2 CREATE RESOURCEGROUP WITH THIS CODE = az group create --name myresourcegroup --location eastus
RESOURCES

STEP 3 CREATE THE KEY VAULT WITH THIS CODE = az keyvault create --name mykeydaniel123 --resource-group myresourcegroup --location eastus

KEY
Purpose of using clI Instead of clicking around in the Azure Portal, you can script everything with CLI

STEP 4 ROLE ASSIGNMENT TO MAKE ABLE TO STORE THE KEY=az role assignment create --assignee 3095d940-46b7-4239-bfed-f46a193281c1 --role "Key Vault Secrets Officer"--scope "/subscriptions/fdf2e0bf-0c36-45cc-8ae5-2f2e84aa3dbe/resourceGroups/myresourcegroup/providers/Microsoft.KeyVault/vaults/mykeydaniel123"

ROLE

This command is how you assign permissions in Azure when the Key Vault is using RBAC (Role-Based Access Control) instead of access policies.

STEP 5 STORE SECRET KEY WITH THIS CODE =az keyvault secret set --name mysecret --value "kolawole@123" --vault-name mykeydaniel123
STORE
Storing secret keys in Azure Key Vault through CMD is important because it keeps sensitive data (like passwords, API keys, and connection strings) safe, centralized, and encrypted. Instead of exposing secrets in code or config files, you use secure commands to store and retrieve them, ensuring better security, access control, and compliance.

STEP 6 RETRIEVE SECRET KEY VALUE MAKE USE OF THIS CODE =az keyvault secret show --vault-name mykeydaniel123 --name mysecret --query value -o tsv

DDDD
Azure Key Vault lets you securely store and retrieve secrets like passwords or API keys using simple CLI commands. This ensures sensitive data stays protected, centralized, and easily managed without exposing it in your code.

STEP 7 USEFUL LISTING MAKE USE OF THIS CODE =az keyvault secret list --vault-name mykeydaniel123 -o table
DDV

HIGLIGHT OF THE EFFECT OF CREATING KEYVAULT ON CMD AND REFLECTING ON YOUR MAIN AZURE PORTAL

RESOURCES

MY KEY

FGD

Top comments (0)