# WithAcrPullIdentity

- Module: [Aspire.Hosting.Azure.AppContainers](/reference/api/go/aspire.hosting.azure.appcontainers.md)
- Version: `17.0.0`
- Kind: `method`
- Defined on: [`AzureContainerAppEnvironmentResource`](/reference/api/go/aspire.hosting.azure.appcontainers/azurecontainerappenvironmentresource.md)
- Source: [GitHub](https://github.com/microsoft/aspire/tree/2d325b13709752ba6d9a943635c5e2940a2530c0)

Configures the container app environment to use the supplied `AzureUserAssignedIdentityResource` as the managed identity that container apps in the environment 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.
This is commonly combined with `AsExisting` on the environment and on the container registry to deploy
container apps into a pre-provisioned set of Azure resources without Aspire emitting any new identity or
role-assignment resources. See for the
scenario this addresses.
Only the combination of an existing environment, 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 environment 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.

## Definition

```go
func (AzureContainerAppEnvironmentResource) WithAcrPullIdentity(identityBuilder AzureUserAssignedIdentityResource) AzureContainerAppEnvironmentResource
```

## Parameters

- `identityBuilder` ([`AzureUserAssignedIdentityResource`](/reference/api/go/aspire.hosting.azure.appcontainers/azureuserassignedidentityresource.md)) -- The resource builder for the user-assigned identity that should be used for image pulls. This identity is only used for the `AcrPull` role; it is not assigned to individual container apps in the environment.

## Returns

[`AzureContainerAppEnvironmentResource`](/reference/api/go/aspire.hosting.azure.appcontainers/azurecontainerappenvironmentresource.md) -- The `IResourceBuilder` for chaining.

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

## Applies to

- [`AzureContainerAppEnvironmentResource`](/reference/api/go/aspire.hosting.azure.appcontainers/azurecontainerappenvironmentresource.md)
