# WithScope

- Module: [Aspire.Hosting.Azure.EntraId](/reference/api/go/aspire.hosting.azure.entraid.md)
- Version: `17.0.0-preview.1.26565.2`
- Kind: `method`
- Defined on: [`EntraIdApplicationResource`](/reference/api/go/aspire.hosting.azure.entraid/entraidapplicationresource.md)
- Source: [GitHub](https://github.com/microsoft/aspire/tree/bcfa151cdca6d0a573f22d5d9c23f9c727cb3b2f)

Exposes a delegated permission scope that clients can request to call this registration as an API.

## Remarks

Scopes are declared explicitly. Unless an application ID URI is set with withApplicationIdUri, the registration uses api://{clientId}.
The scope's ID stays the same across deployments. Microsoft Graph does not let a deployment remove an enabled scope or change its name:
to retire a scope, deploy it with isEnabled set to false and remove it in a later deployment.
For an existing registration the scope is configuration only, which lets callers declare permissions to it. Set its id to the ID the registration defines.

## Definition

```go
func (EntraIdApplicationResource) WithScope(
    name string,
    description string,
    options ...*EntraIdScopeOptions,
) EntraIdApplicationResource
```

## Parameters

- `name` (`string`) -- The scope's name, which appears in the token's scp claim, such as access_as_user.
- `description` (`string`) -- What the scope allows, shown on the consent page.
- `options` (`...*EntraIdScopeOptions`) -- optional settings, see [Options](#options)

## Options

Optional parameters are passed as the existing [`*EntraIdScopeOptions`](/reference/api/go/aspire.hosting.azure.entraid/entraidscopeoptions.md) struct.

## Returns

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

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

## Applies to

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