I want to access config files from AWS AppConfig in .Net Core (AWS Lambda). How can I do that? I have seen in the AWS docs that the recommended way is to use the GetLatestConfiguration and StartConfigurationSession APIs but I am unable to find the functions in AWS .Net Client SDK.
Question posted in Amazon Web Sevices
The official Amazon Web Services documentation can be found here.
The official Amazon Web Services documentation can be found here.
2
Answers
One of the easiest ways to do this is using the App Config Lambda extension. The link below provides further detail, but the extension simplifies a lot of the communication between your function and AppConfig whilst also providing an element of caching and cost reduction.
From your perspective, you then interact with AppConfig by making requests to a local web endpoint
(http://localhost:2772/applications/application_name/environments/environment_name/configurations/configuration_name)
Full details can be found below.
https://docs.aws.amazon.com/appconfig/latest/userguide/appconfig-integration-lambda-extensions.html
I was able to get this working by using
AWSSDK.AppConfigData
nuget package.Note that examples out on the web you may find make it difficult to find it due to the namespace changing from the deprecated version.
I want to emphasize again that the sdk is
AWSSDK.AppConfigData
and not the deprecatedAWSSDK.AppConfig
.Once the package is installed you can leverage the sdk with:
Client model is called
AmazonAppConfigDataClient
once you initialize the client you can call
StartConfigurationSessionAsync
which accepts a model ofStartConfigurationSessionRequest
and will return aStartConfigurationSessionResponse
You can then use the client to call
GetLatestConfigurationAsync
GetLatestConfigurationAsync
will accept a model ofGetLatestConfigurationRequest
. You can populate itsInitialConfigurationToken
property with from theStartConfigurationSessionResponse.InitialConfigurationToken
you get back from your session call.Happy coding!