Create Users in Azure Active Directory With Terraform

In this Friday blog post about Terraform, we will learn how to create a user in Azure Active Directory with Terraform.

In a previous blog post about Azure Active Directory and Microsoft 365, we have shown you how to create users using PowerShell and CSV files and automate the process of creating and managing users however using scripts to create users is very code-intensive. Managing code and error detection make scripting hard to manage and transfer ownership to new team members.

When I first saw Terraform ability to create users I was happy to see that this task can be simple and automated in such an away that the code is readable and can be understood easily. I have to say that we are reaching a point were scripting become a hard task compared to using declarative code that uses instructions.

Terraform Configuration

In the following confirmation, I am creating a single user in Azure Active Directory with basic information. For instructions in how to use Terraform visit this post.

provider "azurerm" {
  features {}
}

resource "azuread_user" "example" {
  user_principal_name = "mtest@ntweekly.local"
  display_name        = "My Test"
  mail_nickname       = "mtest"
  password            = "set password"
}

Posted

in

by