1. Packages
  2. Azure Native v1
  3. API Docs
  4. apimanagement
  5. ApiPolicy
These are the docs for Azure Native v1. We recommenend using the latest version, Azure Native v2.
Azure Native v1 v1.104.0 published on Thursday, Jul 6, 2023 by Pulumi

azure-native.apimanagement.ApiPolicy

Explore with Pulumi AI

azure-native-v1 logo
These are the docs for Azure Native v1. We recommenend using the latest version, Azure Native v2.
Azure Native v1 v1.104.0 published on Thursday, Jul 6, 2023 by Pulumi

    Policy Contract details. API Version: 2020-12-01.

    Example Usage

    ApiManagementCreateApiPolicy

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using AzureNative = Pulumi.AzureNative;
    
    return await Deployment.RunAsync(() => 
    {
        var apiPolicy = new AzureNative.ApiManagement.ApiPolicy("apiPolicy", new()
        {
            ApiId = "5600b57e7e8880006a040001",
            Format = "xml",
            PolicyId = "policy",
            ResourceGroupName = "rg1",
            ServiceName = "apimService1",
            Value = "<policies> <inbound /> <backend>    <forward-request />  </backend>  <outbound /></policies>",
        });
    
    });
    
    package main
    
    import (
    	apimanagement "github.com/pulumi/pulumi-azure-native-sdk/apimanagement"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := apimanagement.NewApiPolicy(ctx, "apiPolicy", &apimanagement.ApiPolicyArgs{
    			ApiId:             pulumi.String("5600b57e7e8880006a040001"),
    			Format:            pulumi.String("xml"),
    			PolicyId:          pulumi.String("policy"),
    			ResourceGroupName: pulumi.String("rg1"),
    			ServiceName:       pulumi.String("apimService1"),
    			Value:             pulumi.String("<policies> <inbound /> <backend>    <forward-request />  </backend>  <outbound /></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.azurenative.apimanagement.ApiPolicy;
    import com.pulumi.azurenative.apimanagement.ApiPolicyArgs;
    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 apiPolicy = new ApiPolicy("apiPolicy", ApiPolicyArgs.builder()        
                .apiId("5600b57e7e8880006a040001")
                .format("xml")
                .policyId("policy")
                .resourceGroupName("rg1")
                .serviceName("apimService1")
                .value("<policies> <inbound /> <backend>    <forward-request />  </backend>  <outbound /></policies>")
                .build());
    
        }
    }
    
    import pulumi
    import pulumi_azure_native as azure_native
    
    api_policy = azure_native.apimanagement.ApiPolicy("apiPolicy",
        api_id="5600b57e7e8880006a040001",
        format="xml",
        policy_id="policy",
        resource_group_name="rg1",
        service_name="apimService1",
        value="<policies> <inbound /> <backend>    <forward-request />  </backend>  <outbound /></policies>")
    
    import * as pulumi from "@pulumi/pulumi";
    import * as azure_native from "@pulumi/azure-native";
    
    const apiPolicy = new azure_native.apimanagement.ApiPolicy("apiPolicy", {
        apiId: "5600b57e7e8880006a040001",
        format: "xml",
        policyId: "policy",
        resourceGroupName: "rg1",
        serviceName: "apimService1",
        value: "<policies> <inbound /> <backend>    <forward-request />  </backend>  <outbound /></policies>",
    });
    
    resources:
      apiPolicy:
        type: azure-native:apimanagement:ApiPolicy
        properties:
          apiId: 5600b57e7e8880006a040001
          format: xml
          policyId: policy
          resourceGroupName: rg1
          serviceName: apimService1
          value: <policies> <inbound /> <backend>    <forward-request />  </backend>  <outbound /></policies>
    

    ApiManagementCreateApiPolicyNonXmlEncoded

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using AzureNative = Pulumi.AzureNative;
    
    return await Deployment.RunAsync(() => 
    {
        var apiPolicy = new AzureNative.ApiManagement.ApiPolicy("apiPolicy", new()
        {
            ApiId = "5600b57e7e8880006a040001",
            Format = "rawxml",
            PolicyId = "policy",
            ResourceGroupName = "rg1",
            ServiceName = "apimService1",
            Value = @"<policies>
         <inbound>
         <base />
      <set-header name=""newvalue"" exists-action=""override"">
       <value>""@(context.Request.Headers.FirstOrDefault(h => h.Ke==""Via""))"" </value>
        </set-header>
      </inbound>
          </policies>",
        });
    
    });
    
    package main
    
    import (
    	apimanagement "github.com/pulumi/pulumi-azure-native-sdk/apimanagement"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := apimanagement.NewApiPolicy(ctx, "apiPolicy", &apimanagement.ApiPolicyArgs{
    			ApiId:             pulumi.String("5600b57e7e8880006a040001"),
    			Format:            pulumi.String("rawxml"),
    			PolicyId:          pulumi.String("policy"),
    			ResourceGroupName: pulumi.String("rg1"),
    			ServiceName:       pulumi.String("apimService1"),
    			Value:             pulumi.String("<policies>
    \n     <inbound>
    \n     <base />
    \n  <set-header name=\"newvalue\" exists-action=\"override\">
    \n   <value>\"@(context.Request.Headers.FirstOrDefault(h => h.Ke==\"Via\"))\" </value>
    \n    </set-header>
    \n  </inbound>
    \n      </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.azurenative.apimanagement.ApiPolicy;
    import com.pulumi.azurenative.apimanagement.ApiPolicyArgs;
    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 apiPolicy = new ApiPolicy("apiPolicy", ApiPolicyArgs.builder()        
                .apiId("5600b57e7e8880006a040001")
                .format("rawxml")
                .policyId("policy")
                .resourceGroupName("rg1")
                .serviceName("apimService1")
                .value("""
    <policies>
         <inbound>
         <base />
      <set-header name="newvalue" exists-action="override">
       <value>"@(context.Request.Headers.FirstOrDefault(h => h.Ke=="Via"))" </value>
        </set-header>
      </inbound>
          </policies>            """)
                .build());
    
        }
    }
    
    import pulumi
    import pulumi_azure_native as azure_native
    
    api_policy = azure_native.apimanagement.ApiPolicy("apiPolicy",
        api_id="5600b57e7e8880006a040001",
        format="rawxml",
        policy_id="policy",
        resource_group_name="rg1",
        service_name="apimService1",
        value="""<policies>
         <inbound>
         <base />
      <set-header name="newvalue" exists-action="override">
       <value>"@(context.Request.Headers.FirstOrDefault(h => h.Ke=="Via"))" </value>
        </set-header>
      </inbound>
          </policies>""")
    
    import * as pulumi from "@pulumi/pulumi";
    import * as azure_native from "@pulumi/azure-native";
    
    const apiPolicy = new azure_native.apimanagement.ApiPolicy("apiPolicy", {
        apiId: "5600b57e7e8880006a040001",
        format: "rawxml",
        policyId: "policy",
        resourceGroupName: "rg1",
        serviceName: "apimService1",
        value: `<policies>
         <inbound>
         <base />
      <set-header name="newvalue" exists-action="override">
       <value>"@(context.Request.Headers.FirstOrDefault(h => h.Ke=="Via"))" </value>
        </set-header>
      </inbound>
          </policies>`,
    });
    
    resources:
      apiPolicy:
        type: azure-native:apimanagement:ApiPolicy
        properties:
          apiId: 5600b57e7e8880006a040001
          format: rawxml
          policyId: policy
          resourceGroupName: rg1
          serviceName: apimService1
          value: "<policies>\r\n     <inbound>\r\n     <base />\r\n  <set-header name=\"newvalue\" exists-action=\"override\">\r\n   <value>\"@(context.Request.Headers.FirstOrDefault(h => h.Ke==\"Via\"))\" </value>\r\n    </set-header>\r\n  </inbound>\r\n      </policies>"
    

    Create ApiPolicy Resource

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

    Constructor syntax

    new ApiPolicy(name: string, args: ApiPolicyArgs, opts?: CustomResourceOptions);
    @overload
    def ApiPolicy(resource_name: str,
                  args: ApiPolicyArgs,
                  opts: Optional[ResourceOptions] = None)
    
    @overload
    def ApiPolicy(resource_name: str,
                  opts: Optional[ResourceOptions] = None,
                  api_id: Optional[str] = None,
                  resource_group_name: Optional[str] = None,
                  service_name: Optional[str] = None,
                  value: Optional[str] = None,
                  format: Optional[Union[str, PolicyContentFormat]] = None,
                  policy_id: Optional[str] = None)
    func NewApiPolicy(ctx *Context, name string, args ApiPolicyArgs, opts ...ResourceOption) (*ApiPolicy, error)
    public ApiPolicy(string name, ApiPolicyArgs args, CustomResourceOptions? opts = null)
    public ApiPolicy(String name, ApiPolicyArgs args)
    public ApiPolicy(String name, ApiPolicyArgs args, CustomResourceOptions options)
    
    type: azure-native:apimanagement:ApiPolicy
    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 ApiPolicyArgs
    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 ApiPolicyArgs
    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 ApiPolicyArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args ApiPolicyArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args ApiPolicyArgs
    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 apiPolicyResource = new AzureNative.Apimanagement.ApiPolicy("apiPolicyResource", new()
    {
        ApiId = "string",
        ResourceGroupName = "string",
        ServiceName = "string",
        Value = "string",
        Format = "string",
        PolicyId = "string",
    });
    
    example, err := apimanagement.NewApiPolicy(ctx, "apiPolicyResource", &apimanagement.ApiPolicyArgs{
    	ApiId:             "string",
    	ResourceGroupName: "string",
    	ServiceName:       "string",
    	Value:             "string",
    	Format:            "string",
    	PolicyId:          "string",
    })
    
    var apiPolicyResource = new ApiPolicy("apiPolicyResource", ApiPolicyArgs.builder()
        .apiId("string")
        .resourceGroupName("string")
        .serviceName("string")
        .value("string")
        .format("string")
        .policyId("string")
        .build());
    
    api_policy_resource = azure_native.apimanagement.ApiPolicy("apiPolicyResource",
        api_id=string,
        resource_group_name=string,
        service_name=string,
        value=string,
        format=string,
        policy_id=string)
    
    const apiPolicyResource = new azure_native.apimanagement.ApiPolicy("apiPolicyResource", {
        apiId: "string",
        resourceGroupName: "string",
        serviceName: "string",
        value: "string",
        format: "string",
        policyId: "string",
    });
    
    type: azure-native:apimanagement:ApiPolicy
    properties:
        apiId: string
        format: string
        policyId: string
        resourceGroupName: string
        serviceName: string
        value: string
    

    ApiPolicy 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 ApiPolicy resource accepts the following input properties:

    ApiId string
    API revision identifier. Must be unique in the current API Management service instance. Non-current revision has ;rev=n as a suffix where n is the revision number.
    ResourceGroupName string
    The name of the resource group.
    ServiceName string
    The name of the API Management service.
    Value string
    Contents of the Policy as defined by the format.
    Format string | Pulumi.AzureNative.ApiManagement.PolicyContentFormat
    Format of the policyContent.
    PolicyId string
    The identifier of the Policy.
    ApiId string
    API revision identifier. Must be unique in the current API Management service instance. Non-current revision has ;rev=n as a suffix where n is the revision number.
    ResourceGroupName string
    The name of the resource group.
    ServiceName string
    The name of the API Management service.
    Value string
    Contents of the Policy as defined by the format.
    Format string | PolicyContentFormat
    Format of the policyContent.
    PolicyId string
    The identifier of the Policy.
    apiId String
    API revision identifier. Must be unique in the current API Management service instance. Non-current revision has ;rev=n as a suffix where n is the revision number.
    resourceGroupName String
    The name of the resource group.
    serviceName String
    The name of the API Management service.
    value String
    Contents of the Policy as defined by the format.
    format String | PolicyContentFormat
    Format of the policyContent.
    policyId String
    The identifier of the Policy.
    apiId string
    API revision identifier. Must be unique in the current API Management service instance. Non-current revision has ;rev=n as a suffix where n is the revision number.
    resourceGroupName string
    The name of the resource group.
    serviceName string
    The name of the API Management service.
    value string
    Contents of the Policy as defined by the format.
    format string | PolicyContentFormat
    Format of the policyContent.
    policyId string
    The identifier of the Policy.
    api_id str
    API revision identifier. Must be unique in the current API Management service instance. Non-current revision has ;rev=n as a suffix where n is the revision number.
    resource_group_name str
    The name of the resource group.
    service_name str
    The name of the API Management service.
    value str
    Contents of the Policy as defined by the format.
    format str | PolicyContentFormat
    Format of the policyContent.
    policy_id str
    The identifier of the Policy.
    apiId String
    API revision identifier. Must be unique in the current API Management service instance. Non-current revision has ;rev=n as a suffix where n is the revision number.
    resourceGroupName String
    The name of the resource group.
    serviceName String
    The name of the API Management service.
    value String
    Contents of the Policy as defined by the format.
    format String | "xml" | "xml-link" | "rawxml" | "rawxml-link"
    Format of the policyContent.
    policyId String
    The identifier of the Policy.

    Outputs

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

    Id string
    The provider-assigned unique ID for this managed resource.
    Name string
    Resource name.
    Type string
    Resource type for API Management resource.
    Id string
    The provider-assigned unique ID for this managed resource.
    Name string
    Resource name.
    Type string
    Resource type for API Management resource.
    id String
    The provider-assigned unique ID for this managed resource.
    name String
    Resource name.
    type String
    Resource type for API Management resource.
    id string
    The provider-assigned unique ID for this managed resource.
    name string
    Resource name.
    type string
    Resource type for API Management resource.
    id str
    The provider-assigned unique ID for this managed resource.
    name str
    Resource name.
    type str
    Resource type for API Management resource.
    id String
    The provider-assigned unique ID for this managed resource.
    name String
    Resource name.
    type String
    Resource type for API Management resource.

    Supporting Types

    PolicyContentFormat, PolicyContentFormatArgs

    Xml
    xmlThe contents are inline and Content type is an XML document.
    Xml_link
    xml-linkThe policy XML document is hosted on a http endpoint accessible from the API Management service.
    Rawxml
    rawxmlThe contents are inline and Content type is a non XML encoded policy document.
    Rawxml_link
    rawxml-linkThe policy document is not Xml encoded and is hosted on a http endpoint accessible from the API Management service.
    PolicyContentFormatXml
    xmlThe contents are inline and Content type is an XML document.
    PolicyContentFormat_Xml_Link
    xml-linkThe policy XML document is hosted on a http endpoint accessible from the API Management service.
    PolicyContentFormatRawxml
    rawxmlThe contents are inline and Content type is a non XML encoded policy document.
    PolicyContentFormat_Rawxml_Link
    rawxml-linkThe policy document is not Xml encoded and is hosted on a http endpoint accessible from the API Management service.
    Xml
    xmlThe contents are inline and Content type is an XML document.
    Xmllink
    xml-linkThe policy XML document is hosted on a http endpoint accessible from the API Management service.
    Rawxml
    rawxmlThe contents are inline and Content type is a non XML encoded policy document.
    Rawxmllink
    rawxml-linkThe policy document is not Xml encoded and is hosted on a http endpoint accessible from the API Management service.
    Xml
    xmlThe contents are inline and Content type is an XML document.
    Xml_link
    xml-linkThe policy XML document is hosted on a http endpoint accessible from the API Management service.
    Rawxml
    rawxmlThe contents are inline and Content type is a non XML encoded policy document.
    Rawxml_link
    rawxml-linkThe policy document is not Xml encoded and is hosted on a http endpoint accessible from the API Management service.
    XML
    xmlThe contents are inline and Content type is an XML document.
    XML_LINK
    xml-linkThe policy XML document is hosted on a http endpoint accessible from the API Management service.
    RAWXML
    rawxmlThe contents are inline and Content type is a non XML encoded policy document.
    RAWXML_LINK
    rawxml-linkThe policy document is not Xml encoded and is hosted on a http endpoint accessible from the API Management service.
    "xml"
    xmlThe contents are inline and Content type is an XML document.
    "xml-link"
    xml-linkThe policy XML document is hosted on a http endpoint accessible from the API Management service.
    "rawxml"
    rawxmlThe contents are inline and Content type is a non XML encoded policy document.
    "rawxml-link"
    rawxml-linkThe policy document is not Xml encoded and is hosted on a http endpoint accessible from the API Management service.

    Import

    An existing resource can be imported using its type token, name, and identifier, e.g.

    $ pulumi import azure-native:apimanagement:ApiPolicy policy /subscriptions/4c1a3bc6-89f9-46fe-a175-5d8984b25095/resourcegroups/Api-DF-West-US/providers/Microsoft.ApiManagement/service/samirmsiservice2/apis/echo-api/operations/create-resource/policies/policy 
    

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

    Package Details

    Repository
    azure-native-v1 pulumi/pulumi-azure-native
    License
    Apache-2.0
    azure-native-v1 logo
    These are the docs for Azure Native v1. We recommenend using the latest version, Azure Native v2.
    Azure Native v1 v1.104.0 published on Thursday, Jul 6, 2023 by Pulumi