Entity with specified identifier not found when applying policy on API operation with Bicep in Azure API Management

Rob Joosen 86 Reputation points
2023-06-02T07:10:14.9133333+00:00

I would like to apply an outbound policy to some of the operations of my API. I use a Bicep file to accomplish that but I get the following error:


"statusMessage": {
        "status": "Failed",
        "error": {
          "code": "ValidationError",
          "message": "Entity with specified identifier not found"
        }
      }



This is the snippet for the policy:


resource relationApiSym 'Microsoft.ApiManagement/service/apis@2022-08-01' existing = {
  name: relationsApi.name
  parent: apiManagementInstance
  resource operationRegisterId 'operations@2022-08-01' existing = {
    name : 'post-registerrelation-id'
    resource policyId 'policies@2022-08-01' = {
      name: 'policy'
      properties: {
        format: 'xml'
        value:'<policies>\r\n<inbound>\r\n<base />\r\n</inbound>\r\n<backend>\r\n<base />\r\n</backend>\r\n<outbound>\r\n<base />\r\n<choose>\r\n<when condition="@(context.Response.StatusCode == 200)">\r\n<set-body>@{var response = context.Response.Body.As&lt;JObject&gt;();foreach (var key in new [] {"RelatieId"}) {response.Property (key).Remove ();}return response.ToString();}\r\n</set-body>\r\n</when>\r\n</choose>\r\n</outbound>\r\n<on-error>\r\n<base />\r\n</on-error>\r\n</policies>'      
      }
    }
  }
}



I see that the operation exisits with the name 'post-register-relation-id' but when i check the target url from the deploymentlog, I notice that there are no policies (jet)

User's image

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
1,944 questions
Azure
Azure
A cloud computing platform and infrastructure for building, deploying and managing applications and services through a worldwide network of Microsoft-managed datacenters.
1,072 questions
{count} votes

Accepted answer
  1. VasimTamboli 4,785 Reputation points
    2023-06-04T13:20:42.32+00:00

    Here are a few suggestions to troubleshoot and resolve the issue:

    Verify the operation name: Double-check that the operation name 'post-register-relation-id' is correct and matches the actual operation name in Azure API Management. Ensure there are no typos or differences in casing.

    Check the API path: Confirm that the API path in your Bicep file matches the API path in Azure API Management. The API path should be unique and correspond to the API you are working with.

    Validate the policy name: Ensure that the policy name 'policy' is correct and matches the actual policy name in Azure API Management. Again, check for typos or casing differences.

    Confirm deployment: After deploying the Bicep file, verify that the deployment was successful and there were no errors. Check the deployment logs and ensure that all resources, including operations and policies, were deployed as expected.

    Validate the API Management instance: Ensure that you are targeting the correct API Management instance and the instance is in the expected state. Check the API Management portal or use the Azure CLI or PowerShell to retrieve information about the API Management instance.

    If you have verified all the above steps and the issue persists, it might be helpful to provide additional details such as the complete Bicep file and any relevant error messages from the deployment logs. This would allow for a more in-depth analysis of the problem and provide more specific guidance to resolve it.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful