Monday, 21 January 2019

Deploy Azure Durable Functions with Terraform and Azure Pipelines - Part 1


I was recently doing the talk on Terraform and Azure Pipelines at the UK Cloud Infrastructure User Group and a number of people asked if I could write up a blog on Terraform and Azure Pipelines. We're also testing out Azure Durable Functions so I figure that I’ll write about deploying .NET Core Azure Durable Functions using Terraform and Azure Pipelines.

Azure Durable Functions

To get more information about Azure Durable Functions, see here

This series is more around the Azure Durable Function deployment rather than the durable function .NET core app itself so we won’t go into much detail however what I can tell you is that this durable function is triggered by an HTTP request, accepts a name value and it just responds with "Hello <name>!”.

You can find the code on GitHub here. I’ll use this repo to deploy my durable function into Azure.

Terraform Configuration

Terraform is a great alternative to ARM Templates. Compared to JSON, Hashicorp Configuration Language (HCL) is much simpler and pretty much human-readable. You can find out more about Terraform by going to or my Terraform presentation here.

There is a Terraform configuration in the same GitHub repo as the Azure Durable Function and we’ll use this configuration to deploy a Function App to Azure which will use the Consumption Plan. The Terraform configuration deploys a new resource group, app service plan, storage account and function app (V2).

Azure DevOps build definition as YAML

Azure DevOps has a cool feature where you can write out your Azure Pipeline build definition as code using YAML. This has the benefit that the build configuration is now stored in source control with the application code itself so you get all the benefits of versioning and peer review through pull requests and you can keep your application code and the build definition in sync. You can read more about pipelines as YAML here.

You can find the full YAML pipeline file in the repo here but we'll go through each part in turn. To get started, the first part of our YAML file needs to look like this:

The resources section specifies that the code we are running tasks against is the same repo that the YAML file is stored in (self).  We will also clean the build directory before starting our build.

The pool section specifies that we'll use the hosted Visual Studio 2017 on Server 2016 hosted build agent.

In the variables section, we're specifying that the variable buildConfiguration is set to Release. We'll use this variable when running our dotnet CLI commands.

Build a .NET Core app using Azure DevOps Pipeline as YAML

In the repo, there's a few folders as below. 
  • AzureDurableFunctionsDemo1: Contains the .NET Core project that includes the Azure Durable Functions
  • AzureDurableFunctionsDemo1.Tests: Contains a .NET Core project that includes tests for the methods in the Azure Durable Functions Demo 1 project
  • Deployment: Contains a terraform folder which includes the terraform configuration

In order to build and test our app, we need to do as we would for any .NET Core application - i.e. build, test and publish. Using the Azure DevOps pipeline as YAML, this looks like below:

Notice the steps keyword here - we only need to specify this before the first task in the build pipeline. 

  • Build: This task is using the .NET Core CLI Azure DevOps V2 task template and it's specifying that we want to build all projects using the configuration parameter which is set to the buildConfiguration variable which itself is set to release.
  • Test: This task is using the same task template but is only running tests in projects which include test in the project folder name. It's also publishing the test results to Azure DevOps as the publishTestResults parameter is set to true.
  • Publish: Again using the same template, this task publishes only the AzureDurableFunctionsDemo1 project and it publishes it to the artifact staging directory on the build agent which is specified by the built-in Azure DevOps variable build.ArtifactStagingDirectory. We don't have any web projects to publish so publishWebProjects is set to false however we do need to publish a zip file for deployment to Azure Functions so we'll set zipAfterPublish to true.

That concludes the build and test for the .NET core app so let's move on to building and testing our terraform configuration.

Build a terraform configuration using Azure DevOps pipeline as YAML

The YAML for the terraform build and test looks like below:

  • Terraform Install: As we're using the Visual Studio 2017 hosted build agent which doesn't have terraform installed on it so you'll see the first task is a Terraform Install task which uses chocolatey to install terraform: choco install terraform. This task uses the Command Line V2 task template in Azure DevOps.
  • Terraform Init: With terraform, we don't need to build/compile it as we do for a .NET app but we can run some basic form of unit tests on it by using terraform validate however before we run this, we need to initialize terraform which we do by running terraform init. We're setting input to false because we don't want terraform to prompt us for any missing variables as this is an unattended command and we'd want it to just fail instead. We'd use a backend configuration to specify the location for the remote state file when we're running the configuration however we're just validating our terraform in this case so we'll set the backend to false.
  • Terraform Validate (Dev): For this task, we need to specify all the variables that terraform would expect when we attempt to deploy an infrastructure. These don't need to be the exact values but they need to be the correct type of variable (string, array or map) so as we just have strings, we can just set them to test. You'll see that we're specifying the envDev.tfvars file so that terraform validate can validate the variables which are set in this file. This task has no output unless there's a problem with the validation where it provides a non-zero exit code which fails the step in the pipeline.

In both the Terraform Init and Terraform Validate (Dev) tasks, you'll see that we're specifying the terraform configuration path as deployment\terraform which is the relative path to our terraform configuration. 

Publish the .NET Core app and terraform configuration

We've now built and tested both our application and terraform code and are ready for the release stage however we first need to output some artifacts to pass through to the release. Below are the tasks to publish these artifacts:

Both tasks are using the Publish Build Artifacts Azure DevOps task templates and are simply specifying the path to publish and the name for the artifact. When run, this would output two artifacts - one called app and one called terraform.

Save the YAML pipeline

The last step is to save the YAML pipeline as azure-pipelines.yml and store this in the root of the repo.


In this post, we've gone through the YAML build definition to build and test a .NET Core Azure Durable Function and terraform configuration. In part 2 we'll go through how to create the Azure Build in Azure DevOps.


  1. This comment has been removed by the author.

  2. Azure cloud technology helps to save a money it is done through users pay what they use. So this makes to reduce the investment. you can learn more in microsoft azure training

  3. Nice and good article. It is very useful for me to learn and understand easily. Thanks for sharing your valuable information and time. Please keep updating Devops online training

  4. I have to search sites with relevant information on given topic and provide them to teacher our opinion and the article. ของเล่นแมว

  5. Hi, This is a great article. Loved your efforts on it buddy. Thanks for sharing this with us
    Azure training
    Azure certification
    Azure Online training

  6. We support all types of HP printer troubleshooting and service. Just enter the model number of your printer in to identify the software and drivers your printer requires. Download and install it in your mac and 'Run' the file. The process is easy however if you have any doubts or queries regarding HP printers contact us.

  7. It’s not a tough task to activate Roku. Understand the Roku activation steps. Connect the necessary hardware. It's the power and HDMI, USB cable that is required. Sign in to Roku account and move to the page To begin streaming, visit the channel store and start the channel search. Select and then add the channel to proceed. Want to know How to Activate Roku? Use the customer support number available on our webpage.

  8. Nice Blog!! It is very helpful and very informative and I really learned a lot from it.
    Microsoft Azure DevOps Training
    Azure DevOps Online Training in Hyderabad

  9. Wow! this is Amazing! Do you know your hidden name meaning ? Click here to find your hidden name meaning

  10. Nice Post, Thank You Author!!! For sharing this informative and great Content.
    Want to Cancel SilverSingles Account? In case the cancellation request raised by you through the website is not processed, please contact the SilverSingles Customer care number.

    How to Cancel SilverSingles Membership Plan
    How do Cancel SilverSingles Membership Account
    How to Manage Silversingles Email Notifications?
    How Do I Cancel Silversingles Account

  11. My travel life have been easier with MyGarmin Express. Plus I can get all the additional knowledge through their blogs. I use the Garmin app and is totally upto the mark. I recommend everyone to use Garmin Gps Update and get Garmin life time map update or call +1-888-309-0939 for instant help from Garmin GPS experts.

  12. I did not know the entire benefits of Garmin Nuvi Update. But since I have read this blog on map update, I have installed all available updates for my garmin device. I must say that this piece of blog has helped me improve navigation experience. I am not suggesting all my friends to read this blog and get Garmin Map Update with this team. For detailed information, you can contact sus at toll-free number +1 888-309-0939. Our Garmin GPS professionals will provide instant help.

  13. Get free notification of all India Government Jobs in India and its job vacancies across sectors in India like Railways, Banking Employment in India, Universities, College Govt Jobs, Teaching, Schools in India, Financial Institutions 2020, Defence, SSC, Agriculture and many more India Government Jobs.Visit:

    State Government Jobs
    Bank Jobs in India

  14. Need a Debt Loan To Pay Off Bills?
    Take control of your debt today
    Available Now Business Expansion Loan Offer?
    Do you need a loan to pay off Bills?
    Do you need a loan?
    Do you need Personal Loan?
    Business Expansion Loan?
    Business Start-up, Education,
    Debt Consolidation Loan
    Hard Money Loans
    Loan for any thing ?
    We offer loan at low interest rate of 3%
    Loan with no credit check,
    Email us:
    Call or add us on what's app +918929509036

  15. Thanks for Sharing This Article.It is very so much valuable content. I hope these Commenting lists will help to my website
    devops online training
    best devops online training
    top devops online training

  16. This information is impressive; I am inspired how continuously you describe this topic. After reading your post, thanks for taking the time to discuss this, I feel happy about it and I love learning more about this topic snowflake data warehouse

  17. My name is Samuel, I was in love with my wife and we were married for eight years with a son his is Liam,I loved my wife so much she had access to all my bank account and even my cash app which my accountant agreed to and said it was a great idea, then it took my wife and my accountant two month to get hold of all my properties,all accounts but I had a cash app which they knew nothing about,I was thrown out of my own house was sleeping in a hotel for weeks she also took possession of my son could only see him once a week then I found out she was in love with my accountant all these while so I went online and I came across a private investigator who help me get all my properties and my accounts back even my company back how he did these I don’t know but I gave all the information he asked for and followed all his instructions and now I’m happy my life’s better now.
    Thanks to
    I just said I should share my own story here
    Thank you

  18. If you prefer to cut your cable line, you can use FuboTv as the better option to stream live TV channels. FuboTv is an American streaming service that mainly focuses on live TV streaming. The main channel lineup focuses on the sports TV packages, and so you will find about two dozen sports channels on FuboTv. You can also buy an add-on international sports pack with the subscription. The streaming service is accessible on various devices.

  19. FuboTv is the latest technology and trend of live streaming that helps to keep constituents informed as well as engaged. Fubo provides a simple, secure and affordable live streaming service. This streaming service is very effective in different fields. By letting you watch, allowing you to create, and at the same time share the created videos in real-time, it has made many entrepreneurs plunge into the live streaming. fubotv/Connect