There are multiple ways for authenticating.
- Authenticating to Azure using the Azure CLI
- Authenticating to Azure using Managed Service Identity
- Authenticating to Azure using a Service Principal and a Client Certificate
- Authenticating to Azure using a Service Principal and a Client Secret
- Authenticating to Azure using a Service Principal and Open ID Connect
Official Terraform documentation recommends authenticating via Azure CLI when using locally and They recommend using either a Service Principal or Managed Service Identity when running Terraform non-interactively (such as when running Terraform in a CI server)
Pre-requisites
- Install Azure CLI
Step 1: Login
Login using powershell and use command az login
Step 2: Microsoft prompt
A prompt is opened in browser, and you can login using the credentials.
Step 3: PowerShell Json Response
Notice you will get below response after authorization.
PS C:\Users\Jasper> az login
A web browser has been opened at https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize. Please continue the login in the web browser. If no web browser is available or if the web browser fails to open, use device code flow with `az login --use-device-code`.
[
{
"cloudName": "AzureCloud",
"homeTenantId": "3hfdg567-4564-6u78-k898-asdgesr34523",
"id": "3hfdg567-4564-6u78-k898-asde8sr34523",
"isDefault": true,
"managedByTenants": [],
"name": "Azure subscription 1",
"state": "Enabled",
"tenantId": "3hfdg567-4564-6u78-k898-asdgesr34523",
"user": {
"name": "pemail@gmail.com",
"type": "user"
}
}
]
Top comments (0)