# AzureApiManagementResource.AddPolicyFragment

- 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`

Adds a reusable policy fragment to the API Management service.

## Definition

```go
type AzureApiManagementResource interface {
    // ... omitted for brevity
    AddPolicyFragment(
        name string,
        policyXml string,
        options ...*AddPolicyFragmentOptions,
    ) AzureApiManagementPolicyFragmentResource
}
```

## Signature

```go
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()`.

## Defined on

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