< Back

Set-AzureRmApiManagementPolicy

Tue Jan 29, 2019 9:30 pm

NAME Set-AzureRmApiManagementPolicy



SYNOPSIS

Sets the specified scope policy for API Management.





SYNTAX

Set-AzureRmApiManagementPolicy -ApiId <String> -Context <PsApiManagementContext> [-DefaultProfile <IAzureContextContainer>] [-Format <String>]

[-PassThru] [-Policy <String>] [-PolicyFilePath <String>] [<CommonParameters>]



Set-AzureRmApiManagementPolicy -ApiId <String> -Context <PsApiManagementContext> [-DefaultProfile <IAzureContextContainer>] [-Format <String>]

-OperationId <String> [-PassThru] [-Policy <String>] [-PolicyFilePath <String>] [<CommonParameters>]



Set-AzureRmApiManagementPolicy -Context <PsApiManagementContext> [-DefaultProfile <IAzureContextContainer>] [-Format <String>] [-PassThru]

[-Policy <String>] [-PolicyFilePath <String>] -ProductId <String> [<CommonParameters>]





DESCRIPTION

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





PARAMETERS

-ApiId <String>

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



Required? true

Position? named

Default value None

Accept pipeline input? True (ByPropertyName)

Accept wildcard characters? false



-Context <PsApiManagementContext>

Specifies the instance of PsApiManagementContext .



Required? true

Position? named

Default value None

Accept pipeline input? True (ByPropertyName)

Accept wildcard characters? false



-DefaultProfile <IAzureContextContainer>

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



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-Format <String>

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



Required? false

Position? named

Default value None

Accept pipeline input? True (ByPropertyName)

Accept wildcard characters? false



-OperationId <String>

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



Required? true

Position? named

Default value None

Accept pipeline input? True (ByPropertyName)

Accept wildcard characters? false



-PassThru [<SwitchParameter>]

passthru



Required? false

Position? named

Default value False

Accept pipeline input? True (ByPropertyName)

Accept wildcard characters? false



-Policy <String>

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



Required? false

Position? named

Default value None

Accept pipeline input? True (ByPropertyName)

Accept wildcard characters? false



-PolicyFilePath <String>

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



Required? false

Position? named

Default value None

Accept pipeline input? True (ByPropertyName)

Accept wildcard characters? false



-ProductId <String>

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



Required? true

Position? named

Default value None

Accept pipeline input? True (ByPropertyName)

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).



INPUTS

None

This cmdlet does not accept any input.





OUTPUTS

bool







NOTES









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.







RELATED LINKS

Online Version: https://docs.microsoft.com/en-us/powers ... mentpolicy

Get-AzureRmApiManagementPolicy

Remove-AzureRmApiManagementPolicy