0

I'm working to move my app from an app service into a docker container. I've added a dockerfile and other standard docker requirements.

My app previously had been using Azure App Configuration to provide a good portion of the configuration settings during startup.

Here's the key part of my Startup.CS

configBuilder

When I run this typically, it gets the connection string from the Environment settings, and calls out to the service and retrieves the configuration.

The environment settings are being found in the Docker startup. However, the service call part isn't working and none of those settings are being made available.

How can I enable this?

A.Rowan
  • 1,460
  • 2
  • 16
  • 20

1 Answers1

0

The recommended way to read the Environment variables and Connection Strings is below:

 var Appconfig = new ConfigurationBuilder()
                .SetBasePath(context.FunctionAppDirectory)
                .AddJsonFile("local.settings.json", optional: true, reloadOnChange: true)
                .AddEnvironmentVariables()
                .Build();
        //Reading config values from local.settings.json
        var appSetValue = Appconfig["MyCustomSetting"];
        //Reading Application Settings 
        var value = Environment.GetEnvironmentVariable("MyCustomSetting");
        //Reading Connection Strings 
        var mycusString = Appconfig.GetConnectionString("MyCustomSetting");

FunctionAppDirectory sets the directory to find your local.settings.json file. Set optional to true because we won’t have the file when we deploy. AddEnvironmentVariables will pick up both App Settings and Connection Strings from Azure settings. Refer here

Refer Azure Function Configuration and Secrets Management on Startup.cs

Delliganesh Sevanesan
  • 4,146
  • 1
  • 5
  • 15