Deploying on Azure Functions - GitHub Actions
This post is about deploying Azure Function with the help of GitHub Actions. In this post we will discuss how a .NET 6.0 Azure function can be deployed to Azure with the help of GitHub Actions - which will help you to implement continuous delivery / deployment for Azure Functions. First we need to create an Azure Function - I am doing it in the Portal. I am creating a .NET Function.
Then using Azure Function CLI I am developing a .NET 6 function and I commit that function to GitHub repository. And then I am creating a GitHub Action. To deploy the function, you need to download the
Publish Profile of the Azure Function. Open the
PublishSettings file - it is an XML format - in notepad.
And create a GitHub Action secret with that value. To create the Secret, go to the Settings > Secrets > Actions. And in the screen, click on the
New repository secret button. Set the
Name field as
AZURE_FUNCTIONAPP_PUBLISH_PROFILE and in the value field, the contents of the Publish settings file. And save it.
Now we can start creating the Azure Function deployment script. We need to follow the exact same steps what we are doing in a normal dotnet app deployment, like -
- Setting up the environment - Download and install the .NET 6 SDK.
- Restore the nuget packages with
- Build the app in Release configuration.
- Deploy it to Azure Functions.
I created a blank workflow and modified it like this.
Once it is deployed, you will be able to see something like this in the GitHub Actions.
Happy Programming :)