0

I am trying to figure out how to monitor the progress of requests made using windows azure management library so we can display to the customer. We are doing it Async inside an Akka.Net actor.

For example I am creating a database like

 SqlManagementClient.Databases.CreateAsync(Server, databaseCreateParameters);

Basically I get a result of DatabaseCreateResponse and I can check if it succeeded. Is there anyway I can monitor the progress. I assumed I could get a request id and then query the status. How do I get the request id? How do I query?

I just want to show progress like on Azure portal - ideally being able to give an estimate of how long to complete.

Alternatively am I just supposed to fake the progress report and assume if no failure its in progress without issue?

This will apply to many items we need to create like websites, DNS, storage etc.

GraemeMiller
  • 11,973
  • 8
  • 57
  • 111

1 Answers1

1

The DatabaseCreateResponse has a RequestId property hanging off of it that you can use to get the operation status. To query the status of the operation, you would use the Get Operation Status Rest API.

You will essentially have to call this API in a polling manner to get the status, which will be either Failed, InProgress, or Succeeded. The link above shows an example of how you might structure a call to this in polling code. You won't be able to give an accurate estimate of how long the operation will take to complete though. So, yes, until you get a respone other than InProgress then you would assume no failures.

Since you're using the management libraries, your code may look something like this to get the RequestId and call GetOperationStatusAsync to check the status.

var dbCreateRequestId = dbCreateResponse.RequestId;
var opStatus = await mgmtClient.GetOperationStatusAsync(dbCreateRequestId, cancellationToken);

switch (opStatus.Status)
{
    case OperationStatus.Failed:
        // Report failed
        break;

    case OperationStatus.InProgress:
        // Report in progress
        break;

    case OperationStatus.Succeeded:
        // Report succeeded
        break;
}

Also, this method is what you would use to check the status for the other items you mentioned. Just get the RequestId for the operations on those items and invoke this same method.

Rick Rainey
  • 11,096
  • 4
  • 30
  • 48
  • That is great. I suspected something like that as I had seen it via the api. My issue now is getting the RequestId. If a do a CreateAsync on the database the DatabaseCreateResponse result I get back takes 5-10 seconds and comes back as 201 Created. So it has already succeeded. I can't seem to find away to get the requestId before the result is returned. When I do a strorage account create that takes far longer but does the same thing – GraemeMiller Sep 18 '15 at 21:21