/// <summary> Captures the specified resource group as a template. </summary> /// <param name="parameters"> Parameters for exporting the template. </param> /// <param name="waitForCompletion"> Waits for the completion of the long running operations. </param> /// <param name="cancellationToken"> The cancellation token to use. </param> public virtual async Task <ResourceGroupExportTemplateOperation> ExportTemplateAsync(ExportTemplateRequest parameters, bool waitForCompletion = true, CancellationToken cancellationToken = default) { if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } using var scope = _clientDiagnostics.CreateScope("ResourceGroup.ExportTemplate"); scope.Start(); try { var originalResponse = await _restClient.ExportTemplateAsync(Id.Name, parameters, cancellationToken).ConfigureAwait(false); var operation = new ResourceGroupExportTemplateOperation(_clientDiagnostics, Pipeline, _restClient.CreateExportTemplateRequest(Id.Name, parameters).Request, originalResponse); if (waitForCompletion) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual ResourceGroupExportTemplateOperation ExportTemplate(bool waitForCompletion, ExportTemplateRequest parameters, CancellationToken cancellationToken = default) { if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } using var scope = _resourceGroupClientDiagnostics.CreateScope("ResourceGroup.ExportTemplate"); scope.Start(); try { var response = _resourceGroupRestClient.ExportTemplate(Id.SubscriptionId, Id.ResourceGroupName, parameters, cancellationToken); var operation = new ResourceGroupExportTemplateOperation(_resourceGroupClientDiagnostics, Pipeline, _resourceGroupRestClient.CreateExportTemplateRequest(Id.SubscriptionId, Id.ResourceGroupName, parameters).Request, response); if (waitForCompletion) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }