Create the DevOps project

1. Create the DevOps project

Azure DevOps (previously VSTS) allows you to automate the deployment of resources, whether ARM template (JSON), PowerShell, CLI, Terraform, etc.

Today, I’m going to focus on the integration with Terraform. Be careful, I’ll not go into Terraform details in this article, so you need to know the technology.

The pricing for Azure DevOps is available here:

https://azure.microsoft.com/en-us/pricing/details/devops/azure-pipelines/

By default, you’ve 5 users free.

Before starting, make sure you’ve an Azure DevOps organization in your subscription:

make sure you’ve an Azure DevOps organization in your subscription

Open via the URL your Azure DevOps and create a new project by clicking on Create project:

Open via the URL your Azure DevOps and create a new project by clicking on Create project

Give it a name and click on Create:

Give it a name and click on Create

When the project is created, you can invite people, etc.:

When the project is created, you can invite people, etc.

On the left, go into Repos > Files and add one or more files in the directory. You can add a README for example, to initialize the project, by clicking on Initialize:

go into Repos > Files and add one or more files in the directory

When the initialization is finished, you’ll have at least one file in your repository:

you’ll have at least one file in your repository

Here, create a folder, with 2 files, main.tf and variables.tf:

create a folder, with 2 files, main.tf and variables.tf2. Terraform code

With following Terraform code, I’ll deploy 1 VNet in Azure, with 2 subnets. As you can see, for some variables, I’m using __ before and after the variable. It’s to be able to use variables, directly in Azure DevOps. The code use dis the following :

Main.tf

Variables.tf

3. Create your first build

We will now create the build, which will check if resources have been modified in a particular folder, and thus, create a new build for our future release. Click on Pipelines > Builds > New Pipeline:

Click on Pipelines > Builds > New Pipeline

Here, choose where sources are located and validate:

choose where sources are located and validate

Choose the template that you want to use, empty job for me:

Choose the template that you want to use

Give a name, choose a pool where an agent is installed. This pool can be deployed on one of your VMs, to limit costs:

Give a name, choose a pool where an agent is installed

Add a job with type Copy Files. Give a name, choose the folder where you created your files main and variables, and choose to copy all content. The target folder must be the following: $(build.artifactstagingdirectory)/Terraform

Add a job with type Copy Files

Add a job with type Publish Build Artifacts and leave it with default parameters:

Add a job with type Publish Build Artifacts and leave it with default parameters

Click now on Triggers to activate the CI (Continuous Integration) to launch this build, after each file modification that exists in the master branch:

Click now on Triggers to activate the CI (Continuous Integration) to launch this build

Save and execute the build:

Save and execute the build - img

Save and execute the build

After few seconds, our build was executed correctly:

After few seconds, our build was executed correctly

You will receive an email to tell you that everything works well with the last build:

You will receive an email to tell you that everything works well with the last build

StarWind Virtual SAN eliminates any need for physical shared storage just by mirroring internal flash and storage resources between hypervisor servers. Furthermore, the solution can be run on the off-the-shelf hardware. Such design allows StarWind Virtual SAN to not only achieve high performance and efficient hardware utilization but also reduce operational and capital expenses.

Learn more about ➡ StarWind Virtual SAN

And with CI activated, the reason of the execution with this new build is Continuous integration:

And with CI activated, the reason of the execution with this new build is Continuous integration

In the next article, we will see how to build our first release to deploy the Terraform template.

Views All Time
19
Views Today
30
Appreciate how useful this article was to you?
1 vote, average: 5.00 out of 51 vote, average: 5.00 out of 51 vote, average: 5.00 out of 51 vote, average: 5.00 out of 51 vote, average: 5.00 out of 5
5 out of 5, based on 1 review
Loading...
Back to blog
The following two tabs change content below.
Florent Appointaire
Florent Appointaire is Microsoft Engineer with 5 years of experience, specialized in Cloud Technologies (Public/Hybrid/Private). He is a freelance consultant in Belgium from the beginning of 2017. He is MVP Cloud and Datacentre Management. He is MCSE Private Cloud and Hyper-V certified. His favorite products are SCVMM, SCOM, Windows Azure pack/Azure Stack and Microsoft Azure.