question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[QUERY] Delay after setting the response/mock in ApiManagement

See original GitHub issue

Library name and version

Microsoft.Azure.Management.ApiManagement

Query/Question

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 successful 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 this behavior attended? Should the method IApiOperationPolicyOperations.CreateOrUpdateWithHttpMessagesAsync not return successful first when the endpoint is returning the updated value?

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

Environment

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
jsquirecommented, Mar 11, 2022

Thank you for your feedback. Tagging and routing to the team member best able to assist.

0reactions
Yao725commented, Oct 31, 2022

Will close this issue, feel free to open new issues if you have problems with SDK, thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

api - Azure APIM sleep or delay policy
Following policy sets a variable after 500 milliseconds. <set-variable name="delayExpression" value="@{ var curr = System.DateTime.UtcNow.
Read more >
Azure API Management policy reference
Reference index for all Azure API Management policies and settings. Policies allow the API publisher to change API behavior through ...
Read more >
Tutorial: Mock API responses - Azure
In this tutorial, you use API Management to set a policy on an API. The policy returns a mocked response even if the...
Read more >
Mockserver dynamic response. SocketUtils
Hello I have set up a mock server, with a very simple example JSON response: { "client_ref": "zzzzzzzz" } This is working fine....
Read more >
Setting up mock servers
To test using a mock server, do the following: In Postman, send a request to any API. Your request must be saved to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found