Skip to content

Latest commit

 

History

History
63 lines (42 loc) · 2.14 KB

authenticate-to-azure.md

File metadata and controls

63 lines (42 loc) · 2.14 KB
title description keywords ms.topic ms.date ms.custom
Authenticate Terraform to Azure
Learn the various options to authenticate to Azure with a Microsoft Account
azure devops terraform cli powershell authentication microsoft account subscription environment variables provider block
how-to
08/29/2021
devx-track-terraform

Authenticate Terraform to Azure

[!INCLUDE Terraform abstract]

To use Terraform commands against your Azure subscription, you must first authenticate Terraform to that subscription. This article covers some common scenarios for authenticating to Azure.

In this article, you learn how to:

[!div class="checklist"]

  • Understand common Terraform and Azure authentication scenarios
  • Authenticate via a Microsoft account from Cloud Shell (using Bash or PowerShell)
  • Authenticate via a Microsoft account from Windows (using Bash or PowerShell)
  • Create a service principal using the Azure CLI
  • Create a service principal using Azure PowerShell
  • Specify service principal credentials in environment variables
  • Specify service principal credentials in a Terraform provider block

1. Configure your environment

[!INCLUDE open-source-devops-prereqs-azure-subscription.md]

[!INCLUDE configure-terraform.md]

2. Authenticate Terraform to Azure

[!INCLUDE authenticate-to-azure.md]

3. Verify the results

Verify that you've authenticated to the Azure subscription by displaying the current subscription.

To confirm the current Azure subscription via the Azure CLI, run az account show.

az account show

To confirm the current Azure subscription via Azure PowerShell, run Get-AzContext.

Get-AzContext

Next steps

[!div class="nextstepaction"] Create an Azure resource group