I'm always excited to take on new projects and collaborate with innovative minds.

Social Links

Browse Azure Key Vault Secrets from the Command Line

A tiny .NET console app that connects to your Azure Key Vault and lists every secret in it — names, values, and content types — right from the command line. No more clicking through the Azure Portal to see what's stored. Authenticates with the default Azure credential chain, so it works with az login, a service principal, or managed identity.

If you've ever managed secrets in Azure, you know the drill: log into the portal, hunt through the menu, open the Key Vault, expand Secrets, and scroll through a page of entries — clicking each one just to see what's inside. Fine once. Annoying every time after.

So I wrote a small console app that just tells me.

What it does

It connects to your Key Vault, pulls down every secret, and prints them one line at a time:

MyDbPassword | hunter2 | text/plain
StorageKey    | <value>  | text/plain

No portal. No clicking. Just an honest list of what's actually stored — name, value, and content type.

Why the credential story matters

The nice part is that it uses Azure's DefaultAzureCredential. That means it doesn't care how you're signed in — az login, a service principal, or a managed identity on a VM. Whatever identity the environment already trusts, the app just works.

The code is tiny

The whole thing is a handful of lines:

var credentials = new DefaultAzureCredential();
var client = new SecretClient(new Uri("https://<vault>.vault.azure.net"), credentials);

foreach (var secret in client.GetPropertiesOfSecrets())
{
    var value = client.GetSecret(secret.Name);
    Console.WriteLine($"{secret.Name} | {value.Value.Value} | {value.Value.Properties.ContentType}");
}

Set your vault name, make sure your identity has Key Vault Secrets User permissions, and dotnet run gets you everything.

When would you actually use this?

Honestly, it's a convenience tool. But the moment you're writing automation — or you just need to sanity-check a secret without opening a browser — it pays for itself. It also makes a great starting point if you want to build a small secrets dashboard or a backup script.

2 min read
Sep 01, 2023
By Dheer Gupta
Share

Leave a comment

Your email address will not be published. Required fields are marked *