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 |
06/20/2024 |
devx-track-terraform |
[!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"]
- See a list of available authentication methods.
- Select an authentication method.
- Verify that you're authenticated.
[!INCLUDE open-source-devops-prereqs-azure-subscription.md]
[!INCLUDE configure-terraform.md]
Terraform only supports authenticating to Azure with the Azure CLI. Authenticating using Azure PowerShell isn't supported. Therefore, while you can use the Azure PowerShell module when doing your Terraform work, you first need to authenticate to Azure using the Azure CLI.
- Authenticate with a Microsoft account using Cloud Shell (with Bash or PowerShell)
- Authenticate with a Microsoft account using Windows (with Bash or PowerShell)
- Authenticate with a service principal
- Authenticate with a managed identity for Azure services
Verify that you've authenticated to the Azure subscription by displaying the current subscription.
To confirm the current Azure subscription with the Azure CLI, run az account show.
az account show
To confirm the current Azure subscription with Azure PowerShell, run Get-AzContext.
Get-AzContext
[!div class="nextstepaction"] Your first Terraform project: Create an Azure resource group