Can we use app-configuration in Java Azure function bindings

CareyBoldenow 96 Reputation points
2021-05-14T11:58:07.753+00:00

Hello,

I cannot seem to find a way to leverage App Configuration for properties that are used in my Azure Function bindings. For example, in the code snippet below, I would like to use App Configuration to serve up the value for the AzureCosmosDBConnection setting in my output binding. I would rather not get in a situation where I need to define some of my properties as "Application Settings" and some in "App Configuration". The situation below seems to be that Function bindings get resolved at build time and the App Configuration values are not available at that time? What is considered the best practice for serving up the values required by function bindings vs other properties your function might need? Like I said, it doesn't feel right that we would need to use multiple solutions for doing this, would love to be able to use App Configuration for everything!

@FunctionName("HttpExample")
public HttpResponseMessage run(
@HttpTrigger(
name = "req",
methods = {HttpMethod.GET, HttpMethod.POST},
authLevel = AuthorizationLevel.ANONYMOUS)
HttpRequestMessage<Optional<String>> request,
@CosmosDBOutput(
name = "database",
databaseName = "%databaseName%",
collectionName = "my-collection",
connectionStringSetting = "AzureCosmosDBConnection")
OutputBinding<List<CosmosFramework>> cosmosOutput,
final ExecutionContext context
)

Azure App Configuration
Azure App Configuration
An Azure service that provides hosted, universal storage for Azure app configurations.
230 questions
0 comments No comments
{count} votes

Accepted answer
  1. Samara Soucy - MSFT 5,051 Reputation points
    2021-05-17T01:19:11.267+00:00

    The short answer is this is not currently possible in Java, but this may change in the near future. The .NET SDK has this capability and handles this through dependency injection, which isn't yet available for Java functions, though it is in the roadmap. On startup it retrieves requested values and adds them to the environment variables before the individual functions load so that Functions can access them just as it would a local app setting.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.