使用管道应用API策略



大家好!

我正在尝试将外部api部署到APIM,但是我不确定如何部署我创建的策略xml文件。

我想也许这可以使用CLI,但是我找不到任何东西。

有人知道吗?

您还不能通过CLI完成此操作。您可以使用powershell脚本代替。这里我从内联xml中获取,但你可以从你的repo中对xml做类似的事情。

- task: AzurePowerShell@5
displayName: "Add API policy in APIM"
inputs:
azureSubscription: 'YourSubscription'
ScriptType: 'InlineScript'
Inline: |
Install-Module Az.ApiManagement -Scope CurrentUser -Force
Import-Module Az.ApiManagement -Force
$PolicyString = "<policies>
<inbound>
<base />
<authentication-certificate thumbprint=`"$(certificateThumbprint)`" />
</inbound>
<backend>
<base />
</backend>
<outbound>
<base />
</outbound>
<on-error>
<base />
</on-error>
</policies>"
$apimContext = New-AzApiManagementContext -ResourceGroupName $(apimResourceGroup) -ServiceName $(apimPortal)
Set-AzApiManagementPolicy -Context $apimContext -ApiId $(apimRestApiId) -Policy $PolicyString
azurePowerShellVersion: 'LatestVersion'

最新更新