My first Azure build & deploy pipelines for an Azure Function V2

Published on 05 March 2019 by Joost. Reading time: 12 minutes.

For those who think I am breaking rank and suddenly move away from HoloLens and Mixed Reality to Microsoft Azure - don't worry. I am still Windows Development MVP with every intention to stay within the Mixed Reality area. But every Mixed Reality app - like basically every app these days that's more than a simple toy, needs a backend - mobile apps in general, but Mixed Reality apps just as well.

Walk the World uses an Azure V1 function and a Redis cache to validate and cache request, and AMS HoloATC uses an app service to do a lot of calculations in the cloud and share selected airplanes. The new version, almost finished, uses two V2 functions. So basically, there's always an Azure component. And I used AMS HoloATC's new backend as a guinea pig for the pipelines because it's better to try something new on private projects first than to experimentally blow a customer's deployment smithereens, right?


Caveat emptor

Anyway, in this post I wrote down my experiences - simply 'how I did it', how I used Azure pipelines. This may not be the best way to do it. I don't doubt some real DevOps heroes will have better ideas. But potentially making a fool out of myself never stopped me blogging.


Function first

To be able to build an deploy a function, we of course first need one. So I made this little demo project "MyFunctionV2"

My first Azure build 1 

I created a simple HTTP trigger with anonymous access rights, which I think in any serious scenario you should never do, but this a demo, so here goes:

My first Azure build 2

And then I simplified the already simple code in it even more so that resulted in this:

using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;

namespace MyFunctionV2
    public static class HelloWorld
        public static async Task<IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
            ILogger log)
            log.LogInformation("C# HTTP trigger function processed a request.");

            return new OkObjectResult("Hello, world");

I stuck the sources in GitHub. Now we are ready to publish.


First publish

Publish? Weren't you going to use the Azure pipelines? Yes - but only to deploy. And since I am lazy I do the first publish just like in the old days (that is, up to last week) from Visual Studio. Although things have improved considerably - I used to make a function in the portal first, delete everything and then start to publish, because that was the only way to get it into a consumption plan. This way is quick and easy But I digress.

I publish a new "App Service", still apparently

My first Azure build 3

Visual Studio selects all kinds of defaults that are not quite desirable:

My first Azure build 4

I want at least a new consumption based plan, and while I am at it, a separate storage account as well - although I am not going to use that in this sample (my AMS HoloATC functions does, for sure).

My first Azure build 5

When you have set everything to your liking, it should look like this:

My first Azure build 6

Notice the Export button. This allows you to export the whole created configuration in the form of a JSON document. This you can use to completely automate the creation of this as well in a release pipeline, as this 'script' contains a number of variables you can set (like names for the service, storage, the plan, etc.). This is a bit more complicated and I haven't gotten to that part yet, but I know it's possible.

And if you click create, you might possible get this:

My first Azure build 7

Click yes, and we are done with this part.


Create a Build pipeline

This requires a project to be present in . If you have opted to store the source in Azure DevOps (or there's already a project of course, but since I put the source in GitHub I need to create it myself. I took "TestProject" (I am not very gifted in the creative naming department, I know).

The following screenshots are made with the preview settings for Azure DevOps, so things may look a bit different still if your UI settings are still for the 'old' settings. You can force the move forward to click your profile picture right top and select "Preview features" and go from there. You might as well get used to it as the new look & feel is rolling out as I type.

My first Azure build 8

Okay, so let's click Pipelines/Builds and continue.

My first Azure build 9

If this is your first pipeline, it will show the picture on the left, by the second and following pipelines you will see a list of pipelines with this on top, but chances are as you are reading this, it will be your first pipeline.

My first Azure build 10

My first Azure build 11







After that, it's just following the steps:

My first Azure build 12

I am not a XAML typist nor very versed in YAML, so I click "Use the visual designer".

My first Azure build 13

Since we are using GitHub, you might need to make a connection first.

My first Azure build 14

I will call mine "LocalJoost" - click "Authorize using oAuth". That will show a GitHub popup authorizing Azure Pipelines. Then select your repository:

My first Azure build 15

Hit select.

My first Azure build 16

And then continue. You will then need to select a template, and need to scroll down quite a bit.

My first Azure build 17

Select C# function and hit apply.

My first Azure build 18

Now let's be bold and hit "Save & queue". This will save nor queue, but give you a three-option drop-down in which "Save & queue" is one of the options. Click that option, and it will still not save, nor queue, but you will get yet another popup:

My first Azure build 19

Hit "Save & queue" - third time's a charm, you will see.

My first Azure build 20

On the top of your screen. If you click the build number, it will take you to a page where you can follow the sausage being made, and when it's done you should see about this:

My first Azure build 21

So far so good. We have a build and it's working! And you should get an e-mail for confirmation as well.


Defining a build trigger

You might want to have a look at when and how a build is kicked off, because we don't want to do this manually every time something changes. A good developer is still a lazy developer. So click Edit in the screen above.

 My first Azure build 22

And then click "Triggers".

My first Azure build 23

We select the continuous trigger checkbox and select the proper values, although the defaults will probably be ok right away:

My first Azure build 24

Hit "Save and queue" once again, but this time only select "Save" from the pop-out menu.

So, for fun, let's change the, push a commit to the master and have a look at the builds again. And sure enough, a built is started immediately by the CI trigger.

My first Azure build 25

And this, my friends, is all it takes to set up a build pipeline for a V2 function with sources hosted in GitHub. Now for the final part - I want automated deploy as well.


Create a Release pipeline

Starts easy again:

My first Azure build 26

This time it does a better suggestion: 

My first Azure build 27

Hit apply. That gives you this screen which I find a wee bit confusing:

My first Azure build 28

Let's click "Add an artifact". That creates a kind of pop-over on the right side:

My first Azure build 29

Select "Build" for source type, then set the Source Build pipeline to be the build pipeline we just created, and the Default Version to "Latest". Then we hit add. Then click the red exclamation mark on "Stage 1", to view the build tasks:

My first Azure build 30

You will have to select the Azure subscription used (I have two) plus the App Service where you want to deployment to happen. To be able to use the subscription you will have to click the Authorize button first:

My first Azure build 31

And you might want to disable your popup blocker for this site to expedite that process.

My first Azure build 32

Once this is done, you can select "Function App" (don't let it sit at "Web App") and select the actual function app you want to deploy to.

My first Azure build 33

And then you click "Save".

My first Azure build 34

Uhm, yeah, click OK I guess. This will give you this screen:

My first Azure build 35

So let's create a release, manually, to see if things are working.

My first Azure build 36 

Click "Create" (don't change anything). You will go back to this screen, but you will see a yellow-greenish banner indicating a release has been started indeed:

My first Azure build 37

Click the release name in that banner, that will take you to this progress screen:

My first Azure build 38

If you click "In progress" you will once again see the sausage being made in more detail:

My first Azure build 39

And it should finish with the "Deploy Azure App Services - succeeded".


For some final automation

We want this of course to kick off automatically. To that extent, we have to click "Edit pipeline" again. If find this screen not very intuitive, but it's not rocket science to find out what's the idea with some clicking around.

My first Azure build 40

We seem to have to click the lightning bolt icon - the left one - to set the "Continuous deployment trigger".

My first Azure build 41

Flip the toggle to to Enabled, hit save, and then the final test.


So does it work?

I have published to app MyFunctionV2, so the URL to the site should be and to the specific function

Hitting that link gives, as expected, "Hello World". Now let's change the HttpTrigger function we made all the way at the beginning to return the text "Hello again, World". We then commit and push the code to GitHub, and now we wait...

We are off to a promising start.

My first Azure build 42

And then we see a release being triggered automatically.

My first Azure build 43

And when that's done, we hit the URL again and sure enough:

My first Azure build 44



So even someone with not a lot of knowledge about this topic, like me, can create a fully features continuous build-and-deploy pipeline, in a manner of a few minutes. I can tell you that retracing my steps and actually writing it down actually took a lot more time than the actual creation of the pipeline itself. I think Azure pipelines makes DevOps a lot easier, and the new UI is a lot more intuitive that the old There are still a few places where there's room for improvement, but this is very usable.

Anyone wanting to have a look at the completely uninteresting test function can do so here. I would not bother, to be honest.


Tags: Azure


Published by Joost on 05 March 2019

Joost van Schaik has 25 years IT experience and has been working in Geographical Information Systems, Azure Cloud development and Cross-Platform Mobile (Xamarin) Development. He is currently focusing on Mixed Reality: he was a HoloLens and Windows Mixed Reality pioneer since the very beginning, authored 2 apps in the store and several for various customers. He is an active community member, has been blogging about a plethora of technical subjects since 2007 and as a result, has been awarded Microsoft Most Valuable Professional since 2011.


Comments? Share them below

Learn more about ETTU

And the way we work