public virtual async Task <ArmOperation <JobAgentResource> > CreateOrUpdateAsync(WaitUntil waitUntil, string jobAgentName, JobAgentData data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(jobAgentName, nameof(jobAgentName)); Argument.AssertNotNull(data, nameof(data)); using var scope = _jobAgentClientDiagnostics.CreateScope("JobAgentCollection.CreateOrUpdate"); scope.Start(); try { var response = await _jobAgentRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, jobAgentName, data, cancellationToken).ConfigureAwait(false); var operation = new SqlArmOperation <JobAgentResource>(new JobAgentOperationSource(Client), _jobAgentClientDiagnostics, Pipeline, _jobAgentRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, jobAgentName, data).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual JobAgentCreateOrUpdateOperation CreateOrUpdate(string jobAgentName, JobAgentData parameters, bool waitForCompletion = true, CancellationToken cancellationToken = default) { if (jobAgentName == null) { throw new ArgumentNullException(nameof(jobAgentName)); } if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } using var scope = _clientDiagnostics.CreateScope("JobAgentCollection.CreateOrUpdate"); scope.Start(); try { var response = _jobAgentsRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, jobAgentName, parameters, cancellationToken); var operation = new JobAgentCreateOrUpdateOperation(Parent, _clientDiagnostics, Pipeline, _jobAgentsRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, jobAgentName, parameters).Request, response); if (waitForCompletion) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }