Pulumi Azure Active Directory (Azure AD)
Pulumi AzureAD is a Python package for defining, deploying, and managing Azure Active Directory (now Microsoft Entra ID) cloud resources using Pulumi's Infrastructure as Code approach. It is currently at version 6.9.0 and follows Pulumi's rapid release cadence, often receiving weekly or bi-weekly updates to incorporate new features and bug fixes from the upstream Terraform provider.
Warnings
- breaking Upgrading from Pulumi AzureAD v5.x to v6.x may introduce breaking changes. These often stem from updates to the underlying Terraform AzureAD provider, leading to schema changes, removed deprecated properties, and potential changes in resource behavior (e.g., case-sensitive enum values). Review the official migration guide for the specific version range you are upgrading to/from.
- gotcha Authentication errors are common if Azure credentials are not correctly configured. The provider relies on the Azure CLI login (`az login`) or specific environment variables (e.g., `ARM_CLIENT_ID`, `ARM_TENANT_ID`, `ARM_CLIENT_SECRET`, `ARM_SUBSCRIPTION_ID`) for authentication. If you encounter errors like 'failed to load Azure credentials' or 'Error obtaining Authorization Token', it's usually an authentication issue.
- deprecated The `end_date_relative` property on the `azuread.ServicePrincipalCertificate` resource is deprecated. It will be removed in a future version.
- gotcha Pulumi has two main Azure providers: `pulumi-azuread` and `pulumi-azure-native` (or `pulumi-azure` for the older Classic provider). `pulumi-azuread` is specifically for managing Azure Active Directory (Entra ID) resources like Users, Groups, Applications, and Service Principals. `pulumi-azure-native` is for general Azure ARM resources (e.g., Virtual Machines, Storage Accounts, Resource Groups). Confusing the two can lead to 'resource not found' or 'property not supported' errors.
Install
-
pip install pulumi-azuread
Imports
- azuread
import pulumi_azuread as azuread
- Group
from pulumi_azuread import Group
Quickstart
import pulumi
import pulumi_azuread as azuread
import os
# Ensure Azure credentials are set via environment variables or `az login`
# Example: ARM_CLIENT_ID, ARM_CLIENT_SECRET, ARM_TENANT_ID, ARM_SUBSCRIPTION_ID
# Pulumi typically picks these up automatically or via `pulumi config set`.
# For local testing, ensure `az login` has been run or environment variables are configured.
# For CI/CD, consider OIDC or Service Principal authentication.
# Create an Azure AD Group
my_group = azuread.Group(
"my-python-group",
display_name="MyPythonManagedGroup",
mail_enabled=False,
security_enabled=True
)
# Export the ID of the created group
pulumi.export("groupId", my_group.id)