Skip to content

Latest commit

 

History

History
114 lines (97 loc) · 4.08 KB

File metadata and controls

114 lines (97 loc) · 4.08 KB

Azure Functions Plugin for Gradle

Gradle Plugin Portal

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.

Prerequisites

Tool Required Version
JDK 1.8
Gradle 5.2 and above
.Net Core SDK Latest version
Azure Functions Core Tools 2.0 and above

Note: See how to install Azure Functions Core Tools - 2.x

Setup

In your Gradle Java project, add the plugin to your build.gradle:

plugins {
  id "com.microsoft.azure.azurefunctions" version "1.8.0"
}

Configuration

Here is a sample configuration, for details, please refer to this document.

Groovy DSL

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'
    }
}

Kotlin DSL

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"
  })
}

Usage

Package Staging folder

Use the script below to package your staging folder:

gradle azureFunctionsPackage

or package the staging folder with a zip file:

gradle azureFunctionsPackageZip

Run Azure Functions locally

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

Deploy Azure Functions to Azure Cloud

gradle azureFunctionsDeploy

Common Questions

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

Feedback and Questions

To report bugs or request new features, file issues on Issues. Or, ask questions on Stack Overflow with tag azure-java-tools.

Data and 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 in the plugin configuration. Please read our document to find more details about allowTelemetry.