Last updated on June 17, 2023
1 Create an Azure Function App
rg, storage account, function app, not deployment is set up yet.
To set up deployment, webapipython | Deployment Center, we do that later
2 Create a GitHub repository
3 Clone GitHub Function repository
$ git clone firstname.lastname@example.org:spawnmarvel/test-webapipython.git
4 Link Azure Function App with GitHub Repository
init project, name is same as function app name in azure-automation
PS C:\giti2023\test-webapipython> func init webapipython
Create a function
C:\giti2023\test-webapipython\webapipython> func new –name testpy1 –template “HTTP trigger” –authlevel “anonymous”
Test the function
Save and commit the changes
5 Deploy Function App
This brings us to the last step, automating the deployment of our Functions with CI/CD using GitHub Actions
webapipython | Deployment Center
Add the repos (I think I added organization previous)
When you save on the configuration above, you will notice that on the GitHub repository there is a new automation workflow that is automatically created as well as a new repository secret.
The workflow will be located in a special folder called .github/workflows that is automatically created by Azure:
Note that the Publish Profile is actually stored as a GitHub Action Secret, this was also automatically created by Azure as part of the workflow YAML file:
Let’s trigger this workflow manually and deploy our function into the Azure Function App. In GitHub navigate to Actions, select the workflow and then Run Workflow:
Node.js 12 actions are deprecated. Please update the following actions to use Node.js 16: actions/checkout@v2, actions/setup-python@v1. For more information see: https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/.
$ git pull origin main
# edit from 2 to 3 - name: Checkout repository uses: actions/checkout@v3
Git add, commit and push.
Run actions again
ERROR: Could not open requirements file: [Errno 2] No such file or directory: ‘requirements.txt’
Hm, moved requirements.txt from
It started deploying at once
I have called the function URL, but it takes time…to build…
Last step I did was to edit the yaml file, did not read enough from the previous post
on: push: branches: - main paths: # elo. Added this - 'webapipython/**' # elo. Added this workflow_dispatch: env: # elo AZURE_FUNCTIONAPP_PACKAGE_PATH: '.' # set this to the path to your web app project, defaults to the repository root AZURE_FUNCTIONAPP_PACKAGE_PATH: 'webapipython' # elo set this to the path to your web app project, defaults to the repository root
And now it works
App in portal
App on URL
Lets make a small change to the code.
return func.HttpResponse( "Github Actions: This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.",
Push to git and deploy automatic from actions
When updating yaml file, the Github actions does not trigger, put a comment in a file with code and it will trigger, all changes.
For now we will lock the actions