Quickstart
How to develop Azure Functions use gradle
Prerequisites
| Tool | Required Version |
|---|---|
| JDK | 1.8 |
| Gradle | 4.10 and above |
| .Net Core SDK | Latest version |
| Azure CLI | Latest version |
Step 1: install Azure Functions Core Tools and Azure Cli
There are several ways of installing Azure Functions Core Tools, for example, use npm
```cmd
npm i -g azure-functions-core-tools@2 --unsafe-perm true
az login
az account set --subscription <your subscription id>
```
Step 2: create your Azure Functions project (Need to install maven to generate function archetype)
```cmd
mvn archetype:generate -DarchetypeGroupId=com.microsoft.azure -DarchetypeArtifactId=azure-functions-archetype
```
In the console prompt, input com.fabrikam.functions for groupId and fabrikam-functions for artifactId.
Step 3: create build.gradle (Need to install VSCode)
Open the generated folder fabrikam-functions in VSCode, create a new file build.gradle with the following content:
plugins {
id "com.microsoft.azure.azurefunctions" version "1.5.0"
}
apply plugin: "java"
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
group 'com.fabrikam.functions'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
implementation 'commons-io:commons-io:2.6'
testCompile group: 'junit', name: 'junit', version: '4.12'
implementation 'com.microsoft.azure.functions:azure-functions-java-library:1.4.0'
}
azurefunctions {
subscription = '__SUBSCRIPTION_ID__'
resourceGroup = '__RESOURCE_GROUP_NAME__'
appName = '__APP_NAME__'
pricingTier = '__PRICING_TIER__'
region = '__LOCATION_NAME__'
runtime {
os = 'windows'
}
// localDebug = "transport=dt_socket,server=y,suspend=n,address=5005"
}
Step 4: run gradle azureFunctionsPackage
This command will generate the staging folder, under the folder: build/azure-functions. The staging folder will be used to local run or deploy the function app. There is another similar task named azureFunctionsPackageZip which will generate a zip under the folder: build/azure-functions, this zip file can be deployed to Azure cloud manually.
Step 5: run gradle azureFunctionsRun
This command will run the functions on local azure function simulator, if you have not run gradle azureFunctionsPackage before, it will be triggered automatically so you needn't run gradle azureFunctionsPackage before azureFunctionsRun.
Step 6: run gradle azureFunctionsDeploy
This command will deploy the project to the target Function App defined at the azurefunctions section of build.gradle.
Telemetry
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 at the azurefunctions section of build.gradle.
azurefunctions {
subscription = '__SUBSCRIPTION_ID__'
...
allowTelemetry = false
}

