# AddPolicyFragment

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

Adds a reusable policy fragment to the API Management service.

## Definition

```go
func (AzureApiManagementResource) AddPolicyFragment(
    name string,
    policyXml string,
    options ...*AddPolicyFragmentOptions,
) AzureApiManagementPolicyFragmentResource
```

## Parameters

- `name` (`string`) -- The globally unique Aspire resource name and default physical policy-fragment name.
- `policyXml` (`string`) -- One or more well-formed APIM policy elements without a `fragment` envelope.
- `options` (`...*AddPolicyFragmentOptions`) -- optional settings, see [Options](#options)

## Options

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

- `Description` (`*string`) -- An optional description.
- `FragmentName` (`*string`) -- The physical policy-fragment identifier in API Management. The resource name is used when omitted.

## Returns

[`AzureApiManagementPolicyFragmentResource`](/reference/api/go/aspire.hosting.azure.apimanagement/azureapimanagementpolicyfragmentresource.md) -- A builder for the policy-fragment resource.

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

## Applies to

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