title | description | keywords | ms.topic | ms.date | ms.custom | adobe-target |
---|---|---|---|---|---|---|
Install Terraform on Windows with Azure PowerShell |
Learn how to configure Terraform on Windows with Azure PowerShell |
terraform azure cli devops powershell install configure windows interactive login rbac service principal automated script |
how-to |
06/20/2024 |
devx-track-terraform, mode-api, devx-track-azurecli, devx-track-azurepowershell |
true |
[!INCLUDE Terraform abstract]
This article describes how to get started with Terraform on Azure using PowerShell.
In this article, you learn how to:
[!div class="checklist"]
- Install the latest version of PowerShell
- Install the new PowerShell Az Module
- Install the Azure CLI
- Install Terraform
- 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
[!INCLUDE open-source-devops-prereqs-azure-subscription.md]
-
The latest PowerShell module that allows interaction with Azure resources is called the Azure PowerShell Az module. When using the Azure PowerShell Az module, PowerShell 7 (or later) is the recommended version on all platforms. If you have PowerShell installed, you can verify the version by entering the following command at a PowerShell prompt.
$PSVersionTable.PSVersion
-
Install PowerShell. This demo was tested using PowerShell 7.2.1 (x64) on Windows 10.
For Terraform to authenticate to Azure, you need to install the Azure CLI. This demo was tested using Azure CLI version 2.32.0.
[!INCLUDE install-terraform-on-windows.md]
Troubleshoot common problems when using Terraform on Azure
[!div class="nextstepaction"] Authenticate Terraform to Azure