-1

Looking for something similar in C#

$AzAccount = Login-AzureRmAccount -Credential $SPOAdminCredentials
$clientId = (Get-AzureKeyVaultSecret -vaultName $KeyVaultName -name $KVSecName_ProvFnClientId).SecretValueText
Nancy
  • 26,865
  • 3
  • 18
  • 34

1 Answers1

0

You can refer to my code, here is detailed sample:

using System;
using System.Threading.Tasks;
using Azure.Identity;
using Azure.Security.KeyVault.Secrets;

 

namespace key_vault_test
{
    class Program
    {
        static async Task Main(string[] args)
        {
            const string secretName = "testxxx";
            var kvUri = "https://tinytestxxxx.vault.azure.net/";
            var client = new SecretClient(new Uri(kvUri), new DefaultAzureCredential());

 

            var secret = await client.GetSecretAsync(secretName);
            Console.WriteLine($"Your secret is '{secret.Value.Value}'.");
        }
    }
}

enter image description here

Next, you need to add the account to Azure:

enter image description here

Carl Zhao
  • 8,543
  • 2
  • 11
  • 19