如何在 XML 策略文件中将 Azure API 后端设置为 Azure 资源?

How to set Azure API Backend to Azure resource in XML Policy file?

在 Azure APIM 门户中,您可以将后端设置为 Azure 资源,例如逻辑应用程序,但我们如何使用 XML 策略文件以编程方式进行设置?

干杯,

Backend

使用 set-backend-service 策略将传入请求重定向到与该操作的 API 设置中指定的后端不同的后端。此策略将传入请求的后端服务基础 URL 更改为策略中指定的基础。

我使用的是“Web 服务 URL”设置,但每次导入新的 swagger.json 文件时,该值都会被覆盖。

使用策略解决了它:

   <policies>
        <inbound>
            <base />
            <set-backend-service base-url="https://api-mysite.azurewebsites.net" />
        </inbound>
        <backend>
            <base />
        </backend>
        <outbound>
            <base />
        </outbound>
        <on-error>
            <base />
        </on-error>
    </policies>

非常感谢@MKaz 带领我朝着正确的方向前进:)