Skip to content

03 - Configuration (Consumption)

Apply environment settings, JVM arguments, and host-level configuration so the same artifact can run across environments.

Prerequisites

Tool Version Purpose
JDK 17+ Compile and run Java functions locally
Maven 3.6+ Build and package Java artifacts
Azure Functions Core Tools v4 Start local host and publish artifacts
Azure CLI 2.61+ Provision Azure resources and inspect app state

Consumption plan basics

Consumption (Y1) is serverless with scale-to-zero, up to 200 instances, 1.5 GB memory per instance, and a default 5-minute timeout (max 10 minutes).

What You'll Build

You will standardize Java runtime app settings for Consumption, keep environment-specific values outside the artifact, and verify effective configuration from Azure.

flowchart TD
    A[local.settings.json] --> B[App Settings in Azure]
    B --> C[Functions host]
    C --> D[Java worker startup]
    D --> E[Function method behavior]

Steps

Step 1 - Baseline local settings

The reference app includes a local.settings.json.example template:

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "FUNCTIONS_WORKER_RUNTIME": "java",
    "FUNCTIONS_EXTENSION_VERSION": "~4",
    "QueueStorage": "UseDevelopmentStorage=true",
    "EventHubConnection__fullyQualifiedNamespace": "placeholder.servicebus.windows.net"
  }
}

Local vs Azure settings

local.settings.json is used only for local development. In Azure, app settings are stored as environment variables in the Function App configuration.

Step 2 - Configure app settings in Azure

az functionapp config appsettings set \
  --name "$APP_NAME" \
  --resource-group "$RG" \
  --settings \
    "APP_ENV=production" \
    "JAVA_OPTS=-Xmx512m"

Step 3 - Set JVM and runtime guardrails

az functionapp config appsettings set \
  --name "$APP_NAME" \
  --resource-group "$RG" \
  --settings \
    "FUNCTIONS_EXTENSION_VERSION=~4" \
    "JAVA_OPTS=-Xmx512m -XX:+UseContainerSupport"

Step 4 - Validate pom.xml dependency and plugin

Ensure the Maven project includes the Azure Functions Java library:

<dependency>
    <groupId>com.microsoft.azure.functions</groupId>
    <artifactId>azure-functions-java-library</artifactId>
    <version>3.1.0</version>
</dependency>

And the Maven plugin for packaging:

<plugin>
    <groupId>com.microsoft.azure</groupId>
    <artifactId>azure-functions-maven-plugin</artifactId>
    <version>1.34.0</version>
    <configuration>
        <appName>${functionAppName}</appName>
        <resourceGroup>${functionResourceGroup}</resourceGroup>
        <runtime>
            <os>linux</os>
            <javaVersion>17</javaVersion>
        </runtime>
    </configuration>
</plugin>

Step 5 - Verify effective settings

az functionapp config appsettings list \
  --name "$APP_NAME" \
  --resource-group "$RG" \
  --output table

Step 6 - Verify runtime behavior with info endpoint

curl --request GET "https://$APP_NAME.azurewebsites.net/api/info"

The /api/info endpoint reads environment variables at runtime, confirming the deployed configuration:

{
  "name": "azure-functions-java-guide",
  "version": "1.0.0",
  "java": "17.0.14",
  "os": "Linux",
  "environment": "production",
  "functionApp": "func-jcon-04100022"
}

Verification

App settings output (showing key fields):

Name                                    Value
--------------------------------------  -----------------------------------------------
FUNCTIONS_WORKER_RUNTIME                java
FUNCTIONS_EXTENSION_VERSION             ~4
APP_ENV                                 production
JAVA_OPTS                               -Xmx512m -XX:+UseContainerSupport
AzureWebJobsStorage                     DefaultEndpointsProtocol=https;AccountName=...
APPLICATIONINSIGHTS_CONNECTION_STRING   InstrumentationKey=<instrumentation-key>;...
QueueStorage                            DefaultEndpointsProtocol=https;AccountName=...
EventHubConnection                      Endpoint=sb://placeholder.servicebus.windows.net/;...

Sensitive values in app settings

Connection strings and keys appear in the output. In production, use Azure Key Vault references instead of storing secrets directly in app settings.

Next Steps

Next: 04 - Logging and Monitoring

See Also

Sources