Files
starter-workflows/deployments/azure-functions-app-container.yml
T

80 lines
3.2 KiB
YAML
Raw Normal View History

2022-11-08 13:07:25 -06:00
# 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
2022-10-07 16:03:49 -05:00
2022-11-08 13:07:25 -06:00
name: Deploy container to Azure Functions App
2022-10-07 16:03:49 -05:00
on:
push:
branches: [$default-branch]
2022-11-08 13:07:25 -06:00
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
2022-10-07 16:03:49 -05:00
jobs:
build-and-deploy:
runs-on: ubuntu-latest
environment: dev
steps:
- name: 'Checkout GitHub Action'
uses: actions/checkout@v4
2022-10-07 16:03:49 -05:00
- name: 'Login via Azure CLI'
uses: azure/login@v1
with:
2022-11-08 13:07:25 -06:00
creds: ${{ secrets.AZURE_RBAC_CREDENTIALS }}
2022-10-07 16:03:49 -05:00
- name: 'Docker Login'
uses: azure/docker-login@v1
with:
2022-11-08 13:07:25 -06:00
login-server: ${{ env.LOGIN_SERVER }}
2022-10-07 16:03:49 -05:00
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
2022-11-08 13:07:25 -06:00
docker build . -t ${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.IMAGE }}:${{ env.TAG }}
docker push ${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.IMAGE }}:${{ env.TAG }}
2022-10-07 16:03:49 -05:00
- name: 'Run Azure Functions Container Action'
uses: Azure/functions-container-action@v1
id: fa
with:
2022-11-08 13:07:25 -06:00
app-name: ${{ env.AZURE_FUNCTIONAPP_NAME }}
image: ${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.IMAGE }}:${{ env.TAG }}
2022-10-07 16:03:49 -05:00
2022-11-08 13:07:25 -06:00
# If you want to display or use the functionapp url, then uncomment the task below
#- name: 'Published functionapp url'
2022-10-07 16:03:49 -05:00
# run: |
# echo "${{ steps.fa.outputs.app-url }}"
- name: Azure logout
run: |
2022-11-08 13:07:25 -06:00
az logout