question

presam avatar image
0 Votes"
presam asked sikumars edited

using Keyvalult in local machine

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
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

sikumars avatar image
0 Votes"
sikumars answered sikumars edited

Hello @presam,

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



image.png (46.5 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.