azure-maven-plugins
azure-maven-plugins copied to clipboard
Ability to set property values from azure-maven-plugin ?
azure-maven-plugin
Is there a way to read or set values from the <appSettings> field in the azure-maven-plugin ?
<plugin>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-functions-maven-plugin</artifactId>
<version>${azure.functions.maven.plugin.version}</version>
<configuration>
<!-- function app name -->
<appName>${functionAppName}</appName>
<!-- function app resource group -->
<resourceGroup>${resourceGroupName}</resourceGroup>
<!-- function app service plan name -->
<appServicePlanName>${appServicePlanName}</appServicePlanName>
<!-- function app region-->
<!-- refers https://github.com/microsoft/azure-maven-plugins/wiki/Azure-Functions:-Configuration-Details#supported-regions for all valid values -->
<region>${azure.region}</region>
<!-- function pricingTier, default to be consumption if not specified -->
<!-- refers https://github.com/microsoft/azure-maven-plugins/wiki/Azure-Functions:-Configuration-Details#supported-pricing-tiers for all valid values -->
<!-- <pricingTier></pricingTier> -->
<!-- Whether to disable application insights, default is false -->
<!-- refers https://github.com/microsoft/azure-maven-plugins/wiki/Azure-Functions:-Configuration-Details for all valid configurations for application insights-->
<!-- <disableAppInsights></disableAppInsights> -->
<runtime>
<!-- runtime os, could be windows, linux or docker-->
<os>Linux</os>
<javaVersion>11</javaVersion>
<!-- for docker function, please set the following parameters -->
<!-- <image>[hub-user/]repo-name[:tag]</image> -->
<!-- <serverId></serverId> -->
<!-- <registryUrl></registryUrl> -->
</runtime>
<appSettings>
<property>
<name>FUNCTIONS_EXTENSION_VERSION</name>
<value>~4</value>
</property>
</appSettings>
</configuration>
<executions>
<execution>
<id>package-functions</id>
<goals>
<goal>package</goal>
</goals>
</execution>
</executions>
</plugin>
Something like
System.getenv("FUNCTIONS_EXTENSION_VERSION");
or
System.getProperty("FUNCTIONS_EXTENSION_VERSION");
@sreyanps Thanks for your report and really sorry for the late response. Yes you could get the app settings with System.getenv("FUNCTIONS_EXTENSION_VERSION");
, and functions maven plugin will help you set the app settings defined in pom to Azure after deployment.
However, if you want to test it locally with mvn azure-functions:run
, you need to set the value in local.settings.json
, which by default locate in the root of your project, here is an example
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "",
"FUNCTIONS_WORKER_RUNTIME": "java",
"FUNCTIONS_EXTENSION_VERSION": "4"
}
}