public virtual ConnectionMonitorCreateOrUpdateOperation CreateOrUpdate(bool waitForCompletion, string connectionMonitorName, ConnectionMonitorInput parameters, string migrate = null, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(connectionMonitorName, nameof(connectionMonitorName)); if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } using var scope = _connectionMonitorClientDiagnostics.CreateScope("ConnectionMonitorCollection.CreateOrUpdate"); scope.Start(); try { var response = _connectionMonitorRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, connectionMonitorName, parameters, migrate, cancellationToken); var operation = new ConnectionMonitorCreateOrUpdateOperation(ArmClient, _connectionMonitorClientDiagnostics, Pipeline, _connectionMonitorRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, connectionMonitorName, parameters, migrate).Request, response); if (waitForCompletion) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual ArmOperation <ConnectionMonitor> CreateOrUpdate(WaitUntil waitUntil, string connectionMonitorName, ConnectionMonitorInput parameters, string migrate = null, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(connectionMonitorName, nameof(connectionMonitorName)); Argument.AssertNotNull(parameters, nameof(parameters)); using var scope = _connectionMonitorClientDiagnostics.CreateScope("ConnectionMonitorCollection.CreateOrUpdate"); scope.Start(); try { var response = _connectionMonitorRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, connectionMonitorName, parameters, migrate, cancellationToken); var operation = new NetworkArmOperation <ConnectionMonitor>(new ConnectionMonitorOperationSource(Client), _connectionMonitorClientDiagnostics, Pipeline, _connectionMonitorRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, connectionMonitorName, parameters, migrate).Request, response, OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }