I am still getting up to speed with Azure Key Vault.
Here is the setup: I have a Windows Service on-premise that needs access to a password. For security reasons, the password will be stored in AKV.
The Azure Portal was then used to create the AKV resource, and a "Secret" which will store the password (TheSecret).
Permissions were then added so that my AD login would have access to TheSecret.
So as far as I know, the Azure side of this is set up correctly.
Now I try to access TheSecret from a Console app.
This is the code based on the sample code in the docs:
var keyVaultUrl = @"https://css-key-vault.vault.azure.net/secrets/TheSecret/<TheGuid>";
var client = new SecretClient(new Uri(keyVaultUrl), new DefaultAzureCredential();
KeyVaultSecret theSecret = client.GetSecret("TheSecret");
Console.WriteLine($"Secret is returned with name {theSecret.Name} and value {theSecret.Value}");
When I run this, I just get a 404 error.
If I take the URL and put it in a brower, it return this message:
{"error":{"code":"Unauthorized","message":"AKV10000: Request is missing a Bearer or PoP token."}}
How do I get this to work?
I am expecting that when the Windows Service is running, the Service will use the Windows Account which it is running and somehow pass this credential information to Azure in order to Authenticate and Authorize getting the secret. But it is not clear to me what needs to be done to pass this information to Azure. If there is some other way to do this, I am open to that as well.