I'm working with .NET Core 6.0, my app is deployed to Azure.
I want to get access to environment variables in Azure from my code.
I created the key value in Azure:
When I try to access it using this code snippet:
Environment.GetEnvironmentVariable("BROKER_IP")
or
_conf["BROKER_IP"])
(IConfiguration is injected in the constructor), it is working when i run the program locally(able to get environment variable from my local PC), but when deployed to Azure (as an App Service), it doesn't return any value.
How can I access it from my API?
Part of my program.cs looks like this:
var builder = WebApplication.CreateBuilder(args);
ConfigurationManager configuration = builder.Configuration;
builder.Services.Configure<AppSettings>(builder.Configuration.GetSection("AppSettings"));
I added this line :
builder.Configuration.AddEnvironmentVariables();
but I still have the same issue.
Thank you


