# AzureAppServiceEnvironmentResource.WithAcrPullIdentity

- Module: [Aspire.Hosting.Azure.AppService](/reference/api/go/aspire.hosting.azure.appservice.md)
- Defined on: [AzureAppServiceEnvironmentResource](/reference/api/go/aspire.hosting.azure.appservice/azureappserviceenvironmentresource.md)
- Version: `17.0.0`
- Kind: `method`

Configures the Azure App Service environment to use the supplied `AzureUserAssignedIdentityResource` as the managed identity that App Service apps use to pull images from the configured container registry (the `AcrPull` identity), instead of having Aspire create a new identity and a new `AcrPull` role assignment.

## Remarks

When this is set, Aspire will not create a new identity or an `AcrPull` role assignment for the
container registry. The caller is responsible for ensuring the supplied identity already has the required
`AcrPull` role assignment on the registry, for example by chaining
`.WithRoleAssignments(acr, ContainerRegistryBuiltInRole.AcrPull)` when adding the identity.
Unlike the equivalent method on Azure Container Apps, App Service reuses this single identity for more than
just image pulls. The same identity is also attached to every generated App Service web app as a user-assigned
managed identity, and is used by the Aspire OTLP sidecar to authenticate telemetry to the Aspire dashboard
(it is added to the dashboard's `ALLOWED_MANAGED_IDENTITIES` and exposed to each app via the OTEL
client-id app setting). If you supply an existing identity here, it will take on all of these roles.
This is commonly combined with `AsExisting` on the App Service environment (App Service Plan) and on
the container registry to deploy websites into a pre-provisioned set of Azure resources without Aspire
emitting any new ACR-pull identity or ACR-pull role-assignment resources. See
for the scenario this addresses.
Only the combination of an existing App Service Plan, an existing container registry, and this method
avoids emitting any new identity or role-assignment resources in the env module. Other combinations still
work but will emit additional resources:
- If the App Service Plan is marked `AsExisting` but no identity is supplied here, Aspire still emits a new `UserAssignedIdentity` and an `AcrPull` role assignment on the configured registry.
- If this method is used but the container registry is not existing (either the Aspire-generated default registry or a user-added registry without `AsExisting`), the registry itself is still provisioned. To wire the supplied identity to that newly-created registry, chain `.WithRoleAssignments(acr, ContainerRegistryBuiltInRole.AcrPull)` on the identity.
If the Aspire dashboard is enabled, Aspire still provisions the dashboard website and its contributor
identity. Use `WithDashboard` with
`false` when targeting a fully pre-provisioned App Service Plan that should not receive a
dashboard.

## Definition

```go
type AzureAppServiceEnvironmentResource interface {
    // ... omitted for brevity
    WithAcrPullIdentity(identityBuilder AzureUserAssignedIdentityResource) AzureAppServiceEnvironmentResource
}
```

## Signature

```go
WithAcrPullIdentity(identityBuilder AzureUserAssignedIdentityResource) AzureAppServiceEnvironmentResource
```

## Parameters

- `identityBuilder` ([`AzureUserAssignedIdentityResource`](/reference/api/go/aspire.hosting.azure.appservice/azureuserassignedidentityresource.md)) -- The resource builder for the user-assigned identity that should be used for image pulls. The supplied identity must already have the `AcrPull` role on the configured container registry.

## Returns

[`AzureAppServiceEnvironmentResource`](/reference/api/go/aspire.hosting.azure.appservice/azureappserviceenvironmentresource.md) -- The `IResourceBuilder` for chaining.

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

## Defined on

- [AzureAppServiceEnvironmentResource](/reference/api/go/aspire.hosting.azure.appservice/azureappserviceenvironmentresource.md) -- `handle`
