在我的公司,我们的应用程序具有相同的环境:IT、ST、AT 和 PRD。我们使用 Terraform 来部署我们的 Azure 资源,目前正在尝试设置一个 API 管理解决方案,它将调用传递给一个 Function App 后端。
设置相当简单,我们声明了一系列 API,在它们的后端策略中我们声明了这一点:
<policies>
<inbound>
<set-backend-service id="apim-generated-policy" backend-id="function-at" />
</inbound>
</policies>
在 IT/ST 中,我们已经能够成功地设置它。但是,当我们的 Terraform 管道在 AT 上运行时,它总是无法更新我们的 API,并出现以下错误:
Error: Error creating or updating API Operation Policy (Resource Group "rg-at" / API Management Service "api-at" / API "call" / Operation "get-call"):
apimanagement.APIOperationPolicyClient#CreateOrUpdate: Failure responding to request:
StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="ValidationError" Message="One or more fields contain incorrect values:" Details=[{"code":"ValidationError","message":"Error in element 'set-backend-service' on line 3, column 6: Backend with id 'function-at' could not be found.","target":"set-backend-service"}]
尝试在 Azure UI 中手动添加此行时,会发生相同的错误:
Error in element 'set-backend-service' on line 3, column 10:
Backend with id 'function-at' could not be found.
我不明白为什么这拒绝工作。该函数存在并且与 API 管理器位于同一资源组中。我最好的猜测是有人在其他环境中手动更改了未反映在 Terraform 代码中的设置。我该如何解决这个问题?我对 ST 和 AT API/函数进行了并排比较,没有发现任何明显的差异。
提前感谢您的帮助!