/// <summary> /// The operation to create or update a resource group. Please note some properties can be set only during creation. /// </summary> /// <param name="name"> The name of the resource group. </param> /// <param name="resourceDetails"> The desired resource group configuration. </param> /// <param name="waitForCompletion"> Waits for the completion of the long running operations. </param> /// <param name="cancellationToken"> A token to allow the caller to cancel the call to the service. The default value is <see cref="CancellationToken.None" />. </param> /// <returns> A response with the <see cref="Response{ResourceGroup}"/> operation for this resource. </returns> /// <exception cref="ArgumentException"> Name of the resource group cannot be null or a whitespace. </exception> /// <exception cref="ArgumentNullException"> resourceDetails cannot be null. </exception> public ResourceGroupCreateOrUpdateOperation CreateOrUpdate(string name, ResourceGroupData resourceDetails, bool waitForCompletion = true, CancellationToken cancellationToken = default) { if (string.IsNullOrWhiteSpace(name)) { throw new ArgumentException("name cannot be null or a whitespace.", nameof(name)); } if (resourceDetails is null) { throw new ArgumentNullException(nameof(resourceDetails)); } using var scope = Diagnostics.CreateScope("ResourceGroupCollection.CreateOrUpdate"); scope.Start(); try { var originalResponse = RestClient.CreateOrUpdate(name, resourceDetails, cancellationToken); var operation = new ResourceGroupCreateOrUpdateOperation(this, originalResponse); if (waitForCompletion) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual ResourceGroupCreateOrUpdateOperation CreateOrUpdate(bool waitForCompletion, string resourceGroupName, ResourceGroupData parameters, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } using var scope = _resourceGroupClientDiagnostics.CreateScope("ResourceGroupCollection.CreateOrUpdate"); scope.Start(); try { var response = _resourceGroupRestClient.CreateOrUpdate(Id.SubscriptionId, resourceGroupName, parameters, cancellationToken); var operation = new ResourceGroupCreateOrUpdateOperation(ArmClient, response); if (waitForCompletion) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }