Edit

Share via


Set-AzApiManagementPolicy

Sets the specified scope policy for API Management.

Syntax

SetTenantLevel (Default)

Set-AzApiManagementPolicy
    -Context <PsApiManagementContext>
    [-Format <String>]
    [-Policy <String>]
    [-PolicyFilePath <String>]
    [-PolicyUrl <String>]
    [-PassThru]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

SetProductLevel

Set-AzApiManagementPolicy
    -Context <PsApiManagementContext>
    -ProductId <String>
    [-Format <String>]
    [-Policy <String>]
    [-PolicyFilePath <String>]
    [-PolicyUrl <String>]
    [-PassThru]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

SetApiLevel

Set-AzApiManagementPolicy
    -Context <PsApiManagementContext>
    -ApiId <String>
    [-Format <String>]
    [-ApiRevision <String>]
    [-Policy <String>]
    [-PolicyFilePath <String>]
    [-PolicyUrl <String>]
    [-PassThru]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

SetOperationLevel

Set-AzApiManagementPolicy
    -Context <PsApiManagementContext>
    -ApiId <String>
    -OperationId <String>
    [-Format <String>]
    [-ApiRevision <String>]
    [-Policy <String>]
    [-PolicyFilePath <String>]
    [-PolicyUrl <String>]
    [-PassThru]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

Description

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

Examples

Example 1: Set the tenant level policy

$apimContext = New-AzApiManagementContext -ResourceGroupName "Api-Default-WestUS" -ServiceName "contoso"
Set-AzApiManagementPolicy -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

$apimContext = New-AzApiManagementContext -ResourceGroupName "Api-Default-WestUS" -ServiceName "contoso"
Set-AzApiManagementPolicy -Context $apimContext -ProductId "0123456789" -Policy $PolicyString

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

Example 3: Set API-scope policy

$apimContext = New-AzApiManagementContext -ResourceGroupName "Api-Default-WestUS" -ServiceName "contoso"
Set-AzApiManagementPolicy -Context $apimContext -ApiId "9876543210" -Policy $PolicyString

This command sets API-scope policy for API Management.

Example 4: Set operation-scope policy

$apimContext = New-AzApiManagementContext -ResourceGroupName "Api-Default-WestUS" -ServiceName "contoso"
Set-AzApiManagementPolicy -Context $apimContext -ApiId "9876543210" -OperationId "777" -Policy $PolicyString

This command sets operation-scope policy for API Management.

Parameters

-ApiId

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

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

SetApiLevel
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
SetOperationLevel
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-ApiRevision

Identifier of API Revision. This parameter is optional. If not specified, the policy will be updated in the currently active api revision.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

SetApiLevel
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
SetOperationLevel
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-Context

Specifies the instance of PsApiManagementContext.

Parameter properties

Type:PsApiManagementContext
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:True
Value from remaining arguments:False

-DefaultProfile

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

Parameter properties

Type:IAzureContextContainer
Default value:None
Supports wildcards:False
DontShow:False
Aliases:AzContext, AzureRmContext, AzureCredential

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Format

Specifies the format of the policy. When using application/vnd.ms-azure-apim.policy+xml, expressions contained within the policy must be XML-escaped. When using application/vnd.ms-azure-apim.policy.raw+xml it is not necessary for the policy to be XML-escaped. The default value is application/vnd.ms-azure-apim.policy+xml. This parameter is optional.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-OperationId

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

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

SetOperationLevel
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-PassThru

passthru

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-Policy

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

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-PolicyFilePath

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

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-PolicyUrl

The Url where the Policy document is hosted. This parameter is required if -Policy or -PolicyFilePath is not specified.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-ProductId

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

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

SetProductLevel
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Inputs

PsApiManagementContext

String

SwitchParameter

Outputs

Boolean