'Delay after setting the response in ApiManagement

We use the Api Management to mock endpoints. We set mock endpoints during tests and depending on which test is running, we change the mock.

With help of PolicyContract we set our mocked content:

<policies>
    <inbound>
        <base />
        <return-response>
            <set-status code="200" />
            <set-header name="Content-Type" exists-action="override">
                <value>text/xml</value>
            </set-header>
            <set-body template="liquid">
               <mockedcontent>content</mockedcontent>
            </set-body>
        </return-response>
    </inbound>
    <backend>
        <base />
    </backend>
    <outbound>
        <base />
    </outbound>
    <on-error>
        <base />
    </on-error>
</policies>

In code we use the nuget package Microsoft.Azure.Management.ApiManagement to set the PolicyContract. When we call the IApiOperationPolicyOperations.CreateOrUpdateWithHttpMessagesAsync the operation is succesful and afterwards IApiOperationPolicyOperations.GetWithHttpMessagesAsync returns new updated PolicyContract. But here comes the problem. The mocked endpoint itself doesn't return the set mocked content directly. There is a delay before the endpoint is being updated. Currently we have code to check if the endpoint is updated. But this is creating other problems in our architecture.

Is there another way how to detect if the mock endpoint has really updated?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source