My AzureFunctionDemo repository demonstrates how you can build and deploy a C# Azure Function to an Azure Function using GitHub Actions.

What even are Functions?

If you’ve any done any software development before they are pretty much what they sound like; a small piece of code that is used to do a specific job. You know… a function. Actually that’s not fantastically helpful 😒. You will typically hear this type of processing referred to as Serverless, but don’t be fooled. There is still a server (or servers) in the background running your code, there is simply less ceremony, i.e. for the simplest of functions it is possible to get something up and running with a few clicks and and a few lines of code.

How do I create a Function?

It seems there are almost as many ways to create Functions as there are possible functions. One possible, cross provider, method is to use the Serverless Framework. However as I knew I wanted an Azure Function I followed this very good tutorial. One call out is that if you’ve not used node.js and you are on Windows then use nvm-windows, as it really takes the pain out of installing and managing node.js locally.

Deployment attempt one

If you’ve followed the linked tutorial then you’ve used the Azure Functions extension to publish your function. And this is fine as far as it goes, but you’re here either out of curiosity or because you want a better more repeatable way of deploying.

Deployment attempt two

Following Aaron Powell’s Deploying Azure Functions With GitHub Actions was straightforward, and really helped in putting my workflow.

It’s worth calling out a couple of things about the whole process.

The first is the use of the Azure / login action in the deployment job. This takes a credential json to log in to Azure for the current job. This is to allow the use of Azure / appservice-settings to provide settings for the function. The settings come from secrets, and are a json blob in the following format:

        "name": "key-1",
        "value": "value-1",
        "slotSetting": false
        "name": "key-2",
        "value": 2,
        "slotSetting": false

The Azure / functions-action is used to deploy the function, the preferred method of connecting to Azure with this action is to use a Publish Profile, this is downloaded from the Function App itself. It’s unfortunate that the appservice-settings doesn’t also (at the time of writing) support the use of a Publish Profile.

A final little callout is that I’ve (again) added a way to invoke a manual build.