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

We recommend using Azure Native.

Azure Classic v5.67.0 published on Wednesday, Feb 21, 2024 by Pulumi

azure.apimanagement.ApiOperationPolicy

Explore with Pulumi AI

azure logo

We recommend using Azure Native.

Azure Classic v5.67.0 published on Wednesday, Feb 21, 2024 by Pulumi

    Manages an API Management API Operation Policy

    Example Usage

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Azure = Pulumi.Azure;
    
    return await Deployment.RunAsync(() => 
    {
        var exampleResourceGroup = new Azure.Core.ResourceGroup("exampleResourceGroup", new()
        {
            Location = "West Europe",
        });
    
        var exampleService = new Azure.ApiManagement.Service("exampleService", new()
        {
            Location = exampleResourceGroup.Location,
            ResourceGroupName = exampleResourceGroup.Name,
            PublisherName = "My Company",
            PublisherEmail = "company@terraform.io",
            SkuName = "Developer_1",
        });
    
        var exampleApi = new Azure.ApiManagement.Api("exampleApi", new()
        {
            ResourceGroupName = exampleResourceGroup.Name,
            ApiManagementName = exampleService.Name,
            Revision = "1",
        });
    
        var exampleApiOperation = new Azure.ApiManagement.ApiOperation("exampleApiOperation", new()
        {
            OperationId = "acctest-operation",
            ApiName = exampleApi.Name,
            ApiManagementName = exampleService.Name,
            ResourceGroupName = exampleResourceGroup.Name,
            DisplayName = "DELETE Resource",
            Method = "DELETE",
            UrlTemplate = "/resource",
        });
    
        var exampleApiOperationPolicy = new Azure.ApiManagement.ApiOperationPolicy("exampleApiOperationPolicy", new()
        {
            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 (
    	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/apimanagement"
    	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		exampleResourceGroup, err := core.NewResourceGroup(ctx, "exampleResourceGroup", &core.ResourceGroupArgs{
    			Location: pulumi.String("West Europe"),
    		})
    		if err != nil {
    			return err
    		}
    		exampleService, err := apimanagement.NewService(ctx, "exampleService", &apimanagement.ServiceArgs{
    			Location:          exampleResourceGroup.Location,
    			ResourceGroupName: exampleResourceGroup.Name,
    			PublisherName:     pulumi.String("My Company"),
    			PublisherEmail:    pulumi.String("company@terraform.io"),
    			SkuName:           pulumi.String("Developer_1"),
    		})
    		if err != nil {
    			return err
    		}
    		exampleApi, err := apimanagement.NewApi(ctx, "exampleApi", &apimanagement.ApiArgs{
    			ResourceGroupName: exampleResourceGroup.Name,
    			ApiManagementName: exampleService.Name,
    			Revision:          pulumi.String("1"),
    		})
    		if err != nil {
    			return err
    		}
    		exampleApiOperation, err := apimanagement.NewApiOperation(ctx, "exampleApiOperation", &apimanagement.ApiOperationArgs{
    			OperationId:       pulumi.String("acctest-operation"),
    			ApiName:           exampleApi.Name,
    			ApiManagementName: exampleService.Name,
    			ResourceGroupName: exampleResourceGroup.Name,
    			DisplayName:       pulumi.String("DELETE Resource"),
    			Method:            pulumi.String("DELETE"),
    			UrlTemplate:       pulumi.String("/resource"),
    		})
    		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(`<policies>
      <inbound>
        <find-and-replace from="xyz" to="abc" />
      </inbound>
    </policies>
    `),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.azure.core.ResourceGroup;
    import com.pulumi.azure.core.ResourceGroupArgs;
    import com.pulumi.azure.apimanagement.Service;
    import com.pulumi.azure.apimanagement.ServiceArgs;
    import com.pulumi.azure.apimanagement.Api;
    import com.pulumi.azure.apimanagement.ApiArgs;
    import com.pulumi.azure.apimanagement.ApiOperation;
    import com.pulumi.azure.apimanagement.ApiOperationArgs;
    import com.pulumi.azure.apimanagement.ApiOperationPolicy;
    import com.pulumi.azure.apimanagement.ApiOperationPolicyArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            var exampleResourceGroup = new ResourceGroup("exampleResourceGroup", ResourceGroupArgs.builder()        
                .location("West Europe")
                .build());
    
            var exampleService = new Service("exampleService", ServiceArgs.builder()        
                .location(exampleResourceGroup.location())
                .resourceGroupName(exampleResourceGroup.name())
                .publisherName("My Company")
                .publisherEmail("company@terraform.io")
                .skuName("Developer_1")
                .build());
    
            var exampleApi = new Api("exampleApi", ApiArgs.builder()        
                .resourceGroupName(exampleResourceGroup.name())
                .apiManagementName(exampleService.name())
                .revision("1")
                .build());
    
            var exampleApiOperation = new ApiOperation("exampleApiOperation", ApiOperationArgs.builder()        
                .operationId("acctest-operation")
                .apiName(exampleApi.name())
                .apiManagementName(exampleService.name())
                .resourceGroupName(exampleResourceGroup.name())
                .displayName("DELETE Resource")
                .method("DELETE")
                .urlTemplate("/resource")
                .build());
    
            var exampleApiOperationPolicy = new ApiOperationPolicy("exampleApiOperationPolicy", ApiOperationPolicyArgs.builder()        
                .apiName(exampleApiOperation.apiName())
                .apiManagementName(exampleApiOperation.apiManagementName())
                .resourceGroupName(exampleApiOperation.resourceGroupName())
                .operationId(exampleApiOperation.operationId())
                .xmlContent("""
    <policies>
      <inbound>
        <find-and-replace from="xyz" to="abc" />
      </inbound>
    </policies>
                """)
                .build());
    
        }
    }
    
    import pulumi
    import pulumi_azure as azure
    
    example_resource_group = azure.core.ResourceGroup("exampleResourceGroup", location="West Europe")
    example_service = azure.apimanagement.Service("exampleService",
        location=example_resource_group.location,
        resource_group_name=example_resource_group.name,
        publisher_name="My Company",
        publisher_email="company@terraform.io",
        sku_name="Developer_1")
    example_api = azure.apimanagement.Api("exampleApi",
        resource_group_name=example_resource_group.name,
        api_management_name=example_service.name,
        revision="1")
    example_api_operation = azure.apimanagement.ApiOperation("exampleApiOperation",
        operation_id="acctest-operation",
        api_name=example_api.name,
        api_management_name=example_service.name,
        resource_group_name=example_resource_group.name,
        display_name="DELETE Resource",
        method="DELETE",
        url_template="/resource")
    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>
    """)
    
    import * as pulumi from "@pulumi/pulumi";
    import * as azure from "@pulumi/azure";
    
    const exampleResourceGroup = new azure.core.ResourceGroup("exampleResourceGroup", {location: "West Europe"});
    const exampleService = new azure.apimanagement.Service("exampleService", {
        location: exampleResourceGroup.location,
        resourceGroupName: exampleResourceGroup.name,
        publisherName: "My Company",
        publisherEmail: "company@terraform.io",
        skuName: "Developer_1",
    });
    const exampleApi = new azure.apimanagement.Api("exampleApi", {
        resourceGroupName: exampleResourceGroup.name,
        apiManagementName: exampleService.name,
        revision: "1",
    });
    const exampleApiOperation = new azure.apimanagement.ApiOperation("exampleApiOperation", {
        operationId: "acctest-operation",
        apiName: exampleApi.name,
        apiManagementName: exampleService.name,
        resourceGroupName: exampleResourceGroup.name,
        displayName: "DELETE Resource",
        method: "DELETE",
        urlTemplate: "/resource",
    });
    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>
    `,
    });
    
    resources:
      exampleResourceGroup:
        type: azure:core:ResourceGroup
        properties:
          location: West Europe
      exampleService:
        type: azure:apimanagement:Service
        properties:
          location: ${exampleResourceGroup.location}
          resourceGroupName: ${exampleResourceGroup.name}
          publisherName: My Company
          publisherEmail: company@terraform.io
          skuName: Developer_1
      exampleApi:
        type: azure:apimanagement:Api
        properties:
          resourceGroupName: ${exampleResourceGroup.name}
          apiManagementName: ${exampleService.name}
          revision: '1'
      exampleApiOperation:
        type: azure:apimanagement:ApiOperation
        properties:
          operationId: acctest-operation
          apiName: ${exampleApi.name}
          apiManagementName: ${exampleService.name}
          resourceGroupName: ${exampleResourceGroup.name}
          displayName: DELETE Resource
          method: DELETE
          urlTemplate: /resource
      exampleApiOperationPolicy:
        type: azure:apimanagement:ApiOperationPolicy
        properties:
          apiName: ${exampleApiOperation.apiName}
          apiManagementName: ${exampleApiOperation.apiManagementName}
          resourceGroupName: ${exampleApiOperation.resourceGroupName}
          operationId: ${exampleApiOperation.operationId}
          xmlContent: |
            <policies>
              <inbound>
                <find-and-replace from="xyz" to="abc" />
              </inbound>
            </policies>        
    

    Create ApiOperationPolicy Resource

    new ApiOperationPolicy(name: string, args: ApiOperationPolicyArgs, opts?: CustomResourceOptions);
    @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)
    @overload
    def ApiOperationPolicy(resource_name: str,
                           args: ApiOperationPolicyArgs,
                           opts: Optional[ResourceOptions] = 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.
    
    
    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.

    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

    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 name of the API within the API Management Service where the Operation exists. 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. Changing this forces a new resource to be created.
    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 name of the API within the API Management Service where the Operation exists. 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. Changing this forces a new resource to be created.
    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 name of the API within the API Management Service where the Operation exists. 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. Changing this forces a new resource to be created.
    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 name of the API within the API Management Service where the Operation exists. 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. Changing this forces a new resource to be created.
    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 name of the API within the API Management Service where the Operation exists. 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. Changing this forces a new resource to be created.
    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 name of the API within the API Management Service where the Operation exists. 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. Changing this forces a new resource to be created.
    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)
    Resource lookup is not supported in YAML
    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 name of the API within the API Management Service where the Operation exists. 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. Changing this forces a new resource to be created.
    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 name of the API within the API Management Service where the Operation exists. 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. Changing this forces a new resource to be created.
    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 name of the API within the API Management Service where the Operation exists. 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. Changing this forces a new resource to be created.
    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 name of the API within the API Management Service where the Operation exists. 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. Changing this forces a new resource to be created.
    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 name of the API within the API Management Service where the Operation exists. 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. Changing this forces a new resource to be created.
    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 name of the API within the API Management Service where the Operation exists. 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. Changing this forces a new resource to be created.
    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
    

    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.

    Azure Classic v5.67.0 published on Wednesday, Feb 21, 2024 by Pulumi