Azure / azure-sdk-for-net

This repository is for active development of the Azure SDK for .NET. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/dotnet/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-net.
MIT License
5.37k stars 4.78k forks source link

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

Closed schw3de closed 1 year ago

schw3de commented 2 years ago

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

azure-sdk commented 2 years ago

Label prediction was below confidence level 0.6 for Model:ServiceLabels: 'Storage:0.16514263,Service Bus:0.13891442,Cognitive Services:0.07000429' Label prediction was below confidence level 0.6 for Model:CategoryLabels: 'Client:0.5805451,Mgmt:0.40426606,Service:0.0136808455'

jsquire commented 2 years ago

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

ArthurMa1978 commented 2 years ago

@Yao725 please help to check if this is happened on sdk side or a service delay

schw3de commented 2 years ago

@ArthurMa1978 Thank you for addressing my issue.

I checked this behavior on https://portal.azure.com and could also reproduce this issue. If I set the response in the Design tab and afterwards quickly go to the Test tab it do not always show directly the new response. image image In this case I have to execute test again to get the correct value.

ghost commented 2 years ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @miaojiang.

Issue Details
### 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: ``` text/xml content ``` 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_
Author: schw3de
Assignees: Yao725
Labels: `API Management`, `Service Attention`, `Mgmt`, `customer-reported`, `question`, `needs-team-attention`
Milestone: -
Yao725 commented 2 years ago

Hi @schw3de, per your description, I think it is a service-related issue because our SDK worked as expected but there is a delay between setup and status update. I tagged this issue with service attention and hope we can get some help from the service team.

schw3de commented 2 years ago

@Yao725 Thanks for the update!

Yao725 commented 1 year ago

Hi @schw3de, sorry I haven't updated this issue for a long time, it seems the service team will not respond here. Do you resolve this issue? If not, maybe you can open an ICM to get more assistances.

schw3de commented 1 year ago

Hi @Yao725,

Thanks for your reply. No, the issue could not be fixed. Sorry to hear that the service team will not respond. We will not continue to investigate the issue further with an ICM issue, because of resources.

Too bad the issue can not be resolved, but I guess there are just not enough people interested in this topic.

I wish you all the best!

Yao725 commented 1 year ago

Thanks for your reply. For your issue, it's hard for us to do something in SDK side to fix it, really sorry for that.

Yao725 commented 1 year ago

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