Sample GitHub Actions CI/CD Pipeline for Azure Function .NET 5 Isolated Process.
YouTube video that walks through this repo is below,
Public docs for Azure Functions with the new .NET 5 isolated process setup can be found below,
https://docs.microsoft.com/en-us/azure/azure-functions/dotnet-isolated-process-guide
The public GitHub repo for the Azure Functions dotnet Worker is below,
https://github.com/Azure/azure-functions-dotnet-worker
And the public GitHub repo for the Azure Functions Core commandline tooling can be found here,
https://github.com/Azure/azure-functions-core-tools
- Clone/fork this repo
- Create a local file in the root of the Sample.FunctionApp project
local.settings.json
. There is a.gitignore
setting to not check this file into source code. A samplelocal.settings.json
is below. You can also download a full sample here.
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "",
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated"
}
}
- Create an Azure Function resource in your own Azure subscription. Public docs on how to do this can be found here.
You can choose two different options below for how to get the Azure Function App deployed :)
See YAML file dotnet.yml
here.
- Go to your Azure Function App overview blade. Download the publish profile. Open up the txt file and copy the entire contents.
- Save the contents as a GitHub Action Secret titled
AZURE_FUNCTION_PUBLISH_CREDS
- Kick off the GitHub Action to deploy your .NET 5 Isotated Processs Azure Function App!
NOTE: if you see the following error, you need to remove the settting
WEBSITE_RUN_FROM_PACKAGE
from the configuration blade of your Azure Function App in the Azure Portal,
When request Azure resource at PublishContent, zipDepoy : WEBSITE_RUN_FROM_PACKAGE in your function app is set to an URL. Please remove WEBSITE_RUN_FROM_PACKAGE app setting from your function app.
See YAML file dotnet2.yml
here.
- Create an AAD Service Principal that has contribute permissions to the Azure Function resource. Easiest way to do this is to launch the Azure Cloud Shell in the Azure Portal
az ad sp create-for-rbac --name "<FUNCTION_APP_NAME>-sp" --sdk-auth --role contributor --scopes /subscriptions/<SUBSCRIPTION_GUID>/resourcegroups/<RESOURCE_GROUP>/providers/Microsoft.Web/sites/<FUNCTION_APP_NAME>
- Once you complete this, you will see the new Service Principal with an assigned contributor role in the IAM blade for the Azure Function App,
- Save the entire JSON output of the PowerShell operations to a GitHub Action Secret with the name
AZURE_CREDS_FUNCTION_APP
. This enables you to securely reference this credential in GitHub Actions to authenticate to Azure. - Update the
dotnet2.yml
file to specify the actual Azure Function resource name you created previously. Snippet included below, the full YAML file can be found here
env:
AZURE_FUNCTIONAPP_NAME: <ACTUAL_FUNCTION_RESOURCE_NAME> # set this to the name of your azure function app resource
AZURE_FUNCTION_PROJ_PATH: src/Sample.FunctionApp # set this to the path to your function app project
ROOT_SOLUTION_PATH: src # set this to the root path of your solution/project file
- Kick off the GitHub Action to deploy your .NET 5 Isolated Process Azure Function App!