Skip to content

Commit 719c865

Browse files
Create azure-functions-app-nodejs.yml
1 parent a9df378 commit 719c865

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# This workflow will build a Node.js 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.
4+
# For instructions see:
5+
# - https://learn.microsoft.com/en-us/azure/azure-functions/create-first-function-vs-code-node
6+
# - https://learn.microsoft.com/en-us/azure/azure-functions/create-first-function-vs-code-typescript
7+
#
8+
# To configure this workflow:
9+
# 1. Set up the following secrets in your repository:
10+
# - AZURE_FUNCTIONAPP_PUBLISH_PROFILE
11+
# 2. Change env variables for your configuration.
12+
#
13+
# For more information on:
14+
# - GitHub Actions for Azure: https://github.com/Azure/Actions
15+
# - Azure Functions Action: https://github.com/Azure/functions-action
16+
# - Publish Profile: https://github.com/Azure/functions-action#using-publish-profile-as-deployment-credential-recommended
17+
# - Azure Service Principal for RBAC: https://github.com/Azure/functions-action#using-azure-service-principal-for-rbac-as-deployment-credential
18+
#
19+
# For more samples to get started with GitHub Action workflows to deploy to Azure: https://github.com/Azure/actions-workflow-samples/tree/master/FunctionApp
20+
21+
name: Deploy Node.js project to Azure Function App
22+
23+
on:
24+
push:
25+
branches: ["main"]
26+
27+
env:
28+
AZURE_FUNCTIONAPP_NAME: 'your-app-name' # set this to your function app name on Azure
29+
AZURE_FUNCTIONAPP_PACKAGE_PATH: '.' # set this to the path to your function app project, defaults to the repository root
30+
NODE_VERSION: '20.x' # set this to the node version to use (e.g. '8.x', '10.x', '12.x')
31+
32+
jobs:
33+
build-and-deploy:
34+
runs-on: windows-latest # For Linux, use ubuntu-latest
35+
environment: dev
36+
steps:
37+
- name: 'Checkout GitHub Action'
38+
uses: actions/checkout@v4
39+
40+
# If you want to use Azure RBAC instead of Publish Profile, then uncomment the task below
41+
# - name: 'Login via Azure CLI'
42+
# uses: azure/login@v1
43+
# with:
44+
# creds: ${{ secrets.AZURE_RBAC_CREDENTIALS }} # set up AZURE_RBAC_CREDENTIALS secrets in your repository
45+
46+
- name: Setup Node ${{ env.NODE_VERSION }} Environment
47+
uses: actions/setup-node@v4
48+
with:
49+
node-version: ${{ env.NODE_VERSION }}
50+
51+
- name: 'Resolve Project Dependencies Using Npm'
52+
shell: pwsh # For Linux, use bash
53+
run: |
54+
pushd './${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}'
55+
npm install
56+
npm run build --if-present
57+
npm run test --if-present
58+
popd
59+
60+
- name: 'Run Azure Functions Action'
61+
uses: Azure/functions-action@v1
62+
id: fa
63+
with:
64+
app-name: ${{ env.AZURE_FUNCTIONAPP_NAME }}
65+
package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
66+
publish-profile: ${{ secrets.AZURE_FUNCTIONAPP_PUBLISH_PROFILE }} # Remove publish-profile to use Azure RBAC

0 commit comments

Comments
 (0)