Deploy Azure Function App #6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy Azure Function App | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
paths: | |
- 'tools/deploy/module2/**' | |
- 'azure-function-workflow.yaml' | |
env: | |
AZURE_FUNCTIONAPP_PACKAGE_PATH: 'tools/deploy/module1/TransactionClassifier/' # 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') | |
AZURE_RESOURCE_GROUP: ${{ secrets.AZURE_RESOURCE_GROUP }} | |
permissions: | |
id-token: write # This is required for requesting the JWT | |
contents: read # This is required for actions/checkout | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: 'Checkout GitHub Action' | |
uses: actions/checkout@main | |
- name: 'Login via Azure CLI' | |
uses: azure/login@v1 | |
with: | |
client-id: ${{ secrets.AZURE_CLIENT_ID }} | |
tenant-id: ${{ secrets.AZURE_TENANT_ID }} | |
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | |
- name: 'retrieve the Function App name' | |
id: get_functionapp_name | |
uses: azure/CLI@v1 | |
with: | |
azcliversion: latest | |
inlineScript: | | |
echo "appName=$(az functionapp list --resource-group ${{ env.AZURE_RESOURCE_GROUP }} --query "[].name" -o tsv)" >> $GITHUB_OUTPUT | |
- 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: 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: | |
# set app_name equal to output from "retrieve the Function App name" step | |
app-name: ${{ steps.get_functionapp_name.outputs.appname }} | |
package: '${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}/output' | |
publish-profile: ${{ secrets.AZURE_FUNCTIONAPP_PUBLISH_PROFILE }} | |
# For more samples to get started with GitHub Action workflows to deploy to Azure, refer to https://github.com/Azure/actions-workflow-samples |