Reputation: 12253
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.
Upvotes: 0
Views: 364
Reputation: 11246
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.
Upvotes: 1