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

[BUG] Any Management SDK call stuck sometimes when using WaitUntil.Completed and never returns back. #42040

Closed vikramdadwal closed 5 months ago

vikramdadwal commented 8 months ago

Library name and version

Azure.ResourceManager.ServiceBus, Azure.ResourceManager.Compute

Describe the bug

We are observing that sometimes the call to Azure with CreateUpdate methods using the WaitUntil enum as WaitUntil.Completed hangs and never returns back with the result, this is causing our services to block the resources for the infinite time.

Following is just one example when SDK with WaitUntil.Completed:

ServiceBusTopicResource serviceBusTopic = serviceBusTopicCollection.CreateOrUpdate(WaitUntil.Completed, dynamicTopicName, topicData).Value;

Expected behavior

The SDK call should return with either a Success or a Failure response.

Actual behavior

SDK call hangs and never returns.

Reproduction Steps

Following is just one example when SDK with WaitUntil.Completed:

ServiceBusTopicResource serviceBusTopic = serviceBusTopicCollection.CreateOrUpdate(WaitUntil.Completed, dynamicTopicName, topicData).Value;

Environment

.NET runtime running on Azure Container Instances

jsquire commented 8 months ago

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

mcgallan commented 6 months ago

Hi @vikramdadwal , regarding the issue you mentioned, I did not encounter the problem you mentioned during the reproduction process. Obviously, such a situation is not a necessary event, so if you can provide more information, such as error messages, specific implementation code, etc., it will help us better understand the situation and solve the problem better.

github-actions[bot] commented 6 months ago

Hi @vikramdadwal. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue.

github-actions[bot] commented 6 months ago

Hi @vikramdadwal, we're sending this friendly reminder because we haven't heard back from you in 7 days. We need more information about this issue to help address it. Please be sure to give us your input. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!

melina5656 commented 6 months ago

Hi @vikramdadwal , you should use asynchronous methods and the await keyword.

await is a mechanism for asynchronously waiting for a task to complete, while WaitUntil.Completed is a parameter that indicates the level of completion to wait for in an asynchronous method. Used together, they allow for waiting for time-consuming operations to complete without blocking the thread.

The specific format is as follows :

 //Create a serviceBus
 var serviceBusCollection = resourceGroup.GetServiceBusNamespaces();
 var namespaceName = "serviceBus";
 var serviceBusData = new ServiceBusNamespaceData(AzureLocation.EastUS)
 {
     Sku = new ServiceBusSku(ServiceBusSkuName.Premium)
     {
         Tier = ServiceBusSkuTier.Premium
     }
 };
 var serviceBus = (await serviceBusCollection.CreateOrUpdateAsync(WaitUntil.Completed, namespaceName, serviceBusData)).Value;

 //Create a serviceBusTopic
 var serviceBusTopicCollection = serviceBus.GetServiceBusTopics();
 var topicName = "topic";
 var topicData = new ServiceBusTopicData();
 var serviceBusTopic = (await serviceBusTopicCollection.CreateOrUpdateAsync(WaitUntil.Completed, topicName, topicData)).Value;

Thank you for your feedback.

github-actions[bot] commented 6 months ago

Hi @vikramdadwal. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text "/unresolve" to remove the "issue-addressed" label and continue the conversation.

github-actions[bot] commented 5 months ago

Hi @vikramdadwal, since you haven’t asked that we /unresolve the issue, we’ll close this out. If you believe further discussion is needed, please add a comment /unresolve to reopen the issue.