I know you can track normal operations using the standard API: https://learn.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-async-operations
However I was wondering if there was a known way to utilize the Fluent Azure Management Libraries to track long async operations such as VM operations etc. For example the VM restart method is a void Task which does not return an operation-id for tracking.
async Task IVirtualMachineScaleSetVM.RestartAsync(CancellationToken cancellationToken)
{
await this.RestartAsync(cancellationToken);
}
Cheers!
AFAIK, it seems that it's hard to trace VM restart status which does not return an operationId.
Logging in the fluent Azure management libraries for .NET leverages the underlying AutoRest service client tracing.
Create a class that implements
Microsoft.Rest.IServiceClientTracingInterceptor
. This class will be responsible for intercepting log messages and passing them to whatever logging mechanism you're using.Before creating the
Microsoft.Azure.Management.Fluent.Azure
object, initialize theIServiceClientTracingInterceptor
you created above by callingServiceClientTracing.AddTracingInterceptor()
and setServiceClientTracing.IsEnabled
to true. When you create the Azure object, include the.WithDelegatingHandler()
and.WithLogLevel()
methods to wire up the client to AutoRest's service client tracing.For more details, you could refer to this article.