Azure App configuration provides a centralized place for storing the configurations. It provides a configuration explorer where you could add Key/value pair configurations. For more information on this, please refer to the below documentation

https://docs.microsoft.com/en-us/azure/azure-app-configuration/overview

In a BizTalk world, we developers use to store configurations in the SSO database. When I moved to Cloud based development using Logic Apps and Functions, there was nothing available initially for storing configurations in a centralized way. I assume few folks would have utilized the Azure functions application settings to store configurations. But now, we have Azure App Configuration.

At this point of time, we do not have a out of the box connector that can retrieve key/value from App configuration. I checked with the product team on this and say it’s in their roadmap

So, to get around this, I have created an Azure Function that can read from the Azure App configuration using the SDK.

public static class GetAppConfigValues
    {
        [FunctionName("GetAppConfigValues")]
        public static async Task<HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)]HttpRequestMessage req, TraceWriter log)
        {
            log.Info("C# HTTP trigger function processed a request.");

            // Extract the Config Key from the Request header
            string appKey = req.Headers.GetValues("AppKey").FirstOrDefault();

            // Extract the Connection String from the Function App Settings
            string connectionString = System.Configuration.ConfigurationManager.AppSettings["AppConfigConnectionString"];

            var builder = new ConfigurationBuilder();
            builder.AddAzureAppConfiguration(connectionString);

            var build = builder.Build();

            string message = build[appKey.ToString()];

            return message == null
                ? req.CreateResponse(HttpStatusCode.BadRequest, "Azure Configuration Key not found - " + appKey.ToString())
                : req.CreateResponse(HttpStatusCode.OK, message);
        }
    }

I have installed the nuget package Microsoft.Extensions.Configuration.AzureAppConfiguration

https://www.nuget.org/packages/Microsoft.Extensions.Configuration.AzureAppConfiguration/1.0.0-preview-007830001

I created an instance of the ConfigurationBuilder and added the app configuration using the connection string. The rest is self explanatory. I can now call the Azure function to read the key/value pair.

I am not sure when the connector will be released. Until then, I will have to use this in our integration projects.

Visits: 1987

0 0 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x