public async virtual Task <AppServicePlanCreateOrUpdateOperation> CreateOrUpdateAsync(string name, AppServicePlanData appServicePlan, bool waitForCompletion = true, CancellationToken cancellationToken = default) { if (name == null) { throw new ArgumentNullException(nameof(name)); } if (appServicePlan == null) { throw new ArgumentNullException(nameof(appServicePlan)); } using var scope = _clientDiagnostics.CreateScope("AppServicePlanCollection.CreateOrUpdate"); scope.Start(); try { var response = await _appServicePlansRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, name, appServicePlan, cancellationToken).ConfigureAwait(false); var operation = new AppServicePlanCreateOrUpdateOperation(Parent, _clientDiagnostics, Pipeline, _appServicePlansRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, name, appServicePlan).Request, response); if (waitForCompletion) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual async Task <ArmOperation <AppServicePlanResource> > CreateOrUpdateAsync(WaitUntil waitUntil, string name, AppServicePlanData data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(name, nameof(name)); Argument.AssertNotNull(data, nameof(data)); using var scope = _appServicePlanClientDiagnostics.CreateScope("AppServicePlanCollection.CreateOrUpdate"); scope.Start(); try { var response = await _appServicePlanRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, name, data, cancellationToken).ConfigureAwait(false); var operation = new AppServiceArmOperation <AppServicePlanResource>(new AppServicePlanOperationSource(Client), _appServicePlanClientDiagnostics, Pipeline, _appServicePlanRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, name, data).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }