Skip to content

lulzzz/azure-functions-dotnet-5-sample

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Azure Functions .NET 5 Sample Project

Sample GitHub Actions CI/CD Pipeline for Azure Function .NET 5 Isolated Process.

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

Setup Notes

  1. Clone/fork this repo
  2. 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 sample local.settings.json is below. You can also download a full sample here.
{
    "IsEncrypted": false,
    "Values": {
        "AzureWebJobsStorage": "",
        "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated"
    }
}
  1. 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 :)

Option 1: Deploying with Azure Functions GitHub Action

See YAML file dotnet.yml here.

  1. Go to your Azure Function App overview blade. Download the publish profile. Open up the txt file and copy the entire contents.

Download Publish Profile Image

  1. Save the contents as a GitHub Action Secret titled AZURE_FUNCTION_PUBLISH_CREDS
  2. 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.

Option 2: Deploying with the Azure Function Core Tools

See YAML file dotnet2.yml here.

  1. 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>
  1. 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,

IAM Security View

  1. 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.
  2. 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
  1. Kick off the GitHub Action to deploy your .NET 5 Isolated Process Azure Function App!

About

Sample GitHub Actions CI/CD Pipeline for Azure Function .NET 5 Isolated Process

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%