# EntraIdApplicationResource.WithExternalApiAdminConsent

- 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.26565.2`
- Kind: `method`

Grants tenant-wide consent to permissions that this registration declared for an API that is not an Aspire resource.

## Remarks

A delegated permission becomes a delegated permission grant for all users. An application permission becomes an app role assignment
to this registration's service principal. The deploying identity needs a directory role or Microsoft Graph permission that allows consent, and deployment fails without it.
Application permissions to broad scopes such as Directory.Read.All give the application access to the whole tenant, so grant only what the application needs.
Throws when a permission was not declared first or the caller is an existing registration. Grant consent for existing registrations manually.
Consent is not additive. The delegated grant is declared in full: it is set to exactly the delegated permissions passed to withExternalApiAdminConsent
for this registration and API, so a permission granted to the pair outside Aspire, or removed from the calls while others remain, is revoked by the next deployment.
When no delegated call remains for the pair, nothing is sent and the existing grant stays. Each application permission is a separate app role assignment:
Aspire creates it but does not delete it when its consent is removed from the AppHost, so remove it in the Microsoft Entra admin center.

## Definition

```go
type EntraIdApplicationResource interface {
    // ... omitted for brevity
    WithExternalApiAdminConsent(
        api any,
        permissions []*EntraIdExternalApiPermission,
    ) EntraIdApplicationResource
}
```

## Signature

```go
WithExternalApiAdminConsent(
    api any,
    permissions []*EntraIdExternalApiPermission,
) EntraIdApplicationResource
```

## Parameters

- `api` (`any`) -- A well-known API, or an API identified by its application ID and application ID URI.
- `permissions` ([`[]*EntraIdExternalApiPermission`](/reference/api/go/aspire.hosting.azure.entraid/entraidexternalapipermission.md)) -- Permissions already declared with withExternalApiPermissions.

## 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`
