So basically what I want to do - is to get the status of an operation.
So for example this line of code creates a database from a restore:
ArmOperation<SqlDatabaseResource> operation = await sqlServerResource.GetSqlDatabases()
.CreateOrUpdateAsync(WaitUntil.Started, newDatabaseName, backupData);
Now on the same method containing the above code I can call operation.HasCompleted() which is all good.. But what I initially want is a new method that gets an operation by id or something and then checking if it has completed - for example:
- I will create an get endpoint with an ID parameter and when calling that method it will try to get the operation with that id and then check if it has completed (I hope it makes sense) If not let me know and I can try to formulate it differently.
Tried to search through all docs and sample codes but I was not able to find anything showcasing how you can retrieve long running operations and query them..
AFAIK the operations themselves are direct REST API calls and ones that result in a
202 Acceptedresponse, are to be polled to get the status of the operation.Unlike resource group deployments, which are resources themselves and can be queried, these operations are just part of the raw HTTP requests being made.
That being said, you essentially have two options here
Operation.GetRawResponseto get the raw 202 response details and store theLocationheader (which is what the operation object uses internally to poll) for future reference