# WithEntraIdReference

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

Injects Entra ID authentication configuration into a consuming resource and sets the prefix of its DownstreamApis entries.

## Remarks

Behaves like withReference with the registration, which is enough for most references. Use this method when a resource references several registrations
that declare permissions to the same API: give all but one of them their own downstreamApisPrefix, or the model is rejected.

## Definition

```go
func (ResourceWithEnvironment) WithEntraIdReference(
    source EntraIdApplicationResource,
    options ...*WithEntraIdReferenceOptions,
) ResourceWithEnvironment
```

## Parameters

- `source` ([`EntraIdApplicationResource`](/reference/api/go/aspire.hosting.azure.entraid/entraidapplicationresource.md)) -- The Entra ID application resource to reference.
- `options` (`...*WithEntraIdReferenceOptions`) -- optional settings, see [Options](#options)

## Options

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

- `ConnectionName` (`*string`) -- The environment variable prefix. Defaults to AzureAd for .NET program resources and the registration's name otherwise.
- `DownstreamApisPrefix` (`*string`) -- The configuration prefix of the DownstreamApis entries. Defaults to DownstreamApis.

## Returns

`ResourceWithEnvironment` -- The resource builder.

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

## Applies to

- `CSharpAppResource`
- `ContainerResource`
- `DotnetToolResource`
- `ExecutableResource`
- `ProjectResource`
