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

We recommend using Azure Native.

Azure v6.30.0 published on Thursday, Nov 20, 2025 by Pulumi
azure logo

We recommend using Azure Native.

Azure v6.30.0 published on Thursday, Nov 20, 2025 by Pulumi

    Manages an API Management Workspace Policy Fragment.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as azure from "@pulumi/azure";
    import * as std from "@pulumi/std";
    
    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: "pub1",
        publisherEmail: "pub1@email.com",
        skuName: "Premium_1",
    });
    const exampleWorkspace = new azure.apimanagement.Workspace("example", {
        name: "example-workspace",
        apiManagementId: exampleService.id,
        displayName: "Example Workspace",
        description: "Example API Management Workspace",
    });
    const exampleWorkspacePolicyFragment = new azure.apimanagement.WorkspacePolicyFragment("example", {
        name: "example-policy-fragment",
        apiManagementWorkspaceId: exampleWorkspace.id,
        xmlFormat: "xml",
        xmlContent: std.file({
            input: "policy-fragment-1.xml",
        }).then(invoke => invoke.result),
    });
    
    import pulumi
    import pulumi_azure as azure
    import pulumi_std as std
    
    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="pub1",
        publisher_email="pub1@email.com",
        sku_name="Premium_1")
    example_workspace = azure.apimanagement.Workspace("example",
        name="example-workspace",
        api_management_id=example_service.id,
        display_name="Example Workspace",
        description="Example API Management Workspace")
    example_workspace_policy_fragment = azure.apimanagement.WorkspacePolicyFragment("example",
        name="example-policy-fragment",
        api_management_workspace_id=example_workspace.id,
        xml_format="xml",
        xml_content=std.file(input="policy-fragment-1.xml").result)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/apimanagement"
    	"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/core"
    	"github.com/pulumi/pulumi-std/sdk/go/std"
    	"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("pub1"),
    			PublisherEmail:    pulumi.String("pub1@email.com"),
    			SkuName:           pulumi.String("Premium_1"),
    		})
    		if err != nil {
    			return err
    		}
    		exampleWorkspace, err := apimanagement.NewWorkspace(ctx, "example", &apimanagement.WorkspaceArgs{
    			Name:            pulumi.String("example-workspace"),
    			ApiManagementId: exampleService.ID(),
    			DisplayName:     pulumi.String("Example Workspace"),
    			Description:     pulumi.String("Example API Management Workspace"),
    		})
    		if err != nil {
    			return err
    		}
    		invokeFile, err := std.File(ctx, &std.FileArgs{
    			Input: "policy-fragment-1.xml",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		_, err = apimanagement.NewWorkspacePolicyFragment(ctx, "example", &apimanagement.WorkspacePolicyFragmentArgs{
    			Name:                     pulumi.String("example-policy-fragment"),
    			ApiManagementWorkspaceId: exampleWorkspace.ID(),
    			XmlFormat:                pulumi.String("xml"),
    			XmlContent:               pulumi.String(invokeFile.Result),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Azure = Pulumi.Azure;
    using Std = Pulumi.Std;
    
    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 = "pub1",
            PublisherEmail = "pub1@email.com",
            SkuName = "Premium_1",
        });
    
        var exampleWorkspace = new Azure.ApiManagement.Workspace("example", new()
        {
            Name = "example-workspace",
            ApiManagementId = exampleService.Id,
            DisplayName = "Example Workspace",
            Description = "Example API Management Workspace",
        });
    
        var exampleWorkspacePolicyFragment = new Azure.ApiManagement.WorkspacePolicyFragment("example", new()
        {
            Name = "example-policy-fragment",
            ApiManagementWorkspaceId = exampleWorkspace.Id,
            XmlFormat = "xml",
            XmlContent = Std.File.Invoke(new()
            {
                Input = "policy-fragment-1.xml",
            }).Apply(invoke => invoke.Result),
        });
    
    });
    
    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.Workspace;
    import com.pulumi.azure.apimanagement.WorkspaceArgs;
    import com.pulumi.azure.apimanagement.WorkspacePolicyFragment;
    import com.pulumi.azure.apimanagement.WorkspacePolicyFragmentArgs;
    import com.pulumi.std.StdFunctions;
    import com.pulumi.std.inputs.FileArgs;
    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("pub1")
                .publisherEmail("pub1@email.com")
                .skuName("Premium_1")
                .build());
    
            var exampleWorkspace = new Workspace("exampleWorkspace", WorkspaceArgs.builder()
                .name("example-workspace")
                .apiManagementId(exampleService.id())
                .displayName("Example Workspace")
                .description("Example API Management Workspace")
                .build());
    
            var exampleWorkspacePolicyFragment = new WorkspacePolicyFragment("exampleWorkspacePolicyFragment", WorkspacePolicyFragmentArgs.builder()
                .name("example-policy-fragment")
                .apiManagementWorkspaceId(exampleWorkspace.id())
                .xmlFormat("xml")
                .xmlContent(StdFunctions.file(FileArgs.builder()
                    .input("policy-fragment-1.xml")
                    .build()).result())
                .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: pub1
          publisherEmail: pub1@email.com
          skuName: Premium_1
      exampleWorkspace:
        type: azure:apimanagement:Workspace
        name: example
        properties:
          name: example-workspace
          apiManagementId: ${exampleService.id}
          displayName: Example Workspace
          description: Example API Management Workspace
      exampleWorkspacePolicyFragment:
        type: azure:apimanagement:WorkspacePolicyFragment
        name: example
        properties:
          name: example-policy-fragment
          apiManagementWorkspaceId: ${exampleWorkspace.id}
          xmlFormat: xml
          xmlContent:
            fn::invoke:
              function: std:file
              arguments:
                input: policy-fragment-1.xml
              return: result
    

    API Providers

    This resource uses the following Azure API Providers:

    • Microsoft.ApiManagement - 2024-05-01

    Create WorkspacePolicyFragment Resource

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

    Constructor syntax

    new WorkspacePolicyFragment(name: string, args: WorkspacePolicyFragmentArgs, opts?: CustomResourceOptions);
    @overload
    def WorkspacePolicyFragment(resource_name: str,
                                args: WorkspacePolicyFragmentArgs,
                                opts: Optional[ResourceOptions] = None)
    
    @overload
    def WorkspacePolicyFragment(resource_name: str,
                                opts: Optional[ResourceOptions] = None,
                                api_management_workspace_id: Optional[str] = None,
                                xml_content: Optional[str] = None,
                                description: Optional[str] = None,
                                name: Optional[str] = None,
                                xml_format: Optional[str] = None)
    func NewWorkspacePolicyFragment(ctx *Context, name string, args WorkspacePolicyFragmentArgs, opts ...ResourceOption) (*WorkspacePolicyFragment, error)
    public WorkspacePolicyFragment(string name, WorkspacePolicyFragmentArgs args, CustomResourceOptions? opts = null)
    public WorkspacePolicyFragment(String name, WorkspacePolicyFragmentArgs args)
    public WorkspacePolicyFragment(String name, WorkspacePolicyFragmentArgs args, CustomResourceOptions options)
    
    type: azure:apimanagement:WorkspacePolicyFragment
    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 WorkspacePolicyFragmentArgs
    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 WorkspacePolicyFragmentArgs
    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 WorkspacePolicyFragmentArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args WorkspacePolicyFragmentArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args WorkspacePolicyFragmentArgs
    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 workspacePolicyFragmentResource = new Azure.ApiManagement.WorkspacePolicyFragment("workspacePolicyFragmentResource", new()
    {
        ApiManagementWorkspaceId = "string",
        XmlContent = "string",
        Description = "string",
        Name = "string",
        XmlFormat = "string",
    });
    
    example, err := apimanagement.NewWorkspacePolicyFragment(ctx, "workspacePolicyFragmentResource", &apimanagement.WorkspacePolicyFragmentArgs{
    	ApiManagementWorkspaceId: pulumi.String("string"),
    	XmlContent:               pulumi.String("string"),
    	Description:              pulumi.String("string"),
    	Name:                     pulumi.String("string"),
    	XmlFormat:                pulumi.String("string"),
    })
    
    var workspacePolicyFragmentResource = new WorkspacePolicyFragment("workspacePolicyFragmentResource", WorkspacePolicyFragmentArgs.builder()
        .apiManagementWorkspaceId("string")
        .xmlContent("string")
        .description("string")
        .name("string")
        .xmlFormat("string")
        .build());
    
    workspace_policy_fragment_resource = azure.apimanagement.WorkspacePolicyFragment("workspacePolicyFragmentResource",
        api_management_workspace_id="string",
        xml_content="string",
        description="string",
        name="string",
        xml_format="string")
    
    const workspacePolicyFragmentResource = new azure.apimanagement.WorkspacePolicyFragment("workspacePolicyFragmentResource", {
        apiManagementWorkspaceId: "string",
        xmlContent: "string",
        description: "string",
        name: "string",
        xmlFormat: "string",
    });
    
    type: azure:apimanagement:WorkspacePolicyFragment
    properties:
        apiManagementWorkspaceId: string
        description: string
        name: string
        xmlContent: string
        xmlFormat: string
    

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

    ApiManagementWorkspaceId string
    Specifies the ID of the API Management Workspace. Changing this forces a new resource to be created.
    XmlContent string
    Specifies the XML content of the API Management Workspace Policy Fragment.
    Description string
    Specifies the description for the API Management Workspace Policy Fragment.
    Name string
    Specifies the name of the API Management Workspace Policy Fragment. Changing this forces a new resource to be created.
    XmlFormat string
    Specifies the XML format of the API Management Workspace Policy Fragment. Possible values are xml or rawxml. Defaults to xml.
    ApiManagementWorkspaceId string
    Specifies the ID of the API Management Workspace. Changing this forces a new resource to be created.
    XmlContent string
    Specifies the XML content of the API Management Workspace Policy Fragment.
    Description string
    Specifies the description for the API Management Workspace Policy Fragment.
    Name string
    Specifies the name of the API Management Workspace Policy Fragment. Changing this forces a new resource to be created.
    XmlFormat string
    Specifies the XML format of the API Management Workspace Policy Fragment. Possible values are xml or rawxml. Defaults to xml.
    apiManagementWorkspaceId String
    Specifies the ID of the API Management Workspace. Changing this forces a new resource to be created.
    xmlContent String
    Specifies the XML content of the API Management Workspace Policy Fragment.
    description String
    Specifies the description for the API Management Workspace Policy Fragment.
    name String
    Specifies the name of the API Management Workspace Policy Fragment. Changing this forces a new resource to be created.
    xmlFormat String
    Specifies the XML format of the API Management Workspace Policy Fragment. Possible values are xml or rawxml. Defaults to xml.
    apiManagementWorkspaceId string
    Specifies the ID of the API Management Workspace. Changing this forces a new resource to be created.
    xmlContent string
    Specifies the XML content of the API Management Workspace Policy Fragment.
    description string
    Specifies the description for the API Management Workspace Policy Fragment.
    name string
    Specifies the name of the API Management Workspace Policy Fragment. Changing this forces a new resource to be created.
    xmlFormat string
    Specifies the XML format of the API Management Workspace Policy Fragment. Possible values are xml or rawxml. Defaults to xml.
    api_management_workspace_id str
    Specifies the ID of the API Management Workspace. Changing this forces a new resource to be created.
    xml_content str
    Specifies the XML content of the API Management Workspace Policy Fragment.
    description str
    Specifies the description for the API Management Workspace Policy Fragment.
    name str
    Specifies the name of the API Management Workspace Policy Fragment. Changing this forces a new resource to be created.
    xml_format str
    Specifies the XML format of the API Management Workspace Policy Fragment. Possible values are xml or rawxml. Defaults to xml.
    apiManagementWorkspaceId String
    Specifies the ID of the API Management Workspace. Changing this forces a new resource to be created.
    xmlContent String
    Specifies the XML content of the API Management Workspace Policy Fragment.
    description String
    Specifies the description for the API Management Workspace Policy Fragment.
    name String
    Specifies the name of the API Management Workspace Policy Fragment. Changing this forces a new resource to be created.
    xmlFormat String
    Specifies the XML format of the API Management Workspace Policy Fragment. Possible values are xml or rawxml. Defaults to xml.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the WorkspacePolicyFragment 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 WorkspacePolicyFragment Resource

    Get an existing WorkspacePolicyFragment 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?: WorkspacePolicyFragmentState, opts?: CustomResourceOptions): WorkspacePolicyFragment
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            api_management_workspace_id: Optional[str] = None,
            description: Optional[str] = None,
            name: Optional[str] = None,
            xml_content: Optional[str] = None,
            xml_format: Optional[str] = None) -> WorkspacePolicyFragment
    func GetWorkspacePolicyFragment(ctx *Context, name string, id IDInput, state *WorkspacePolicyFragmentState, opts ...ResourceOption) (*WorkspacePolicyFragment, error)
    public static WorkspacePolicyFragment Get(string name, Input<string> id, WorkspacePolicyFragmentState? state, CustomResourceOptions? opts = null)
    public static WorkspacePolicyFragment get(String name, Output<String> id, WorkspacePolicyFragmentState state, CustomResourceOptions options)
    resources:  _:    type: azure:apimanagement:WorkspacePolicyFragment    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:
    ApiManagementWorkspaceId string
    Specifies the ID of the API Management Workspace. Changing this forces a new resource to be created.
    Description string
    Specifies the description for the API Management Workspace Policy Fragment.
    Name string
    Specifies the name of the API Management Workspace Policy Fragment. Changing this forces a new resource to be created.
    XmlContent string
    Specifies the XML content of the API Management Workspace Policy Fragment.
    XmlFormat string
    Specifies the XML format of the API Management Workspace Policy Fragment. Possible values are xml or rawxml. Defaults to xml.
    ApiManagementWorkspaceId string
    Specifies the ID of the API Management Workspace. Changing this forces a new resource to be created.
    Description string
    Specifies the description for the API Management Workspace Policy Fragment.
    Name string
    Specifies the name of the API Management Workspace Policy Fragment. Changing this forces a new resource to be created.
    XmlContent string
    Specifies the XML content of the API Management Workspace Policy Fragment.
    XmlFormat string
    Specifies the XML format of the API Management Workspace Policy Fragment. Possible values are xml or rawxml. Defaults to xml.
    apiManagementWorkspaceId String
    Specifies the ID of the API Management Workspace. Changing this forces a new resource to be created.
    description String
    Specifies the description for the API Management Workspace Policy Fragment.
    name String
    Specifies the name of the API Management Workspace Policy Fragment. Changing this forces a new resource to be created.
    xmlContent String
    Specifies the XML content of the API Management Workspace Policy Fragment.
    xmlFormat String
    Specifies the XML format of the API Management Workspace Policy Fragment. Possible values are xml or rawxml. Defaults to xml.
    apiManagementWorkspaceId string
    Specifies the ID of the API Management Workspace. Changing this forces a new resource to be created.
    description string
    Specifies the description for the API Management Workspace Policy Fragment.
    name string
    Specifies the name of the API Management Workspace Policy Fragment. Changing this forces a new resource to be created.
    xmlContent string
    Specifies the XML content of the API Management Workspace Policy Fragment.
    xmlFormat string
    Specifies the XML format of the API Management Workspace Policy Fragment. Possible values are xml or rawxml. Defaults to xml.
    api_management_workspace_id str
    Specifies the ID of the API Management Workspace. Changing this forces a new resource to be created.
    description str
    Specifies the description for the API Management Workspace Policy Fragment.
    name str
    Specifies the name of the API Management Workspace Policy Fragment. Changing this forces a new resource to be created.
    xml_content str
    Specifies the XML content of the API Management Workspace Policy Fragment.
    xml_format str
    Specifies the XML format of the API Management Workspace Policy Fragment. Possible values are xml or rawxml. Defaults to xml.
    apiManagementWorkspaceId String
    Specifies the ID of the API Management Workspace. Changing this forces a new resource to be created.
    description String
    Specifies the description for the API Management Workspace Policy Fragment.
    name String
    Specifies the name of the API Management Workspace Policy Fragment. Changing this forces a new resource to be created.
    xmlContent String
    Specifies the XML content of the API Management Workspace Policy Fragment.
    xmlFormat String
    Specifies the XML format of the API Management Workspace Policy Fragment. Possible values are xml or rawxml. Defaults to xml.

    Import

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

    $ pulumi import azure:apimanagement/workspacePolicyFragment:WorkspacePolicyFragment example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.ApiManagement/service/instance1/workspaces/workspace1/policyFragments/policyFragment1
    

    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.

    Azure v6.30.0 published on Thursday, Nov 20, 2025 by Pulumi
      Meet Neo: Your AI Platform Teammate