Create Service Principal : Implementation Guide
We create service principals to use it instead of doing Sign In every time while using automation tools like terraform.
Step 5: This will also be done with help of Azure CLI so open any terminal on your computer.
Step 6: First set the MSYS_NO_PATHCONV environment variable.
PowerShell Syntax
$env:MSYS_NO_PATHCONV = 1
Linux Syntax
export MSYS_NO_PATHCONV=1
Step 7: To create service principal use command az ad sp create-for-rbac for creating role-based access control (RBAC) service principal.
Syntax
az ad sp create-for-rbac --name <service_principal_name> --role Contributor --scopes /subscriptions/<subscription_id>
- Replace the <service_principal_name> with any name, or you can also skip this and random name will be assigned automatically.
- the –role here Contributor which grants full access to all resources in a specified scope.
- Replace the <subscription_id> with you subscription id which you got in Step 4 in Authenticate to Azure part.
Example: Keep your subscription id secure, I have altered mine in this example command
az ad sp create-for-rbac --name gfgVMtut --role Contributor --scopes /subscriptions/120160be-fda9-4201-85rf-fi5d4551012b
output: Save the appId, password and tenant securely as they will be needed in further steps and remember to don’t include them in code.
How to Create Windows VM in Azure Using Terraform
In this article, we will cover the whole process of creating Windows VM in Azure using Terraform. When you have to create multiple VMs, perhaps even identical ones, or machines with nearly identical configurations, it can be repetitive and time-consuming to go through the manual setup process each time. That’s where Terraform comes in. Think of it as a blueprint for building VMs without the need for manual work, reducing errors and saving you valuable time. Let’s first see what virtual machines, azure, and Terraform are.