We recommend using Azure Native.
azure.apimanagement.ApiOperationPolicy
Explore with Pulumi AI
Manages an API Management API Operation Policy
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";
const example = new azure.core.ResourceGroup("example", {
name: "example-resources",
location: "West Europe",
});
const exampleService = new azure.apimanagement.Service("example", {
name: "example-apim",
location: example.location,
resourceGroupName: example.name,
publisherName: "My Company",
publisherEmail: "company@terraform.io",
skuName: "Developer_1",
});
const exampleApi = new azure.apimanagement.Api("example", {
name: "example-api",
resourceGroupName: example.name,
apiManagementName: exampleService.name,
revision: "1",
});
const exampleApiOperation = new azure.apimanagement.ApiOperation("example", {
operationId: "acctest-operation",
apiName: exampleApi.name,
apiManagementName: exampleService.name,
resourceGroupName: example.name,
displayName: "DELETE Resource",
method: "DELETE",
urlTemplate: "/resource",
});
const exampleApiOperationPolicy = new azure.apimanagement.ApiOperationPolicy("example", {
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 = azure.core.ResourceGroup("example",
name="example-resources",
location="West Europe")
example_service = azure.apimanagement.Service("example",
name="example-apim",
location=example.location,
resource_group_name=example.name,
publisher_name="My Company",
publisher_email="company@terraform.io",
sku_name="Developer_1")
example_api = azure.apimanagement.Api("example",
name="example-api",
resource_group_name=example.name,
api_management_name=example_service.name,
revision="1")
example_api_operation = azure.apimanagement.ApiOperation("example",
operation_id="acctest-operation",
api_name=example_api.name,
api_management_name=example_service.name,
resource_group_name=example.name,
display_name="DELETE Resource",
method="DELETE",
url_template="/resource")
example_api_operation_policy = azure.apimanagement.ApiOperationPolicy("example",
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>
""")
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 {
example, err := core.NewResourceGroup(ctx, "example", &core.ResourceGroupArgs{
Name: pulumi.String("example-resources"),
Location: pulumi.String("West Europe"),
})
if err != nil {
return err
}
exampleService, err := apimanagement.NewService(ctx, "example", &apimanagement.ServiceArgs{
Name: pulumi.String("example-apim"),
Location: example.Location,
ResourceGroupName: example.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, "example", &apimanagement.ApiArgs{
Name: pulumi.String("example-api"),
ResourceGroupName: example.Name,
ApiManagementName: exampleService.Name,
Revision: pulumi.String("1"),
})
if err != nil {
return err
}
exampleApiOperation, err := apimanagement.NewApiOperation(ctx, "example", &apimanagement.ApiOperationArgs{
OperationId: pulumi.String("acctest-operation"),
ApiName: exampleApi.Name,
ApiManagementName: exampleService.Name,
ResourceGroupName: example.Name,
DisplayName: pulumi.String("DELETE Resource"),
Method: pulumi.String("DELETE"),
UrlTemplate: pulumi.String("/resource"),
})
if err != nil {
return err
}
_, err = apimanagement.NewApiOperationPolicy(ctx, "example", &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
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Azure = Pulumi.Azure;
return await Deployment.RunAsync(() =>
{
var example = new Azure.Core.ResourceGroup("example", new()
{
Name = "example-resources",
Location = "West Europe",
});
var exampleService = new Azure.ApiManagement.Service("example", new()
{
Name = "example-apim",
Location = example.Location,
ResourceGroupName = example.Name,
PublisherName = "My Company",
PublisherEmail = "company@terraform.io",
SkuName = "Developer_1",
});
var exampleApi = new Azure.ApiManagement.Api("example", new()
{
Name = "example-api",
ResourceGroupName = example.Name,
ApiManagementName = exampleService.Name,
Revision = "1",
});
var exampleApiOperation = new Azure.ApiManagement.ApiOperation("example", new()
{
OperationId = "acctest-operation",
ApiName = exampleApi.Name,
ApiManagementName = exampleService.Name,
ResourceGroupName = example.Name,
DisplayName = "DELETE Resource",
Method = "DELETE",
UrlTemplate = "/resource",
});
var exampleApiOperationPolicy = new Azure.ApiManagement.ApiOperationPolicy("example", 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 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 example = new ResourceGroup("example", ResourceGroupArgs.builder()
.name("example-resources")
.location("West Europe")
.build());
var exampleService = new Service("exampleService", ServiceArgs.builder()
.name("example-apim")
.location(example.location())
.resourceGroupName(example.name())
.publisherName("My Company")
.publisherEmail("company@terraform.io")
.skuName("Developer_1")
.build());
var exampleApi = new Api("exampleApi", ApiArgs.builder()
.name("example-api")
.resourceGroupName(example.name())
.apiManagementName(exampleService.name())
.revision("1")
.build());
var exampleApiOperation = new ApiOperation("exampleApiOperation", ApiOperationArgs.builder()
.operationId("acctest-operation")
.apiName(exampleApi.name())
.apiManagementName(exampleService.name())
.resourceGroupName(example.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());
}
}
resources:
example:
type: azure:core:ResourceGroup
properties:
name: example-resources
location: West Europe
exampleService:
type: azure:apimanagement:Service
name: example
properties:
name: example-apim
location: ${example.location}
resourceGroupName: ${example.name}
publisherName: My Company
publisherEmail: company@terraform.io
skuName: Developer_1
exampleApi:
type: azure:apimanagement:Api
name: example
properties:
name: example-api
resourceGroupName: ${example.name}
apiManagementName: ${exampleService.name}
revision: '1'
exampleApiOperation:
type: azure:apimanagement:ApiOperation
name: example
properties:
operationId: acctest-operation
apiName: ${exampleApi.name}
apiManagementName: ${exampleService.name}
resourceGroupName: ${example.name}
displayName: DELETE Resource
method: DELETE
urlTemplate: /resource
exampleApiOperationPolicy:
type: azure:apimanagement:ApiOperationPolicy
name: example
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
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
The ApiOperationPolicy resource accepts the following input properties:
- Api
Management stringName - The name of the API Management Service. Changing this forces a new resource to be created.
- Api
Name string - 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 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.
- Resource
Group stringName - The name of the Resource Group in which the API Management Service exists. Changing this forces a new resource to be created.
- Xml
Content string - The XML Content for this Policy.
- Xml
Link string - A link to a Policy XML Document, which must be publicly available.
- Api
Management stringName - The name of the API Management Service. Changing this forces a new resource to be created.
- Api
Name string - 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 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.
- Resource
Group stringName - The name of the Resource Group in which the API Management Service exists. Changing this forces a new resource to be created.
- Xml
Content string - The XML Content for this Policy.
- Xml
Link string - A link to a Policy XML Document, which must be publicly available.
- api
Management StringName - The name of the API Management Service. Changing this forces a new resource to be created.
- api
Name String - 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 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.
- resource
Group StringName - The name of the Resource Group in which the API Management Service exists. Changing this forces a new resource to be created.
- xml
Content String - The XML Content for this Policy.
- xml
Link String - A link to a Policy XML Document, which must be publicly available.
- api
Management stringName - The name of the API Management Service. Changing this forces a new resource to be created.
- api
Name string - 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 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.
- resource
Group stringName - The name of the Resource Group in which the API Management Service exists. Changing this forces a new resource to be created.
- xml
Content string - The XML Content for this Policy.
- xml
Link string - A link to a Policy XML Document, which must be publicly available.
- api_
management_ strname - 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_ strname - 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.
- api
Management StringName - The name of the API Management Service. Changing this forces a new resource to be created.
- api
Name String - 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 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.
- resource
Group StringName - The name of the Resource Group in which the API Management Service exists. Changing this forces a new resource to be created.
- xml
Content String - The XML Content for this Policy.
- xml
Link 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.
- Api
Management stringName - The name of the API Management Service. Changing this forces a new resource to be created.
- Api
Name string - 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 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.
- Resource
Group stringName - The name of the Resource Group in which the API Management Service exists. Changing this forces a new resource to be created.
- Xml
Content string - The XML Content for this Policy.
- Xml
Link string - A link to a Policy XML Document, which must be publicly available.
- Api
Management stringName - The name of the API Management Service. Changing this forces a new resource to be created.
- Api
Name string - 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 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.
- Resource
Group stringName - The name of the Resource Group in which the API Management Service exists. Changing this forces a new resource to be created.
- Xml
Content string - The XML Content for this Policy.
- Xml
Link string - A link to a Policy XML Document, which must be publicly available.
- api
Management StringName - The name of the API Management Service. Changing this forces a new resource to be created.
- api
Name String - 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 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.
- resource
Group StringName - The name of the Resource Group in which the API Management Service exists. Changing this forces a new resource to be created.
- xml
Content String - The XML Content for this Policy.
- xml
Link String - A link to a Policy XML Document, which must be publicly available.
- api
Management stringName - The name of the API Management Service. Changing this forces a new resource to be created.
- api
Name string - 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 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.
- resource
Group stringName - The name of the Resource Group in which the API Management Service exists. Changing this forces a new resource to be created.
- xml
Content string - The XML Content for this Policy.
- xml
Link string - A link to a Policy XML Document, which must be publicly available.
- api_
management_ strname - 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_ strname - 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.
- api
Management StringName - The name of the API Management Service. Changing this forces a new resource to be created.
- api
Name String - 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 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.
- resource
Group StringName - The name of the Resource Group in which the API Management Service exists. Changing this forces a new resource to be created.
- xml
Content String - The XML Content for this Policy.
- xml
Link 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
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.