1. Packages
  2. Packages
  3. Azure Classic
  4. API Docs
  5. apimanagement
  6. ApiOperationPolicy

We recommend using Azure Native.

Viewing docs for Azure v4.42.0 (Older version)
published on Monday, Mar 9, 2026 by Pulumi
azure logo

We recommend using Azure Native.

Viewing docs for Azure v4.42.0 (Older version)
published on Monday, Mar 9, 2026 by Pulumi

    Manages an API Management API Operation Policy

    Example Usage

    using Pulumi;
    using Azure = Pulumi.Azure;
    
    class MyStack : Stack
    {
        public MyStack()
        {
            var exampleApiOperation = new Azure.ApiManagement.ApiOperation("exampleApiOperation", new Azure.ApiManagement.ApiOperationArgs
            {
            });
            //...
            var exampleApiOperationPolicy = new Azure.ApiManagement.ApiOperationPolicy("exampleApiOperationPolicy", new Azure.ApiManagement.ApiOperationPolicyArgs
            {
                ApiName = exampleApiOperation.ApiName,
                ApiManagementName = exampleApiOperation.ApiManagementName,
                ResourceGroupName = exampleApiOperation.ResourceGroupName,
                OperationId = exampleApiOperation.OperationId,
                XmlContent = @"<policies>
      <inbound>
        <find-and-replace from=""xyz"" to=""abc"" />
      </inbound>
    </policies>
    ",
            });
        }
    
    }
    
    package main
    
    import (
    	"fmt"
    
    	"github.com/pulumi/pulumi-azure/sdk/v4/go/azure/apimanagement"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		exampleApiOperation, err := apimanagement.NewApiOperation(ctx, "exampleApiOperation", nil)
    		if err != nil {
    			return err
    		}
    		_, err = apimanagement.NewApiOperationPolicy(ctx, "exampleApiOperationPolicy", &apimanagement.ApiOperationPolicyArgs{
    			ApiName:           exampleApiOperation.ApiName,
    			ApiManagementName: exampleApiOperation.ApiManagementName,
    			ResourceGroupName: exampleApiOperation.ResourceGroupName,
    			OperationId:       exampleApiOperation.OperationId,
    			XmlContent:        pulumi.String(fmt.Sprintf("%v%v%v%v%v", "<policies>\n", "  <inbound>\n", "    <find-and-replace from=\"xyz\" to=\"abc\" />\n", "  </inbound>\n", "</policies>\n")),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    

    Example coming soon!

    import * as pulumi from "@pulumi/pulumi";
    import * as azure from "@pulumi/azure";
    
    const exampleApiOperation = new azure.apimanagement.ApiOperation("exampleApiOperation", {});
    //...
    const exampleApiOperationPolicy = new azure.apimanagement.ApiOperationPolicy("exampleApiOperationPolicy", {
        apiName: exampleApiOperation.apiName,
        apiManagementName: exampleApiOperation.apiManagementName,
        resourceGroupName: exampleApiOperation.resourceGroupName,
        operationId: exampleApiOperation.operationId,
        xmlContent: `<policies>
      <inbound>
        <find-and-replace from="xyz" to="abc" />
      </inbound>
    </policies>
    `,
    });
    
    import pulumi
    import pulumi_azure as azure
    
    example_api_operation = azure.apimanagement.ApiOperation("exampleApiOperation")
    #...
    example_api_operation_policy = azure.apimanagement.ApiOperationPolicy("exampleApiOperationPolicy",
        api_name=example_api_operation.api_name,
        api_management_name=example_api_operation.api_management_name,
        resource_group_name=example_api_operation.resource_group_name,
        operation_id=example_api_operation.operation_id,
        xml_content="""<policies>
      <inbound>
        <find-and-replace from="xyz" to="abc" />
      </inbound>
    </policies>
    """)
    

    Example coming soon!

    Create ApiOperationPolicy Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new ApiOperationPolicy(name: string, args: ApiOperationPolicyArgs, opts?: CustomResourceOptions);
    @overload
    def ApiOperationPolicy(resource_name: str,
                           args: ApiOperationPolicyArgs,
                           opts: Optional[ResourceOptions] = None)
    
    @overload
    def ApiOperationPolicy(resource_name: str,
                           opts: Optional[ResourceOptions] = None,
                           api_management_name: Optional[str] = None,
                           api_name: Optional[str] = None,
                           operation_id: Optional[str] = None,
                           resource_group_name: Optional[str] = None,
                           xml_content: Optional[str] = None,
                           xml_link: Optional[str] = None)
    func NewApiOperationPolicy(ctx *Context, name string, args ApiOperationPolicyArgs, opts ...ResourceOption) (*ApiOperationPolicy, error)
    public ApiOperationPolicy(string name, ApiOperationPolicyArgs args, CustomResourceOptions? opts = null)
    public ApiOperationPolicy(String name, ApiOperationPolicyArgs args)
    public ApiOperationPolicy(String name, ApiOperationPolicyArgs args, CustomResourceOptions options)
    
    type: azure:apimanagement:ApiOperationPolicy
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args ApiOperationPolicyArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args ApiOperationPolicyArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args ApiOperationPolicyArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args ApiOperationPolicyArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args ApiOperationPolicyArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Constructor example

    The following reference example uses placeholder values for all input properties.

    var apiOperationPolicyResource = new Azure.ApiManagement.ApiOperationPolicy("apiOperationPolicyResource", new()
    {
        ApiManagementName = "string",
        ApiName = "string",
        OperationId = "string",
        ResourceGroupName = "string",
        XmlContent = "string",
        XmlLink = "string",
    });
    
    example, err := apimanagement.NewApiOperationPolicy(ctx, "apiOperationPolicyResource", &apimanagement.ApiOperationPolicyArgs{
    	ApiManagementName: pulumi.String("string"),
    	ApiName:           pulumi.String("string"),
    	OperationId:       pulumi.String("string"),
    	ResourceGroupName: pulumi.String("string"),
    	XmlContent:        pulumi.String("string"),
    	XmlLink:           pulumi.String("string"),
    })
    
    var apiOperationPolicyResource = new ApiOperationPolicy("apiOperationPolicyResource", ApiOperationPolicyArgs.builder()
        .apiManagementName("string")
        .apiName("string")
        .operationId("string")
        .resourceGroupName("string")
        .xmlContent("string")
        .xmlLink("string")
        .build());
    
    api_operation_policy_resource = azure.apimanagement.ApiOperationPolicy("apiOperationPolicyResource",
        api_management_name="string",
        api_name="string",
        operation_id="string",
        resource_group_name="string",
        xml_content="string",
        xml_link="string")
    
    const apiOperationPolicyResource = new azure.apimanagement.ApiOperationPolicy("apiOperationPolicyResource", {
        apiManagementName: "string",
        apiName: "string",
        operationId: "string",
        resourceGroupName: "string",
        xmlContent: "string",
        xmlLink: "string",
    });
    
    type: azure:apimanagement:ApiOperationPolicy
    properties:
        apiManagementName: string
        apiName: string
        operationId: string
        resourceGroupName: string
        xmlContent: string
        xmlLink: string
    

    ApiOperationPolicy Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

    The ApiOperationPolicy resource accepts the following input properties:

    ApiManagementName string
    The name of the API Management Service. Changing this forces a new resource to be created.
    ApiName string
    The ID of the API Management API Operation within the API Management Service. Changing this forces a new resource to be created.
    OperationId string
    The operation identifier within an API. Must be unique in the current API Management service instance.
    ResourceGroupName string
    The name of the Resource Group in which the API Management Service exists. Changing this forces a new resource to be created.
    XmlContent string
    The XML Content for this Policy.
    XmlLink string
    A link to a Policy XML Document, which must be publicly available.
    ApiManagementName string
    The name of the API Management Service. Changing this forces a new resource to be created.
    ApiName string
    The ID of the API Management API Operation within the API Management Service. Changing this forces a new resource to be created.
    OperationId string
    The operation identifier within an API. Must be unique in the current API Management service instance.
    ResourceGroupName string
    The name of the Resource Group in which the API Management Service exists. Changing this forces a new resource to be created.
    XmlContent string
    The XML Content for this Policy.
    XmlLink string
    A link to a Policy XML Document, which must be publicly available.
    apiManagementName String
    The name of the API Management Service. Changing this forces a new resource to be created.
    apiName String
    The ID of the API Management API Operation within the API Management Service. Changing this forces a new resource to be created.
    operationId String
    The operation identifier within an API. Must be unique in the current API Management service instance.
    resourceGroupName String
    The name of the Resource Group in which the API Management Service exists. Changing this forces a new resource to be created.
    xmlContent String
    The XML Content for this Policy.
    xmlLink String
    A link to a Policy XML Document, which must be publicly available.
    apiManagementName string
    The name of the API Management Service. Changing this forces a new resource to be created.
    apiName string
    The ID of the API Management API Operation within the API Management Service. Changing this forces a new resource to be created.
    operationId string
    The operation identifier within an API. Must be unique in the current API Management service instance.
    resourceGroupName string
    The name of the Resource Group in which the API Management Service exists. Changing this forces a new resource to be created.
    xmlContent string
    The XML Content for this Policy.
    xmlLink string
    A link to a Policy XML Document, which must be publicly available.
    api_management_name str
    The name of the API Management Service. Changing this forces a new resource to be created.
    api_name str
    The ID of the API Management API Operation within the API Management Service. Changing this forces a new resource to be created.
    operation_id str
    The operation identifier within an API. Must be unique in the current API Management service instance.
    resource_group_name str
    The name of the Resource Group in which the API Management Service exists. Changing this forces a new resource to be created.
    xml_content str
    The XML Content for this Policy.
    xml_link str
    A link to a Policy XML Document, which must be publicly available.
    apiManagementName String
    The name of the API Management Service. Changing this forces a new resource to be created.
    apiName String
    The ID of the API Management API Operation within the API Management Service. Changing this forces a new resource to be created.
    operationId String
    The operation identifier within an API. Must be unique in the current API Management service instance.
    resourceGroupName String
    The name of the Resource Group in which the API Management Service exists. Changing this forces a new resource to be created.
    xmlContent String
    The XML Content for this Policy.
    xmlLink String
    A link to a Policy XML Document, which must be publicly available.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the ApiOperationPolicy resource produces the following output properties:

    Id string
    The provider-assigned unique ID for this managed resource.
    Id string
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.
    id string
    The provider-assigned unique ID for this managed resource.
    id str
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.

    Look up Existing ApiOperationPolicy Resource

    Get an existing ApiOperationPolicy resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

    public static get(name: string, id: Input<ID>, state?: ApiOperationPolicyState, opts?: CustomResourceOptions): ApiOperationPolicy
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            api_management_name: Optional[str] = None,
            api_name: Optional[str] = None,
            operation_id: Optional[str] = None,
            resource_group_name: Optional[str] = None,
            xml_content: Optional[str] = None,
            xml_link: Optional[str] = None) -> ApiOperationPolicy
    func GetApiOperationPolicy(ctx *Context, name string, id IDInput, state *ApiOperationPolicyState, opts ...ResourceOption) (*ApiOperationPolicy, error)
    public static ApiOperationPolicy Get(string name, Input<string> id, ApiOperationPolicyState? state, CustomResourceOptions? opts = null)
    public static ApiOperationPolicy get(String name, Output<String> id, ApiOperationPolicyState state, CustomResourceOptions options)
    resources:  _:    type: azure:apimanagement:ApiOperationPolicy    get:      id: ${id}
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    resource_name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    The following state arguments are supported:
    ApiManagementName string
    The name of the API Management Service. Changing this forces a new resource to be created.
    ApiName string
    The ID of the API Management API Operation within the API Management Service. Changing this forces a new resource to be created.
    OperationId string
    The operation identifier within an API. Must be unique in the current API Management service instance.
    ResourceGroupName string
    The name of the Resource Group in which the API Management Service exists. Changing this forces a new resource to be created.
    XmlContent string
    The XML Content for this Policy.
    XmlLink string
    A link to a Policy XML Document, which must be publicly available.
    ApiManagementName string
    The name of the API Management Service. Changing this forces a new resource to be created.
    ApiName string
    The ID of the API Management API Operation within the API Management Service. Changing this forces a new resource to be created.
    OperationId string
    The operation identifier within an API. Must be unique in the current API Management service instance.
    ResourceGroupName string
    The name of the Resource Group in which the API Management Service exists. Changing this forces a new resource to be created.
    XmlContent string
    The XML Content for this Policy.
    XmlLink string
    A link to a Policy XML Document, which must be publicly available.
    apiManagementName String
    The name of the API Management Service. Changing this forces a new resource to be created.
    apiName String
    The ID of the API Management API Operation within the API Management Service. Changing this forces a new resource to be created.
    operationId String
    The operation identifier within an API. Must be unique in the current API Management service instance.
    resourceGroupName String
    The name of the Resource Group in which the API Management Service exists. Changing this forces a new resource to be created.
    xmlContent String
    The XML Content for this Policy.
    xmlLink String
    A link to a Policy XML Document, which must be publicly available.
    apiManagementName string
    The name of the API Management Service. Changing this forces a new resource to be created.
    apiName string
    The ID of the API Management API Operation within the API Management Service. Changing this forces a new resource to be created.
    operationId string
    The operation identifier within an API. Must be unique in the current API Management service instance.
    resourceGroupName string
    The name of the Resource Group in which the API Management Service exists. Changing this forces a new resource to be created.
    xmlContent string
    The XML Content for this Policy.
    xmlLink string
    A link to a Policy XML Document, which must be publicly available.
    api_management_name str
    The name of the API Management Service. Changing this forces a new resource to be created.
    api_name str
    The ID of the API Management API Operation within the API Management Service. Changing this forces a new resource to be created.
    operation_id str
    The operation identifier within an API. Must be unique in the current API Management service instance.
    resource_group_name str
    The name of the Resource Group in which the API Management Service exists. Changing this forces a new resource to be created.
    xml_content str
    The XML Content for this Policy.
    xml_link str
    A link to a Policy XML Document, which must be publicly available.
    apiManagementName String
    The name of the API Management Service. Changing this forces a new resource to be created.
    apiName String
    The ID of the API Management API Operation within the API Management Service. Changing this forces a new resource to be created.
    operationId String
    The operation identifier within an API. Must be unique in the current API Management service instance.
    resourceGroupName String
    The name of the Resource Group in which the API Management Service exists. Changing this forces a new resource to be created.
    xmlContent String
    The XML Content for this Policy.
    xmlLink String
    A link to a Policy XML Document, which must be publicly available.

    Import

    API Management API Operation Policy can be imported using the resource id, e.g.

     $ pulumi import azure:apimanagement/apiOperationPolicy:ApiOperationPolicy example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.ApiManagement/service/instance1/apis/api1/operations/operation1/policies/policy
    

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    Azure Classic pulumi/pulumi-azure
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the azurerm Terraform Provider.
    azure logo

    We recommend using Azure Native.

    Viewing docs for Azure v4.42.0 (Older version)
    published on Monday, Mar 9, 2026 by Pulumi
      Try Pulumi Cloud free. Your team will thank you.