Bash Script to Add secrets in Azure Key Vault

Azure Key Vault is a cloud service provided by Microsoft Azure that allows you to securely store and manage sensitive information, such as:
Secrets: API keys, passwords, connection strings, tokens
Keys: Cryptographic keys used for encryption/decryption
Certificates: SSL/TLS certificates
Managed identities & access control for secure access
In short, Azure Key Vault helps teams keep sensitive data safe and avoid hardcoding secrets in apps or codebases.
Here are some features of Azure Key Vault_
Centralized Secret Management
Secure Access via RBAC & Policies
Integration with Azure Services
Now that you know what Azure Key Vault is and why it matters, let’s move to how to add secrets using a Bash script and a CSV file inside Azure Cloud Shell.
🚀 Automate Azure Key Vault Secret Management Using Bash + CSV in Azure Cloud Shell!
Managing secrets in Azure Key Vault manually can be tedious. So I created a simple automation using Bash scripting and a CSV file to bulk upload secrets directly in Azure using Cloud Shell.
What I did:
Used Azure Cloud Shell – no local setup needed.
Created a .csv file with all secrets.
Wrote a .sh Bash script to read the CSV and upload each secret.
Granted executable permissions and ran it securely.
Files I created:
secrets.csv – Contains secret names and values.
secrets.sh – Bash script to push secrets to Azure Key Vault.
*****************************************************************************************************
Open your Azure Account
Go to the Azure key vault that you have
Now open the azure cloudshell within the azure key vault
Once this open creates two files __ 1. secrests.csv and 2.secrets.sh
Step 1: Create secrests.csv
Step 2: Create secrests.sh
Step 3: Make Script Executable
Use the below command to make this file as executable
“chmod +x secrets.sh“
Step 3: Run the Script
Use the below script to run the .sh script
“./secrests.sh“
Subscribe to my newsletter
Read articles from Nilesh Ganvir directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
