Skip to navigation Skip to content
GeralexGR

Personal blog

  • Home
  • About
  • Contact
  • Home
  • About
  • Contact
  • Test

Tag: azure devops terraform cli login

Posted on March 29, 2022March 29, 2022 by geralexgr — Leave a comment

Automate virtual machines deployment with terraform and Azure Devops

Following my previous article about resources deployment on Azure using terraform, I will now explain how you could deploy those resources through Azure DevOps.

Deploy windows and linux virtual machines on Azure using terraform

You can find pipeline code on my Github repository
https://github.com/geralexgr/terraform-az-lin-win/blob/main/azure-pipelines.yml

To getting started you will need to install in your Azure DevOps organization the terraform extension provided from Microsoft DevLabs.

You can install it using the below link

https://marketplace.visualstudio.com/items?itemName=ms-devlabs.custom-terraform-tasks&ssr=false#overview

Then you will have to create a resource group and a storage account inside. You will need the storage account to create a container that will hold you tfstate file.

Under your storage account select containers and add a new container. I created one named terraform that will be used in the pipeline.

Pipeline explanation:

Pipeline contains three tasks. The first task will install terraform tools. The second one will initialize terraform in your working directory. Based on the user input provided in the pipeline the appropriate resource will be deployed. The code on the github contains two separate directories, one for windows and one for linux machines.

Selecting windows will deploy a windows VM using terraform

The third task will apply your terraform configuration. The working directory is generated automatically from the provided parameter.

Terraform init variables:

          - task: TerraformTaskV2@2
            displayName: terraform init
            inputs:
              provider: 'azurerm' 
              command: 'init'
              workingDirectory: '$(Build.SourcesDirectory)/${{ parameters.image }}' // your working terraform directory
              backendServiceArm: 'AzureMSDN' // azure devops service connection with your subscription
              backendAzureRmResourceGroupName: 'terraform' //resource group name
              backendAzureRmStorageAccountName: 'geralexgrstorageaccount' //storage account name
              backendAzureRmContainerName: 'terraform' //container inside storage account
              backendAzureRmKey: 'terraform.tfstate' //state file name inside your storage account

Resources deployed on Azure through the pipeline:

deployment on azure based on github code
Categories: Automation, Azure, Cloud, Devops, Infrastructure, Terraform
Tags: az cli terraform azure devops, Azure, azure devops auth terraform, azure devops authentication terraform, azure devops terraform, azure devops terraform cli login, azure devops terraform vms, azure terraform deploy, deploy, deploy resources terraform azure, devops, native task terraform devops, terraform, terraform azure devops connection
Mastering Azure Devops CI/CD Pipelines with YAML
Learn how to create advanced automation scenarios using YAML and Azure Devops: https://www.udemy.com/course/mastering-azure-devops-cicd-pipelines-with-yaml
Social
Subscribe on my YouTube channel for more tutorials:


Follow me on Linkedin: Linkedin profile
Azure DevOps platform Fundamentals – Build CI/CD pipelines
Start your journey with Azure DevOps platform: https://www.udemy.com/course/azure-devops-platform-fundamentals-build-cicd-pipelines/
Adblock notice
Support this blog to maintain its operational costs by turning off Adblock or donate a small amount using the button below
Blog Stats
  • 371,446 Views

Join 10 other subscribers
Recent Posts
  • Chaos Engineering in Azure: Automating Resilience Testing with Terraform & Pipelines
  • Azure Chaos Studio terraform properties
  • Automating chaos experiment execution with Azure DevOps
  • Chaos Engineering with Azure – simulate web app failure
  • Azure AI Studio – Deploy and use your first model
Top Posts
  • Pass parameters from Power automate to Azure DevOps pipeline using rest api
  • Allow non Admin users to connect through RDP on domain controller
  • Tasks, jobs, stages templates combined for Azure DevOps
  • The specified module 'MSAL.PS' was not loaded because no valid module file was found in any module directory.
  • Trigger azure Devops pipeline from another repository
  • Connect to Azure resources with Managed Identity – Storage account example
  • Error while proxying request: getting credentials: exec: executable kubelogin not found
  • Error from server (Forbidden): nodes is forbidden: User "" cannot list resource "nodes" in API group "" at the cluster scope
  • How Azure DevOps pipelines agent works
  • Build triggers on Azure devops pipelines
Categories
  • AI
  • Ansible
  • Automation
  • AWS
  • Azure
  • BotFramework
  • C# & .NET
  • Chaos Engineering
  • Cloud
  • Devops
  • Docker
  • Github
  • Infrastructure
  • Kubernetes
  • Linux
  • Monitoring
  • Scripts
  • Security
  • Terraform
  • Testing
  • UWP apps – Windows 10
  • VMware
  • Web Development
  • Windows
  • Xamarin
Tags
.net ansible api appservice az cli Azure azuredevops azure devops build c# centos cli command container containers deploy devops docker github html identity jobs k8s kubernetes linux managed identity modules pipeline pipelines powershell redhat release rest api security storage account teamcity terraform update variables visual studio vmware web web app windows xamarin.forms
Archives
  • February 2025
  • November 2024
  • October 2024
  • August 2024
  • June 2024
  • May 2024
  • April 2024
  • March 2024
  • November 2023
  • October 2023
  • September 2023
  • August 2023
  • July 2023
  • June 2023
  • May 2023
  • April 2023
  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • December 2019
  • August 2019
  • April 2019
  • March 2019
  • October 2018
  • September 2018
  • August 2018
  • July 2018
  • March 2018
  • July 2017
  • May 2017
  • February 2016
  • October 2015
  • August 2015
  • February 2015
  • November 2014
  • April 2014
  • March 2014
  • February 2014
  • January 2014
Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy
© GeralexGR 2025
Built with Storefront.