Bearbeiten

Freigeben über


Set-AzApiManagementPolicy

Sets the specified scope policy for API Management.

Syntax

Set-AzApiManagementPolicy
   -Context <PsApiManagementContext>
   [-Format <String>]
   [-Policy <String>]
   [-PolicyFilePath <String>]
   [-PolicyUrl <String>]
   [-PassThru]
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]
Set-AzApiManagementPolicy
   -Context <PsApiManagementContext>
   [-Format <String>]
   -ProductId <String>
   [-Policy <String>]
   [-PolicyFilePath <String>]
   [-PolicyUrl <String>]
   [-PassThru]
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]
Set-AzApiManagementPolicy
   -Context <PsApiManagementContext>
   [-Format <String>]
   -ApiId <String>
   [-ApiRevision <String>]
   [-Policy <String>]
   [-PolicyFilePath <String>]
   [-PolicyUrl <String>]
   [-PassThru]
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]
Set-AzApiManagementPolicy
   -Context <PsApiManagementContext>
   [-Format <String>]
   -ApiId <String>
   [-ApiRevision <String>]
   -OperationId <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.

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-ApiRevision

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

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-Context

Specifies the instance of PsApiManagementContext.

Type:PsApiManagementContext
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-DefaultProfile

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

Type:IAzureContextContainer
Aliases:AzContext, AzureRmContext, AzureCredential
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters: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.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:True
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
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-PassThru

passthru

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:True
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
Required:False
Accept pipeline input:True
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
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-PolicyUrl

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

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:True
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
Required:True
Accept pipeline input:True
Accept wildcard characters:False

Inputs

PsApiManagementContext

String

SwitchParameter

Outputs

Boolean