Set-AzureRmApiManagementPolicy

Sets the specified scope policy for API Management.

Syntax

Set-AzureRmApiManagementPolicy
   -Context <PsApiManagementContext>
   [-Format <String>]
   [-Policy <String>]
   [-PolicyFilePath <String>]
   [-PassThru]
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]
Set-AzureRmApiManagementPolicy
   -Context <PsApiManagementContext>
   [-Format <String>]
   -ProductId <String>
   [-Policy <String>]
   [-PolicyFilePath <String>]
   [-PassThru]
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]
Set-AzureRmApiManagementPolicy
   -Context <PsApiManagementContext>
   [-Format <String>]
   -ApiId <String>
   [-Policy <String>]
   [-PolicyFilePath <String>]
   [-PassThru]
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]
Set-AzureRmApiManagementPolicy
   -Context <PsApiManagementContext>
   [-Format <String>]
   -ApiId <String>
   -OperationId <String>
   [-Policy <String>]
   [-PolicyFilePath <String>]
   [-PassThru]
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]

Description

The Set-AzureRmApiManagementPolicy cmdlet sets the specified scope policy for API Management.

Examples

Example 1: Set the tenant level policy

PS C:\>$apimContext = New-AzureRmApiManagementContext -ResourceGroupName "Api-Default-WestUS" -ServiceName "contoso"
PS C:\>Set-AzureRmApiManagementPolicy -Context $apimContext -PolicyFilePath "C:\contoso\policies\tenantpolicy.xml"

This command sets the tenant level policy from a file named tenantpolicy.xml.

Example 2: Set a product-scope policy

PS C:\>$apimContext = New-AzureRmApiManagementContext -ResourceGroupName "Api-Default-WestUS" -ServiceName "contoso"
PS C:\>Set-AzureRmApiManagementPolicy -Context $apimContext -ProductId "0123456789" -Policy $PolicyString

This command sets the product-scope policy for API Management.

Example 3: Set API-scope policy

PS C:\>$apimContext = New-AzureRmApiManagementContext -ResourceGroupName "Api-Default-WestUS" -ServiceName "contoso"
PS C:\>Get-AzureRmApiManagementPolicy -Context $apimContext -ApiId "9876543210" -Policy $PolicyString

This command sets API-scope policy for API Management.

Example 4: Set operation-scope policy

PS C:\>$apimContext = New-AzureRmApiManagementContext -ResourceGroupName "Api-Default-WestUS" -ServiceName "contoso"
PS C:\>Set-AzureRmApiManagementPolicy -Context $apimContext -ApiId "9876543210" -OperationId "777" -Policy $PolicyString

This command sets operation-scope policy for API Management.

Required Parameters

-ApiId

Specifies the identifier of the existing API. If you specify this parameter, the cmdlet sets the API-scope policy.

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-Context

Specifies the instance of PsApiManagementContext.

Type:Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models.PsApiManagementContext
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-OperationId

Specifies the identifier of the existing operation. If specified with ApiId will set operation-scope policy. This parameters is required.

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-ProductId

Specifies the identifier of the existing product. If this parameter is specified, the cmdlet sets the product-scope policy.

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False

Optional Parameters

-DefaultProfile

The credentials, account, tenant, and subscription used for communication with azure.

Type:Microsoft.Azure.Commands.Common.Authentication.Abstractions.IAzureContextContainer
Aliases:AzureRmContext, AzureCredential
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Format

Specifies the format of the policy. The default value is "application/vnd.ms-azure-apim.policy+xml".

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-PassThru

passthru

Type:System.Management.Automation.SwitchParameter
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-Policy

Specifies the policy document as a string. This parameter is required if the -PolicyFilePath is not specified.

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-PolicyFilePath

Specifies the policy document file path. This parameter is required if the Policy parameter is not specified.

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False

Outputs

bool