# AzureApiManagementResource.WithPolicy

- Module: [Aspire.Hosting.Azure.ApiManagement](/reference/api/go/aspire.hosting.azure.apimanagement.md)
- Defined on: [AzureApiManagementResource](/reference/api/go/aspire.hosting.azure.apimanagement/azureapimanagementresource.md)
- Version: `17.0.0-preview.1.26567.5`
- Kind: `method`

Replaces the complete service-level policy document.

## Remarks

APIM policy updates replace the complete policy document at a scope. To prevent silently dropping policy fragments,
this method cannot be combined with `WithInboundPolicy`
at the same scope.

## Definition

```go
type AzureApiManagementResource interface {
    // ... omitted for brevity
    WithPolicy(policyXml string) AzureApiManagementResource
}
```

## Signature

```go
WithPolicy(policyXml string) AzureApiManagementResource
```

## Parameters

- `policyXml` (`string`) -- A complete APIM `policies` XML document.

## Returns

[`AzureApiManagementResource`](/reference/api/go/aspire.hosting.azure.apimanagement/azureapimanagementresource.md) -- The resource builder.

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

## Defined on

- [AzureApiManagementResource](/reference/api/go/aspire.hosting.azure.apimanagement/azureapimanagementresource.md) -- `handle`
