microsoft / azure-gradle-plugins

Azure Plugins for Gradle
MIT License
45 stars 28 forks source link

setAppSettings has no effect on values that can be set in local.settings.json #190

Open Lesrac opened 1 week ago

Lesrac commented 1 week ago

Variables in the appSettings seem to be not applied to the locally run function. Changes in "localDebug" have an effect on the locally run function.

Consider this configuration:

azurefunctions  {
    appName = project.name
    localDebug = "transport=dt_socket,server=y,suspend=n,address=5005"
    setRuntime(closureOf<com.microsoft.azure.gradle.configuration.GradleRuntimeConfig> {
        os("linux")
    })
    setAppSettings(closureOf<MutableMap<String, String>> {
        put("FUNCTIONS_WORKER_RUNTIME", "python")
        put("JAVA_OPTS", "-Djdk.net.hosts.file=/path/src/test/resources/test_hosts")
    })
}

When executing "gradlew azureFunctionsRun" then no java environment variable or system property is set for "jdk.net.hosts.file" and the log states "FUNCTIONS_WORKER_RUNTIME set to java." - which is the config for FUNCTIONS_WORKER_RUNTIME that is set in the local.settings.json.

Example local.settings.json file:

{
  "IsEncrypted": false,
  "Values": {
    "FUNCTIONS_WORKER_RUNTIME": "java",
    "FUNCTIONS_EXTENSION_VERSION": "~4",
    "AzureFunctionsJobHost__logging__logLevel__default": "Information",
    "AzureFunctionsJobHost__logging__logLevel__Function": "Information",
    "MAIN_CLASS": "com.Functions",
    "AzureWebJobsStorage": ""
  }
}

My expectation would be that the "setAppSettings" would work locally and replace values that are set in the local.settings.json. Is this a bug or is this the intended behaviour? (in which case a comment in the wiki would be appreciated)

Gradle version: 8.10.2 Azure gradle plugin version: 1.16.1