In my company we have identical environments for our application: IT, ST, AT and PRD. We use Terraform to deploy our Azure resources, and are currently attempting to set up an API management solution which passes calls to a Function App backend.
The set up is fairly simple, we have a series of APIs declared, and in their backend policies we declare this bit:
<policies>
<inbound>
<set-backend-service id="apim-generated-policy" backend-id="function-at" />
</inbound>
</policies>
In IT/ST we have been able to set this successfully. However, when our Terraform pipeline runs on AT, it always fails to update our APIs with this error:
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"}]
When attempting to add this line manually in the Azure UI, the same error occurs:
Error in element 'set-backend-service' on line 3, column 10:
Backend with id 'function-at' could not be found.
I cannot understand why this refuses to work. The function exists and is in the same resource group as the API manager. My best guess is that someone has changed a setting manually in the other environments that is not reflected in the Terraform code. How can I go about troubleshooting this issue? I did a side-by-side comparison of the ST and AT APIs/functions and did not find any obvious differences.
Thanks in advance for any help!
I faced the same problem during Terraform deployment and for me solution was to add api_management_backend and in policy I was able reference to it.