Merge pull request #1780 from patelchandni/main
Starter Workflows for Azure Function App
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
# This workflow will build a container and deploy it to an Azure Functions App on Linux when a commit is pushed to your default branch.
|
||||
#
|
||||
# This workflow assumes you have already created the target Azure Functions app.
|
||||
# For instructions see https://learn.microsoft.com/en-us/azure/azure-functions/functions-create-function-linux-custom-image?tabs=in-process%2Cbash%2Cazure-cli&pivots=programming-language-csharp
|
||||
#
|
||||
# To configure this workflow:
|
||||
# 1. Set up the following secrets in your repository:
|
||||
# - AZURE_RBAC_CREDENTIALS
|
||||
# - REGISTRY_USERNAME
|
||||
# - REGISTRY_PASSWORD
|
||||
# 2. Change env variables for your configuration.
|
||||
#
|
||||
# For more information on:
|
||||
# - GitHub Actions for Azure: https://github.com/Azure/Actions
|
||||
# - Azure Functions Container Action: https://github.com/Azure/functions-container-action
|
||||
# - Azure Service Principal for RBAC: https://github.com/Azure/functions-action#using-azure-service-principal-for-rbac-as-deployment-credential
|
||||
#
|
||||
# For more samples to get started with GitHub Action workflows to deploy to Azure: https://github.com/Azure/actions-workflow-samples/tree/master/FunctionApp
|
||||
|
||||
name: Deploy container to Azure Functions App
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- [$default-branch]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
env:
|
||||
AZURE_FUNCTIONAPP_NAME: 'your-app-name' # set this to your function app name on Azure
|
||||
LOGIN_SERVER: 'login-server' # set this to login server for your private container registry (e.g. 'contoso.azurecr.io', 'index.docker.io' )
|
||||
REGISTRY: 'your-registry' # set this to proper value for REGISTRY
|
||||
NAMESPACE: 'your-namespace' # set this to proper value for NAMESPACE
|
||||
IMAGE: 'your-image' # set this to proper value for IMAGE
|
||||
TAG: 'your-tag' # set this to proper value for TAG
|
||||
|
||||
jobs:
|
||||
build-and-deploy:
|
||||
runs-on: ubuntu-latest
|
||||
environment: dev
|
||||
steps:
|
||||
- name: 'Checkout GitHub Action'
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: 'Login via Azure CLI'
|
||||
uses: azure/login@v1
|
||||
with:
|
||||
creds: ${{ secrets.AZURE_RBAC_CREDENTIALS }}
|
||||
|
||||
- name: 'Docker Login'
|
||||
uses: azure/docker-login@v1
|
||||
with:
|
||||
login-server: ${{ env.LOGIN_SERVER }}
|
||||
username: ${{ secrets.REGISTRY_USERNAME }}
|
||||
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
|
||||
- name: 'Compose Customized Docker Image'
|
||||
shell: bash
|
||||
run: |
|
||||
# If your function app project is not located in your repository's root
|
||||
# Please change the path to your directory for docker build
|
||||
docker build . -t ${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.IMAGE }}:${{ env.TAG }}
|
||||
docker push ${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.IMAGE }}:${{ env.TAG }}
|
||||
|
||||
- name: 'Run Azure Functions Container Action'
|
||||
uses: Azure/functions-container-action@v1
|
||||
id: fa
|
||||
with:
|
||||
app-name: ${{ env.AZURE_FUNCTIONAPP_NAME }}
|
||||
image: ${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.IMAGE }}:${{ env.TAG }}
|
||||
|
||||
# If you want to display or use the functionapp url, then uncomment the task below
|
||||
#- name: 'Published functionapp url'
|
||||
# run: |
|
||||
# echo "${{ steps.fa.outputs.app-url }}"
|
||||
|
||||
- name: Azure logout
|
||||
run: |
|
||||
az logout
|
||||
@@ -0,0 +1,64 @@
|
||||
# This workflow will build a .NET Core project and deploy it to an Azure Functions App on Windows or Linux when a commit is pushed to your default branch.
|
||||
#
|
||||
# This workflow assumes you have already created the target Azure Functions app.
|
||||
# For instructions see https://learn.microsoft.com/en-us/azure/azure-functions/create-first-function-vs-code-csharp?tabs=in-process
|
||||
#
|
||||
# To configure this workflow:
|
||||
# 1. Set up the following secrets in your repository:
|
||||
# - AZURE_FUNCTIONAPP_PUBLISH_PROFILE
|
||||
# 2. Change env variables for your configuration.
|
||||
#
|
||||
# For more information on:
|
||||
# - GitHub Actions for Azure: https://github.com/Azure/Actions
|
||||
# - Azure Functions Action: https://github.com/Azure/functions-action
|
||||
# - Publish Profile: https://github.com/Azure/functions-action#using-publish-profile-as-deployment-credential-recommended
|
||||
# - Azure Service Principal for RBAC: https://github.com/Azure/functions-action#using-azure-service-principal-for-rbac-as-deployment-credential
|
||||
#
|
||||
# For more samples to get started with GitHub Action workflows to deploy to Azure: https://github.com/Azure/actions-workflow-samples/tree/master/FunctionApp
|
||||
|
||||
name: Deploy DotNet project to Azure Function App
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- [$default-branch]
|
||||
|
||||
env:
|
||||
AZURE_FUNCTIONAPP_NAME: 'your-app-name' # set this to your function app name on Azure
|
||||
AZURE_FUNCTIONAPP_PACKAGE_PATH: '.' # set this to the path to your function app project, defaults to the repository root
|
||||
DOTNET_VERSION: '6.0.x' # set this to the dotnet version to use (e.g. '2.1.x', '3.1.x', '5.0.x')
|
||||
|
||||
jobs:
|
||||
build-and-deploy:
|
||||
runs-on: windows-latest # For Linux, use ubuntu-latest
|
||||
environment: dev
|
||||
steps:
|
||||
- name: 'Checkout GitHub Action'
|
||||
uses: actions/checkout@v3
|
||||
|
||||
# If you want to use Azure RBAC instead of Publish Profile, then uncomment the task below
|
||||
# - name: 'Login via Azure CLI'
|
||||
# uses: azure/login@v1
|
||||
# with:
|
||||
# creds: ${{ secrets.AZURE_RBAC_CREDENTIALS }} # set up AZURE_RBAC_CREDENTIALS secrets in your repository
|
||||
|
||||
- name: Setup DotNet ${{ env.DOTNET_VERSION }} Environment
|
||||
uses: actions/setup-dotnet@v3
|
||||
with:
|
||||
dotnet-version: ${{ env.DOTNET_VERSION }}
|
||||
|
||||
- name: 'Resolve Project Dependencies Using Dotnet'
|
||||
shell: pwsh # For Linux, use bash
|
||||
run: |
|
||||
pushd './${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}'
|
||||
dotnet build --configuration Release --output ./output
|
||||
popd
|
||||
|
||||
- name: 'Run Azure Functions Action'
|
||||
uses: Azure/functions-action@v1
|
||||
id: fa
|
||||
with:
|
||||
app-name: ${{ env.AZURE_FUNCTIONAPP_NAME }}
|
||||
package: '${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}/output'
|
||||
publish-profile: ${{ secrets.AZURE_FUNCTIONAPP_PUBLISH_PROFILE }} # Remove publish-profile to use Azure RBAC
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
# 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.
|
||||
#
|
||||
# This workflow assumes you have already created the target Azure Functions app.
|
||||
# For instructions see https://learn.microsoft.com/en-us/azure/azure-functions/create-first-function-vs-code-java
|
||||
#
|
||||
# To configure this workflow:
|
||||
# 1. Set up the following secrets in your repository:
|
||||
# - AZURE_FUNCTIONAPP_PUBLISH_PROFILE
|
||||
# 2. Change env variables for your configuration.
|
||||
#
|
||||
# For more information on:
|
||||
# - GitHub Actions for Azure: https://github.com/Azure/Actions
|
||||
# - Azure Functions Action: https://github.com/Azure/functions-action
|
||||
# - Publish Profile: https://github.com/Azure/functions-action#using-publish-profile-as-deployment-credential-recommended
|
||||
# - Azure Service Principal for RBAC: https://github.com/Azure/functions-action#using-azure-service-principal-for-rbac-as-deployment-credential
|
||||
#
|
||||
# For more samples to get started with GitHub Action workflows to deploy to Azure: https://github.com/Azure/actions-workflow-samples/tree/master/FunctionApp
|
||||
|
||||
name: Deploy Java project to Azure Function App
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- [$default-branch]
|
||||
|
||||
env:
|
||||
AZURE_FUNCTIONAPP_NAME: 'your-app-name' # set this to your function app name on Azure
|
||||
POM_XML_DIRECTORY: '.' # set this to the directory which contains pom.xml file
|
||||
JAVA_VERSION: '8' # set this to the java version to use (e.g. '8', '11', '17')
|
||||
|
||||
jobs:
|
||||
build-and-deploy:
|
||||
runs-on: windows-latest # For Linux, use ubuntu-latest
|
||||
environment: dev
|
||||
steps:
|
||||
- name: 'Checkout GitHub Action'
|
||||
uses: actions/checkout@v3
|
||||
|
||||
# If you want to use Azure RBAC instead of Publish Profile, then uncomment the task below
|
||||
# - name: 'Login via Azure CLI'
|
||||
# uses: azure/login@v1
|
||||
# with:
|
||||
# creds: ${{ secrets.AZURE_RBAC_CREDENTIALS }} # set up AZURE_RBAC_CREDENTIALS secrets in your repository
|
||||
|
||||
- name: Setup Java Sdk ${{ env.JAVA_VERSION }}
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: ${{ env.JAVA_VERSION }}
|
||||
|
||||
- name: 'Restore Project Dependencies Using Mvn'
|
||||
shell: pwsh # For Linux, use bash
|
||||
run: |
|
||||
pushd './${{ env.POM_XML_DIRECTORY }}'
|
||||
mvn clean package
|
||||
popd
|
||||
|
||||
- name: 'Run Azure Functions Action'
|
||||
uses: Azure/functions-action@v1
|
||||
id: fa
|
||||
with:
|
||||
app-name: ${{ env.AZURE_FUNCTIONAPP_NAME }}
|
||||
package: '${{ env.POM_XML_DIRECTORY }}' # if there are multiple function apps in same project, then this path will be like './${{ env.POM_XML_DIRECTORY }}/target/azure-functions/${{ env.POM_FUNCTIONAPP_NAME }'
|
||||
publish-profile: ${{ secrets.AZURE_FUNCTIONAPP_PUBLISH_PROFILE }} # Remove publish-profile to use Azure RBAC
|
||||
respect-pom-xml: true
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
# 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.
|
||||
#
|
||||
# This workflow assumes you have already created the target Azure Functions app.
|
||||
# For instructions see:
|
||||
# - https://learn.microsoft.com/en-us/azure/azure-functions/create-first-function-vs-code-node
|
||||
# - https://learn.microsoft.com/en-us/azure/azure-functions/create-first-function-vs-code-typescript
|
||||
#
|
||||
# To configure this workflow:
|
||||
# 1. Set up the following secrets in your repository:
|
||||
# - AZURE_FUNCTIONAPP_PUBLISH_PROFILE
|
||||
# 2. Change env variables for your configuration.
|
||||
#
|
||||
# For more information on:
|
||||
# - GitHub Actions for Azure: https://github.com/Azure/Actions
|
||||
# - Azure Functions Action: https://github.com/Azure/functions-action
|
||||
# - Publish Profile: https://github.com/Azure/functions-action#using-publish-profile-as-deployment-credential-recommended
|
||||
# - Azure Service Principal for RBAC: https://github.com/Azure/functions-action#using-azure-service-principal-for-rbac-as-deployment-credential
|
||||
#
|
||||
# For more samples to get started with GitHub Action workflows to deploy to Azure: https://github.com/Azure/actions-workflow-samples/tree/master/FunctionApp
|
||||
|
||||
name: Deploy Node.js project to Azure Function App
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- [$default-branch]
|
||||
|
||||
env:
|
||||
AZURE_FUNCTIONAPP_NAME: 'your-app-name' # set this to your function app name on Azure
|
||||
AZURE_FUNCTIONAPP_PACKAGE_PATH: '.' # set this to the path to your function app project, defaults to the repository root
|
||||
NODE_VERSION: '16.x' # set this to the node version to use (e.g. '8.x', '10.x', '12.x')
|
||||
|
||||
jobs:
|
||||
build-and-deploy:
|
||||
runs-on: windows-latest # For Linux, use ubuntu-latest
|
||||
environment: dev
|
||||
steps:
|
||||
- name: 'Checkout GitHub Action'
|
||||
uses: actions/checkout@v3
|
||||
|
||||
# If you want to use Azure RBAC instead of Publish Profile, then uncomment the task below
|
||||
# - name: 'Login via Azure CLI'
|
||||
# uses: azure/login@v1
|
||||
# with:
|
||||
# creds: ${{ secrets.AZURE_RBAC_CREDENTIALS }} # set up AZURE_RBAC_CREDENTIALS secrets in your repository
|
||||
|
||||
- name: Setup Node ${{ env.NODE_VERSION }} Environment
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
|
||||
- name: 'Resolve Project Dependencies Using Npm'
|
||||
shell: pwsh # For Linux, use bash
|
||||
run: |
|
||||
pushd './${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}'
|
||||
npm install
|
||||
npm run build --if-present
|
||||
npm run test --if-present
|
||||
popd
|
||||
|
||||
- name: 'Run Azure Functions Action'
|
||||
uses: Azure/functions-action@v1
|
||||
id: fa
|
||||
with:
|
||||
app-name: ${{ env.AZURE_FUNCTIONAPP_NAME }}
|
||||
package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
|
||||
publish-profile: ${{ secrets.AZURE_FUNCTIONAPP_PUBLISH_PROFILE }} # Remove publish-profile to use Azure RBAC
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
# This workflow will deploy a PowerShell project to an Azure Functions App on Windows or Linux when a commit is pushed to your default branch.
|
||||
#
|
||||
# This workflow assumes you have already created the target Azure Functions app.
|
||||
# For instructions see https://learn.microsoft.com/en-us/azure/azure-functions/create-first-function-vs-code-powershell
|
||||
#
|
||||
# To configure this workflow:
|
||||
# 1. Set up the following secrets in your repository:
|
||||
# - AZURE_FUNCTIONAPP_PUBLISH_PROFILE
|
||||
# 2. Change env variables for your configuration.
|
||||
#
|
||||
# For more information on:
|
||||
# - GitHub Actions for Azure: https://github.com/Azure/Actions
|
||||
# - Azure Functions Action: https://github.com/Azure/functions-action
|
||||
# - Publish Profile: https://github.com/Azure/functions-action#using-publish-profile-as-deployment-credential-recommended
|
||||
# - Azure Service Principal for RBAC: https://github.com/Azure/functions-action#using-azure-service-principal-for-rbac-as-deployment-credential
|
||||
#
|
||||
# For more samples to get started with GitHub Action workflows to deploy to Azure: https://github.com/Azure/actions-workflow-samples/tree/master/FunctionApp
|
||||
|
||||
name: Deploy PowerShell project to Azure Function App
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- [$default-branch]
|
||||
|
||||
env:
|
||||
AZURE_FUNCTIONAPP_NAME: 'your-app-name' # set this to your function app name on Azure
|
||||
AZURE_FUNCTIONAPP_PACKAGE_PATH: '.' # set this to the path to your function app project, defaults to the repository root
|
||||
|
||||
jobs:
|
||||
build-and-deploy:
|
||||
runs-on: windows-latest # For Linux, use ubuntu-latest
|
||||
environment: dev
|
||||
steps:
|
||||
- name: 'Checkout GitHub Action'
|
||||
uses: actions/checkout@v3
|
||||
|
||||
# If you want to use Azure RBAC instead of Publish Profile, then uncomment the task below
|
||||
# - name: 'Login via Azure CLI'
|
||||
# uses: azure/login@v1
|
||||
# with:
|
||||
# creds: ${{ secrets.AZURE_RBAC_CREDENTIALS }} # set up AZURE_RBAC_CREDENTIALS secrets in your repository
|
||||
|
||||
- name: 'Run Azure Functions Action'
|
||||
uses: Azure/functions-action@v1
|
||||
id: fa
|
||||
with:
|
||||
app-name: ${{ env.AZURE_FUNCTIONAPP_NAME }}
|
||||
package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
|
||||
publish-profile: ${{ secrets.AZURE_FUNCTIONAPP_PUBLISH_PROFILE }} # Remove publish-profile to use Azure RBAC
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
# This workflow will build a Python app and deploy it to an Azure Functions App on Linux when a commit is pushed to your default branch.
|
||||
#
|
||||
# This workflow assumes you have already created the target Azure Functions app.
|
||||
# For instructions see https://learn.microsoft.com/en-us/azure/azure-functions/create-first-function-vs-code-python?pivots=python-mode-configuration
|
||||
#
|
||||
# To configure this workflow:
|
||||
# 1. Set up the following secrets in your repository:
|
||||
# - AZURE_FUNCTIONAPP_PUBLISH_PROFILE
|
||||
# 2. Change env variables for your configuration.
|
||||
#
|
||||
# For more information on:
|
||||
# - GitHub Actions for Azure: https://github.com/Azure/Actions
|
||||
# - Azure Functions Action: https://github.com/Azure/functions-action
|
||||
# - Publish Profile: https://github.com/Azure/functions-action#using-publish-profile-as-deployment-credential-recommended
|
||||
# - Azure Service Principal for RBAC: https://github.com/Azure/functions-action#using-azure-service-principal-for-rbac-as-deployment-credential
|
||||
#
|
||||
# For more samples to get started with GitHub Action workflows to deploy to Azure: https://github.com/Azure/actions-workflow-samples/tree/master/FunctionApp
|
||||
|
||||
name: Deploy Python project to Azure Function App
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- [$default-branch]
|
||||
|
||||
env:
|
||||
AZURE_FUNCTIONAPP_NAME: 'your-app-name' # set this to your function app name on Azure
|
||||
AZURE_FUNCTIONAPP_PACKAGE_PATH: '.' # set this to the path to your function app project, defaults to the repository root
|
||||
PYTHON_VERSION: '3.9' # set this to the python version to use (e.g. '3.6', '3.7', '3.8')
|
||||
|
||||
jobs:
|
||||
build-and-deploy:
|
||||
runs-on: ubuntu-latest
|
||||
environment: dev
|
||||
steps:
|
||||
- name: 'Checkout GitHub Action'
|
||||
uses: actions/checkout@v3
|
||||
|
||||
# If you want to use Azure RBAC instead of Publish Profile, then uncomment the task below
|
||||
# - name: 'Login via Azure CLI'
|
||||
# uses: azure/login@v1
|
||||
# with:
|
||||
# creds: ${{ secrets.AZURE_RBAC_CREDENTIALS }} # set up AZURE_RBAC_CREDENTIALS secrets in your repository
|
||||
|
||||
- name: Setup Python ${{ env.PYTHON_VERSION }} Environment
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: ${{ env.PYTHON_VERSION }}
|
||||
|
||||
- name: 'Resolve Project Dependencies Using Pip'
|
||||
shell: bash
|
||||
run: |
|
||||
pushd './${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}'
|
||||
python -m pip install --upgrade pip
|
||||
pip install -r requirements.txt --target=".python_packages/lib/site-packages"
|
||||
popd
|
||||
|
||||
- name: 'Run Azure Functions Action'
|
||||
uses: Azure/functions-action@v1
|
||||
id: fa
|
||||
with:
|
||||
app-name: ${{ env.AZURE_FUNCTIONAPP_NAME }}
|
||||
package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
|
||||
publish-profile: ${{ secrets.AZURE_FUNCTIONAPP_PUBLISH_PROFILE }} # Remove publish-profile to use Azure RBAC
|
||||
scm-do-build-during-deployment: true
|
||||
enable-oryx-build: true
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"name": "Deploy container to Azure Functions App",
|
||||
"description": "Build a container and deploy it to an Azure Functions App on Linux.",
|
||||
"creator": "Microsoft Azure",
|
||||
"iconName": "azure",
|
||||
"categories": ["Deployment", "Dockerfile", "Azure Functions"]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"name": "Deploy .NET Core app to Azure Functions App",
|
||||
"description": "Build a .NET Core project and deploy it to an Azure Functions App on Windows or Linux.",
|
||||
"creator": "Microsoft Azure",
|
||||
"iconName": "azure",
|
||||
"categories": ["Deployment", "C#", "AspNetCore", "Azure Functions"]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"name": "Deploy Java app to Azure Functions App",
|
||||
"description": "Build a Java project and deploy it to an Azure Functions App on Windows or Linux.",
|
||||
"creator": "Microsoft Azure",
|
||||
"iconName": "azure",
|
||||
"categories": ["Deployment", "Java", "Maven", "Azure Functions"]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"name": "Deploy Node.js to Azure Functions App",
|
||||
"description": "Build a Node.js project and deploy it to an Azure Functions App on Windows or Linux.",
|
||||
"creator": "Microsoft Azure",
|
||||
"iconName": "azure",
|
||||
"categories": ["Deployment", "JavaScript", "TypeScript", "npm", "Azure Functions"]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"name": "Deploy PowerShell app to Azure Functions App",
|
||||
"description": "Deploy a PowerShell project to an Azure Functions App on Windows or Linux.",
|
||||
"creator": "Microsoft Azure",
|
||||
"iconName": "azure",
|
||||
"categories": ["Deployment", "PowerShell", "Azure Functions"]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"name": "Deploy Python app to Azure Functions App",
|
||||
"description": "Build a Python app and deploy it to an Azure Functions App on Linux.",
|
||||
"creator": "Microsoft Azure",
|
||||
"iconName": "azure",
|
||||
"categories": ["Deployment", "Python", "Pip", "Azure Functions"]
|
||||
}
|
||||
Reference in New Issue
Block a user