Share via

using Keyvalult in local machine

Samuel Tilakraj 6 Reputation points
2021-04-23T08:09:42.203+00:00

After configuring the Azure Key Vault and publishing my app, the application is working properly from the website. However, when i tried to run it on my local machine using VS2019 debugger, I am getting the following error. However, if I comment out the "ConfigureAppConfiguration()" method, I am able to run the application on my local machine.

I am guessing that i am supposed to maybe save the "vaultUri" somewhere in my code. Any pointers is greatly appreciated.

Thanks in advance,
Samuel

=====================================================================================
ArgumentNullException: Value cannot be null. (Parameter 'uriString')
System.Uri..ctor(string uriString)

ArgumentNullException: Value cannot be null. (Parameter 'uriString')
System.Uri..ctor(string uriString)

RogersSalesPortal1.Program+<>c.<CreateHostBuilder>b__1_0(HostBuilderContext context, IConfigurationBuilder config) in Program.cs

    }
    public static IHostBuilder CreateHostBuilder(string[] args) =>
        Host.CreateDefaultBuilder(args)

.ConfigureAppConfiguration((context, config) =>
{
var keyVaultEndpoint = new Uri(Environment.GetEnvironmentVariable("VaultUri"));
config.AddAzureKeyVault(
keyVaultEndpoint,
new DefaultAzureCredential());
})
.ConfigureWebHostDefaults(webBuilder =>
{
Microsoft.Extensions.Hosting.HostBuilder.BuildAppConfiguration()
Microsoft.Extensions.Hosting.HostBuilder.Build()
RogersSalesPortal1.Program.Main(string[] args) in Program.cs
+

CreateHostBuilder(args).Build().Run();

Azure Key Vault
Azure Key Vault

An Azure service that is used to manage and protect cryptographic keys and other secrets used by cloud apps and services.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Siva-kumar-selvaraj 15,741 Reputation points Volunteer Moderator
    2021-04-26T16:31:35.423+00:00

    Hello @Samuel Tilakraj ,

    Thanks for reaching out.

    There is similar question was asked from this thread, sharing here for your reference.

    Here is screenshot of when I configure Azure Key Vault through Connected Services from visual studio . To know more about how "Safe storage of app secrets in development in ASP.NET Core works".

    91783-image.png

    Hope this helps.

    Regards,
    Siva

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.