public async virtual Task <ArmOperation <DeploymentScript> > CreateOrUpdateAsync(bool waitForCompletion, string scriptName, DeploymentScriptData deploymentScript, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(scriptName, nameof(scriptName)); Argument.AssertNotNull(deploymentScript, nameof(deploymentScript)); using var scope = _deploymentScriptClientDiagnostics.CreateScope("DeploymentScriptCollection.CreateOrUpdate"); scope.Start(); try { var response = await _deploymentScriptRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, scriptName, deploymentScript, cancellationToken).ConfigureAwait(false); var operation = new ResourcesArmOperation <DeploymentScript>(new DeploymentScriptOperationSource(Client), _deploymentScriptClientDiagnostics, Pipeline, _deploymentScriptRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, scriptName, deploymentScript).Request, response, OperationFinalStateVia.Location); if (waitForCompletion) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual DeploymentScriptCreateOperation CreateOrUpdate(string scriptName, DeploymentScriptData deploymentScript, bool waitForCompletion = true, CancellationToken cancellationToken = default) { if (scriptName == null) { throw new ArgumentNullException(nameof(scriptName)); } if (deploymentScript == null) { throw new ArgumentNullException(nameof(deploymentScript)); } using var scope = _clientDiagnostics.CreateScope("DeploymentScriptCollection.CreateOrUpdate"); scope.Start(); try { var response = _deploymentScriptsRestClient.Create(Id.SubscriptionId, Id.ResourceGroupName, scriptName, deploymentScript, cancellationToken); var operation = new DeploymentScriptCreateOperation(Parent, _clientDiagnostics, Pipeline, _deploymentScriptsRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, scriptName, deploymentScript).Request, response); if (waitForCompletion) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }