1. Packages
  2. Azure Active Directory (Azure AD)
  3. API Docs
  4. DirectoryRole
Azure Active Directory (Azure AD) v6.4.0 published on Monday, Apr 7, 2025 by Pulumi

azuread.DirectoryRole

Explore with Pulumi AI

Manages a Directory Role within Azure Active Directory. Directory Roles are also known as Administrator Roles.

Directory Roles are built-in to Azure Active Directory and are immutable. However, by default they are not activated in a tenant (except for the Global Administrator role). This resource ensures a directory role is activated from its associated role template, and exports the object ID of the role, so that role assignments can be made for it.

Once activated, directory roles cannot be deactivated and so this resource does not perform any actions on destroy.

API Permissions

The following API permissions are required in order to use this resource.

When authenticated with a service principal, this resource requires one of the following application roles: RoleManagement.ReadWrite.Directory or Directory.ReadWrite.All

When authenticated with a user principal, this resource requires one of the following directory roles: Privileged Role Administrator or Global Administrator

Example Usage

Activate a directory role by its template ID

import * as pulumi from "@pulumi/pulumi";
import * as azuread from "@pulumi/azuread";

const example = new azuread.DirectoryRole("example", {templateId: "00000000-0000-0000-0000-000000000000"});
Copy
import pulumi
import pulumi_azuread as azuread

example = azuread.DirectoryRole("example", template_id="00000000-0000-0000-0000-000000000000")
Copy
package main

import (
	"github.com/pulumi/pulumi-azuread/sdk/v6/go/azuread"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := azuread.NewDirectoryRole(ctx, "example", &azuread.DirectoryRoleArgs{
			TemplateId: pulumi.String("00000000-0000-0000-0000-000000000000"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureAD = Pulumi.AzureAD;

return await Deployment.RunAsync(() => 
{
    var example = new AzureAD.DirectoryRole("example", new()
    {
        TemplateId = "00000000-0000-0000-0000-000000000000",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azuread.DirectoryRole;
import com.pulumi.azuread.DirectoryRoleArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var example = new DirectoryRole("example", DirectoryRoleArgs.builder()
            .templateId("00000000-0000-0000-0000-000000000000")
            .build());

    }
}
Copy
resources:
  example:
    type: azuread:DirectoryRole
    properties:
      templateId: 00000000-0000-0000-0000-000000000000
Copy

Activate a directory role by display name

import * as pulumi from "@pulumi/pulumi";
import * as azuread from "@pulumi/azuread";

const example = new azuread.DirectoryRole("example", {displayName: "Printer administrator"});
Copy
import pulumi
import pulumi_azuread as azuread

example = azuread.DirectoryRole("example", display_name="Printer administrator")
Copy
package main

import (
	"github.com/pulumi/pulumi-azuread/sdk/v6/go/azuread"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := azuread.NewDirectoryRole(ctx, "example", &azuread.DirectoryRoleArgs{
			DisplayName: pulumi.String("Printer administrator"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureAD = Pulumi.AzureAD;

return await Deployment.RunAsync(() => 
{
    var example = new AzureAD.DirectoryRole("example", new()
    {
        DisplayName = "Printer administrator",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azuread.DirectoryRole;
import com.pulumi.azuread.DirectoryRoleArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var example = new DirectoryRole("example", DirectoryRoleArgs.builder()
            .displayName("Printer administrator")
            .build());

    }
}
Copy
resources:
  example:
    type: azuread:DirectoryRole
    properties:
      displayName: Printer administrator
Copy

Create DirectoryRole Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new DirectoryRole(name: string, args?: DirectoryRoleArgs, opts?: CustomResourceOptions);
@overload
def DirectoryRole(resource_name: str,
                  args: Optional[DirectoryRoleArgs] = None,
                  opts: Optional[ResourceOptions] = None)

@overload
def DirectoryRole(resource_name: str,
                  opts: Optional[ResourceOptions] = None,
                  display_name: Optional[str] = None,
                  template_id: Optional[str] = None)
func NewDirectoryRole(ctx *Context, name string, args *DirectoryRoleArgs, opts ...ResourceOption) (*DirectoryRole, error)
public DirectoryRole(string name, DirectoryRoleArgs? args = null, CustomResourceOptions? opts = null)
public DirectoryRole(String name, DirectoryRoleArgs args)
public DirectoryRole(String name, DirectoryRoleArgs args, CustomResourceOptions options)
type: azuread:DirectoryRole
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args DirectoryRoleArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args DirectoryRoleArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args DirectoryRoleArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args DirectoryRoleArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. DirectoryRoleArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var directoryRoleResource = new AzureAD.DirectoryRole("directoryRoleResource", new()
{
    DisplayName = "string",
    TemplateId = "string",
});
Copy
example, err := azuread.NewDirectoryRole(ctx, "directoryRoleResource", &azuread.DirectoryRoleArgs{
	DisplayName: pulumi.String("string"),
	TemplateId:  pulumi.String("string"),
})
Copy
var directoryRoleResource = new DirectoryRole("directoryRoleResource", DirectoryRoleArgs.builder()
    .displayName("string")
    .templateId("string")
    .build());
Copy
directory_role_resource = azuread.DirectoryRole("directoryRoleResource",
    display_name="string",
    template_id="string")
Copy
const directoryRoleResource = new azuread.DirectoryRole("directoryRoleResource", {
    displayName: "string",
    templateId: "string",
});
Copy
type: azuread:DirectoryRole
properties:
    displayName: string
    templateId: string
Copy

DirectoryRole Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The DirectoryRole resource accepts the following input properties:

DisplayName Changes to this property will trigger replacement. string
The display name of the directory role to activate. Changing this forces a new resource to be created.
TemplateId Changes to this property will trigger replacement. string

The object ID of the role template from which to activate the directory role. Changing this forces a new resource to be created.

Either display_name or template_id must be specified.

DisplayName Changes to this property will trigger replacement. string
The display name of the directory role to activate. Changing this forces a new resource to be created.
TemplateId Changes to this property will trigger replacement. string

The object ID of the role template from which to activate the directory role. Changing this forces a new resource to be created.

Either display_name or template_id must be specified.

displayName Changes to this property will trigger replacement. String
The display name of the directory role to activate. Changing this forces a new resource to be created.
templateId Changes to this property will trigger replacement. String

The object ID of the role template from which to activate the directory role. Changing this forces a new resource to be created.

Either display_name or template_id must be specified.

displayName Changes to this property will trigger replacement. string
The display name of the directory role to activate. Changing this forces a new resource to be created.
templateId Changes to this property will trigger replacement. string

The object ID of the role template from which to activate the directory role. Changing this forces a new resource to be created.

Either display_name or template_id must be specified.

display_name Changes to this property will trigger replacement. str
The display name of the directory role to activate. Changing this forces a new resource to be created.
template_id Changes to this property will trigger replacement. str

The object ID of the role template from which to activate the directory role. Changing this forces a new resource to be created.

Either display_name or template_id must be specified.

displayName Changes to this property will trigger replacement. String
The display name of the directory role to activate. Changing this forces a new resource to be created.
templateId Changes to this property will trigger replacement. String

The object ID of the role template from which to activate the directory role. Changing this forces a new resource to be created.

Either display_name or template_id must be specified.

Outputs

All input properties are implicitly available as output properties. Additionally, the DirectoryRole resource produces the following output properties:

Description string
The description of the directory role.
Id string
The provider-assigned unique ID for this managed resource.
ObjectId string
The object ID of the directory role.
Description string
The description of the directory role.
Id string
The provider-assigned unique ID for this managed resource.
ObjectId string
The object ID of the directory role.
description String
The description of the directory role.
id String
The provider-assigned unique ID for this managed resource.
objectId String
The object ID of the directory role.
description string
The description of the directory role.
id string
The provider-assigned unique ID for this managed resource.
objectId string
The object ID of the directory role.
description str
The description of the directory role.
id str
The provider-assigned unique ID for this managed resource.
object_id str
The object ID of the directory role.
description String
The description of the directory role.
id String
The provider-assigned unique ID for this managed resource.
objectId String
The object ID of the directory role.

Look up Existing DirectoryRole Resource

Get an existing DirectoryRole resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: DirectoryRoleState, opts?: CustomResourceOptions): DirectoryRole
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        description: Optional[str] = None,
        display_name: Optional[str] = None,
        object_id: Optional[str] = None,
        template_id: Optional[str] = None) -> DirectoryRole
func GetDirectoryRole(ctx *Context, name string, id IDInput, state *DirectoryRoleState, opts ...ResourceOption) (*DirectoryRole, error)
public static DirectoryRole Get(string name, Input<string> id, DirectoryRoleState? state, CustomResourceOptions? opts = null)
public static DirectoryRole get(String name, Output<String> id, DirectoryRoleState state, CustomResourceOptions options)
resources:  _:    type: azuread:DirectoryRole    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
Description string
The description of the directory role.
DisplayName Changes to this property will trigger replacement. string
The display name of the directory role to activate. Changing this forces a new resource to be created.
ObjectId string
The object ID of the directory role.
TemplateId Changes to this property will trigger replacement. string

The object ID of the role template from which to activate the directory role. Changing this forces a new resource to be created.

Either display_name or template_id must be specified.

Description string
The description of the directory role.
DisplayName Changes to this property will trigger replacement. string
The display name of the directory role to activate. Changing this forces a new resource to be created.
ObjectId string
The object ID of the directory role.
TemplateId Changes to this property will trigger replacement. string

The object ID of the role template from which to activate the directory role. Changing this forces a new resource to be created.

Either display_name or template_id must be specified.

description String
The description of the directory role.
displayName Changes to this property will trigger replacement. String
The display name of the directory role to activate. Changing this forces a new resource to be created.
objectId String
The object ID of the directory role.
templateId Changes to this property will trigger replacement. String

The object ID of the role template from which to activate the directory role. Changing this forces a new resource to be created.

Either display_name or template_id must be specified.

description string
The description of the directory role.
displayName Changes to this property will trigger replacement. string
The display name of the directory role to activate. Changing this forces a new resource to be created.
objectId string
The object ID of the directory role.
templateId Changes to this property will trigger replacement. string

The object ID of the role template from which to activate the directory role. Changing this forces a new resource to be created.

Either display_name or template_id must be specified.

description str
The description of the directory role.
display_name Changes to this property will trigger replacement. str
The display name of the directory role to activate. Changing this forces a new resource to be created.
object_id str
The object ID of the directory role.
template_id Changes to this property will trigger replacement. str

The object ID of the role template from which to activate the directory role. Changing this forces a new resource to be created.

Either display_name or template_id must be specified.

description String
The description of the directory role.
displayName Changes to this property will trigger replacement. String
The display name of the directory role to activate. Changing this forces a new resource to be created.
objectId String
The object ID of the directory role.
templateId Changes to this property will trigger replacement. String

The object ID of the role template from which to activate the directory role. Changing this forces a new resource to be created.

Either display_name or template_id must be specified.

Import

This resource does not support importing.

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
Azure Active Directory (Azure AD) pulumi/pulumi-azuread
License
Apache-2.0
Notes
This Pulumi package is based on the azuread Terraform Provider.