Skip to content

Instantly share code, notes, and snippets.

@billdeitrick
Created February 28, 2021 19:14
Show Gist options
  • Save billdeitrick/5e483d8304f7d0ba697851db9610bfeb to your computer and use it in GitHub Desktop.
Save billdeitrick/5e483d8304f7d0ba697851db9610bfeb to your computer and use it in GitHub Desktop.
Get Secret from Azure KeyVault Using Managed Identity - C#
using System;
using Azure.Security.KeyVault.Secrets;
using Azure.Identity;
namespace kvtest
{
class Program
{
static void Main(string[] args)
{
var client = new SecretClient(new Uri("https://totallybogusvault.vault.azure.net"), new DefaultAzureCredential());
var secret = client.GetSecret("totallybogussecret");
Console.WriteLine($"The secret was \"{secret.Value.Value}\"");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment