# EntraIdApplicationResource.WithAdminConsent

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

Grants tenant-wide consent to delegated permissions that this registration declared for another registration in the AppHost.

## Remarks

This creates a delegated permission grant for all users (`consentType: AllPrincipals`) from this registration to
`api`, so nobody is prompted to consent. The identity that deploys needs a directory role such as
Privileged Role Administrator, Cloud Application Administrator or Application Administrator, or a privileged
Microsoft Graph permission such as `DelegatedPermissionGrant.ReadWrite.All`. Deployment fails without it.
See .
A grant is neither a declaration nor a pre-authorization. Throws for an existing caller; grant its consent manually
in the Microsoft Entra admin center. A created caller may consent to an existing API.
The grant is declared in full: it is set to exactly the scopes passed to `WithAdminConsent` for this registration and
`api`. A scope that was granted to the pair outside Aspire, or that is removed from the calls while others remain,
is revoked by the next deployment. When no call remains for the pair, nothing is sent and the existing grant stays.

## Definition

```go
type EntraIdApplicationResource interface {
    // ... omitted for brevity
    WithAdminConsent(
        api EntraIdApplicationResource,
        scopeNames []string,
    ) EntraIdApplicationResource
}
```

## Signature

```go
WithAdminConsent(
    api EntraIdApplicationResource,
    scopeNames []string,
) EntraIdApplicationResource
```

## Parameters

- `api` ([`EntraIdApplicationResource`](/reference/api/go/aspire.hosting.azure.entraid/entraidapplicationresource.md)) -- The registration that exposes the scopes.
- `scopeNames` (`[]string`) -- The names of scopes already declared with `WithApiPermissions`.

## Returns

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

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

## Defined on

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