# EntraIdApplicationResource.WithAppRole

- Module: [Aspire.Hosting.Azure.EntraId](/reference/api/go/aspire.hosting.azure.entraid.md)
- Defined on: [EntraIdApplicationResource](/reference/api/go/aspire.hosting.azure.entraid/entraidapplicationresource.md)
- Version: `17.0.0-preview.1.26567.5`
- Kind: `method`

Declares an application role on a registration created by Aspire.

## Remarks

Application roles are separate from delegated scopes and from Azure RBAC roles. This only declares the role; it does not assign it or grant consent.
Role IDs stay the same across deployments, and changing a role's value or ID creates a different role. Whenever at least one role is declared,
the complete appRoles collection is sent, so include every role to keep. Microsoft Graph rejects deleting an enabled role.
Existing registrations are never modified, so this throws for registrations created with addExistingEntraIdApplication.

## Definition

```go
type EntraIdApplicationResource interface {
    // ... omitted for brevity
    WithAppRole(
        value string,
        displayName string,
        description string,
        options ...*WithAppRoleOptions,
    ) EntraIdApplicationResource
}
```

## Signature

```go
WithAppRole(
    value string,
    displayName string,
    description string,
    options ...*WithAppRoleOptions,
) EntraIdApplicationResource
```

## Parameters

- `value` (`string`) -- The value emitted in the roles claim, for example Admin. It must be unique for the application, at most 120 characters, must not start with a period, and may contain only ASCII letters, digits and the punctuation that Microsoft Graph allows.
- `displayName` (`string`) -- The display name shown in the Microsoft Entra admin center.
- `description` (`string`) -- The description shown in assignment and consent experiences.
- `options` (`...*WithAppRoleOptions`) -- optional settings, see [Options](#options)

## Options

Optional parameters are passed in a trailing `options ...*WithAppRoleOptions` argument.

- `AllowedMemberTypes` (`[]string`) -- The member types the role can be assigned to, passed through to Microsoft Graph (for example User or Application). Defaults to User.
- `Id` (`*string`) -- An optional role GUID. When omitted, a stable ID is derived from the registration's resource name and value.
- `IsEnabled` (`*bool`) -- Whether the role is enabled. Defaults to true. To retire a role, deploy it with false and leave it declared; disabling is not access revocation because existing assignments still receive the role in tokens.

## Returns

[`EntraIdApplicationResource`](/reference/api/go/aspire.hosting.azure.entraid/entraidapplicationresource.md) -- The registration builder.

Returns a handle; failures surface later via `Err()`.

## Defined on

- [EntraIdApplicationResource](/reference/api/go/aspire.hosting.azure.entraid/entraidapplicationresource.md) -- `handle`
