Skip to content

Commit 20496eb

Browse files
Flanker32Phantsure
andauthored
Add workflow for Azure Function App with Gradle (actions#1963)
* Add starter workflow for Azure Function App with Gradle * Mark as preview * Fix properties for function gradle template * Add workflow and job level permissions to function gradle template --------- Co-authored-by: Sampark Sharma <phantsure@github.com>
1 parent b4e97ff commit 20496eb

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# This workflow will build a Java project and deploy it to an Azure Functions App on Windows or Linux when a commit is pushed to your default branch.
2+
#
3+
# This workflow assumes you have already created the target Azure Functions app and applied azure functions plugin for gradle.
4+
# For instructions see https://learn.microsoft.com/en-us/azure/azure-functions/functions-create-first-java-gradle
5+
#
6+
# To configure this workflow:
7+
# 1. Set up the following secrets in your repository:
8+
# - AZURE_FUNCTIONAPP_PUBLISH_PROFILE
9+
# 2. Change env variables for your configuration.
10+
#
11+
# For more information on:
12+
# - GitHub Actions for Azure: https://github.com/Azure/Actions
13+
# - Azure Functions Action: https://github.com/Azure/functions-action
14+
# - Publish Profile: https://github.com/Azure/functions-action#using-publish-profile-as-deployment-credential-recommended
15+
# - Azure Service Principal for RBAC: https://github.com/Azure/functions-action#using-azure-service-principal-for-rbac-as-deployment-credential
16+
#
17+
# For more samples to get started with GitHub Action workflows to deploy to Azure: https://github.com/Azure/actions-workflow-samples/tree/master/FunctionApp
18+
19+
name: Deploy Gradle Java project to Azure Function App
20+
21+
on:
22+
push:
23+
branches:
24+
- [$default-branch]
25+
26+
permissions:
27+
contents: read
28+
29+
env:
30+
AZURE_FUNCTIONAPP_NAME: 'your-app-name' # set this to your function app name on Azure
31+
BUILD_GRADLE_DIRECTORY: '.' # set this to the directory which contains build.gradle file
32+
JAVA_VERSION: '8' # set this to the java version to use (e.g. '8', '11', '17')
33+
34+
jobs:
35+
build-and-deploy:
36+
permissions:
37+
contents: none
38+
runs-on: windows-latest # For Linux, use ubuntu-latest
39+
environment: dev
40+
steps:
41+
- name: 'Checkout GitHub Action'
42+
uses: actions/checkout@v3
43+
44+
# If you want to use Azure RBAC instead of Publish Profile, then uncomment the task below
45+
# - name: 'Login via Azure CLI'
46+
# uses: azure/login@v1
47+
# with:
48+
# creds: ${{ secrets.AZURE_RBAC_CREDENTIALS }} # set up AZURE_RBAC_CREDENTIALS secrets in your repository
49+
50+
- name: Setup Java Sdk ${{ env.JAVA_VERSION }}
51+
uses: actions/setup-java@v1
52+
with:
53+
java-version: ${{ env.JAVA_VERSION }}
54+
55+
# Build function project with functions gradle plugin
56+
# For project with function plugin lower than 1.12.1, please make sure you have set same app name in gradle configuration
57+
- name: 'Restore Project Dependencies Using Gradle Plugin for Azure Functions'
58+
shell: pwsh # For Linux, use bash
59+
run: |
60+
pushd './${{ env.BUILD_GRADLE_DIRECTORY }}'
61+
gradle azureFunctionsPackage -DappName=${{ env.AZURE_FUNCTIONAPP_NAME }}
62+
popd
63+
64+
- name: 'Run Azure Functions Action'
65+
uses: Azure/functions-action@v1
66+
id: fa
67+
with:
68+
app-name: ${{ env.AZURE_FUNCTIONAPP_NAME }}
69+
package: '${{ env.BUILD_GRADLE_DIRECTORY }}/build/azure-functions/${{ env.AZURE_FUNCTIONAPP_NAME }}'
70+
publish-profile: ${{ secrets.AZURE_FUNCTIONAPP_PUBLISH_PROFILE }} # Remove publish-profile to use Azure RBAC
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "Deploy Gradle app to Azure Functions App",
3+
"description": "Build a Java project and deploy it to an Azure Functions App on Windows or Linux.",
4+
"creator": "Microsoft Azure",
5+
"iconName": "azure",
6+
"categories": ["Deployment", "Java", "Gradle", "Azure Functions"],
7+
"labels": ["preview"]
8+
}

0 commit comments

Comments
 (0)