Looking for something similar in C#
$AzAccount = Login-AzureRmAccount -Credential $SPOAdminCredentials
$clientId = (Get-AzureKeyVaultSecret -vaultName $KeyVaultName -name $KVSecName_ProvFnClientId).SecretValueText
Looking for something similar in C#
$AzAccount = Login-AzureRmAccount -Credential $SPOAdminCredentials
$clientId = (Get-AzureKeyVaultSecret -vaultName $KeyVaultName -name $KVSecName_ProvFnClientId).SecretValueText
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}'.");
}
}
}
Next, you need to add the account to Azure: