This plugin provides seamless integration into Gradle projects. You can package a Java Functions project, run it locally or deploy it to Azure with tasks provided by this plugin.
Tool | Required Version |
---|---|
JDK | 1.8 |
Gradle | 5.2 and above |
.Net Core SDK | Latest version |
Azure Functions Core Tools | 2.0 and above |
In your Gradle Java project, add the plugin to your build.gradle
:
plugins {
id "com.microsoft.azure.azurefunctions" version "1.8.0"
}
Here is a sample configuration, for details, please refer to this document.
azurefunctions {
subscription = <your subscription id>
resourceGroup = <your resource group>
appName = <your function app name>
pricingTier = <price tier like 'Consumption'>
region = <region like 'westus'>
runtime {
os = <os like 'windows'>
}
appSettings {
<key> = <value>
}
auth {
type = 'azure_cli'
}
// enable local debug
// localDebug = "transport=dt_socket,server=y,suspend=n,address=5005"
deployment {
type = 'run_from_blob'
}
}
azurefunctions {
subscription = "<your subscription id>"
resourceGroup = "<your resource group>"
appName = "<your function app name>"
pricingTier = "<price tier like 'Consumption'>"
region = "<region like 'westus'>"
setRuntime(closureOf<com.microsoft.azure.gradle.configuration.GradleRuntimeConfig> {
os("Windows")
})
setAppSettings(closureOf<MutableMap<String, String>> {
put("key", "value")
})
setAuth(closureOf<com.microsoft.azure.gradle.auth.GradleAuthConfig> {
type = "azure_cli"
})
// enable local debug
// localDebug = "transport=dt_socket,server=y,suspend=n,address=5005"
setDeployment(closureOf<com.microsoft.azure.plugin.functions.gradle.configuration.deploy.Deployment> {
type = "run_from_blob"
})
}
Use the script below to package your staging folder:
gradle azureFunctionsPackage
or package the staging folder with a zip file:
gradle azureFunctionsPackageZip
Use the script below to run the function locally, if you want to debug your functions, please add localDebug = "transport=dt_socket,server=y,suspend=n,address=5005"
to the azurefunctions
section of your build.gradle.
gradle azureFunctionsRun
gradle azureFunctionsDeploy
Q: How to do when reporting "Cannot run functions locally due to error: Azure Functions Core Tools can not be found."
A: You can install Azure Functions Core Tools at: https://aka.ms/azfunc-install
To report bugs or request new features, file issues on Issues. Or, ask questions on Stack Overflow with tag azure-java-tools.
This project collects usage data and sends it to Microsoft to help improve our products and services.
Read Microsoft's privacy statement to learn more.
If you would like to opt out of sending telemetry data to Microsoft, you can set allowTelemetry
to false in the plugin configuration.
Please read our document to find more details about allowTelemetry.