public virtual VirtualMachineScaleSetVMRunCommandUpdateOperation Update(VirtualMachineRunCommandUpdate runCommand, bool waitForCompletion = true, CancellationToken cancellationToken = default) { if (runCommand == null) { throw new ArgumentNullException(nameof(runCommand)); } using var scope = _clientDiagnostics.CreateScope("VirtualMachineRunCommandVirtualMachineScaleSetVM.Update"); scope.Start(); try { var response = _restClient.Update(Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, runCommand, cancellationToken); var operation = new VirtualMachineScaleSetVMRunCommandUpdateOperation(this, _clientDiagnostics, Pipeline, _restClient.CreateUpdateRequest(Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, runCommand).Request, response); if (waitForCompletion) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
internal static VirtualMachineRunCommandUpdate GetTestVMUpdateRunCommand() { var vmRunCommandUpdate = new VirtualMachineRunCommandUpdate { Source = new VirtualMachineRunCommandScriptSource("Write-Host Update Hello World!"), }; return(vmRunCommandUpdate); }
/// <summary> /// The operation to update the VMSS VM run command. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. /// </param> /// <param name='vmScaleSetName'> /// The name of the VM scale set. /// </param> /// <param name='instanceId'> /// The instance ID of the virtual machine. /// </param> /// <param name='runCommandName'> /// The name of the virtual machine run command. /// </param> /// <param name='runCommand'> /// Parameters supplied to the Update Virtual Machine RunCommand operation. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <VirtualMachineRunCommand> BeginUpdateAsync(this IVirtualMachineScaleSetVMRunCommandsOperations operations, string resourceGroupName, string vmScaleSetName, string instanceId, string runCommandName, VirtualMachineRunCommandUpdate runCommand, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.BeginUpdateWithHttpMessagesAsync(resourceGroupName, vmScaleSetName, instanceId, runCommandName, runCommand, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// The operation to update the VMSS VM run command. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. /// </param> /// <param name='vmScaleSetName'> /// The name of the VM scale set. /// </param> /// <param name='instanceId'> /// The instance ID of the virtual machine. /// </param> /// <param name='runCommandName'> /// The name of the virtual machine run command. /// </param> /// <param name='runCommand'> /// Parameters supplied to the Update Virtual Machine RunCommand operation. /// </param> public static VirtualMachineRunCommand BeginUpdate(this IVirtualMachineScaleSetVMRunCommandsOperations operations, string resourceGroupName, string vmScaleSetName, string instanceId, string runCommandName, VirtualMachineRunCommandUpdate runCommand) { return(operations.BeginUpdateAsync(resourceGroupName, vmScaleSetName, instanceId, runCommandName, runCommand).GetAwaiter().GetResult()); }
public virtual ArmOperation <VirtualMachineRunCommand> Update(bool waitForCompletion, VirtualMachineRunCommandUpdate runCommand, CancellationToken cancellationToken = default) { Argument.AssertNotNull(runCommand, nameof(runCommand)); using var scope = _virtualMachineRunCommandClientDiagnostics.CreateScope("VirtualMachineRunCommand.Update"); scope.Start(); try { var response = _virtualMachineRunCommandRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, runCommand, cancellationToken); var operation = new ComputeArmOperation <VirtualMachineRunCommand>(new VirtualMachineRunCommandOperationSource(Client), _virtualMachineRunCommandClientDiagnostics, Pipeline, _virtualMachineRunCommandRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, runCommand).Request, response, OperationFinalStateVia.Location); if (waitForCompletion) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public Response Update(string subscriptionId, string resourceGroupName, string vmScaleSetName, string instanceId, string runCommandName, VirtualMachineRunCommandUpdate runCommand, CancellationToken cancellationToken = default) { if (subscriptionId == null) { throw new ArgumentNullException(nameof(subscriptionId)); } if (resourceGroupName == null) { throw new ArgumentNullException(nameof(resourceGroupName)); } if (vmScaleSetName == null) { throw new ArgumentNullException(nameof(vmScaleSetName)); } if (instanceId == null) { throw new ArgumentNullException(nameof(instanceId)); } if (runCommandName == null) { throw new ArgumentNullException(nameof(runCommandName)); } if (runCommand == null) { throw new ArgumentNullException(nameof(runCommand)); } using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, vmScaleSetName, instanceId, runCommandName, runCommand); _pipeline.Send(message, cancellationToken); switch (message.Response.Status) { case 200: return(message.Response); default: throw ClientDiagnostics.CreateRequestFailedException(message.Response); } }
internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string vmScaleSetName, string instanceId, string runCommandName, VirtualMachineRunCommandUpdate runCommand) { var message = _pipeline.CreateMessage(); var request = message.Request; request.Method = RequestMethod.Patch; var uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); uri.AppendPath("/resourceGroups/", false); uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false); uri.AppendPath(vmScaleSetName, true); uri.AppendPath("/virtualMachines/", false); uri.AppendPath(instanceId, true); uri.AppendPath("/runCommands/", false); uri.AppendPath(runCommandName, true); uri.AppendQuery("api-version", _apiVersion, true); request.Uri = uri; request.Headers.Add("Accept", "application/json, text/json"); request.Headers.Add("Content-Type", "application/json"); var content = new Utf8JsonRequestContent(); content.JsonWriter.WriteObjectValue(runCommand); request.Content = content; message.SetProperty("SDKUserAgent", _userAgent); return(message); }
public async virtual Task <VirtualMachineScaleSetVirtualMachineRunCommandUpdateOperation> UpdateAsync(bool waitForCompletion, VirtualMachineRunCommandUpdate runCommand, CancellationToken cancellationToken = default) { if (runCommand == null) { throw new ArgumentNullException(nameof(runCommand)); } using var scope = _clientDiagnostics.CreateScope("VirtualMachineScaleSetVirtualMachineRunCommand.Update"); scope.Start(); try { var response = await _virtualMachineScaleSetVMRunCommandsRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, runCommand, cancellationToken).ConfigureAwait(false); var operation = new VirtualMachineScaleSetVirtualMachineRunCommandUpdateOperation(this, _clientDiagnostics, Pipeline, _virtualMachineScaleSetVMRunCommandsRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, runCommand).Request, response); if (waitForCompletion) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public async Task <Response> UpdateAsync(string resourceGroupName, string vmScaleSetName, string instanceId, string runCommandName, VirtualMachineRunCommandUpdate runCommand, CancellationToken cancellationToken = default) { if (resourceGroupName == null) { throw new ArgumentNullException(nameof(resourceGroupName)); } if (vmScaleSetName == null) { throw new ArgumentNullException(nameof(vmScaleSetName)); } if (instanceId == null) { throw new ArgumentNullException(nameof(instanceId)); } if (runCommandName == null) { throw new ArgumentNullException(nameof(runCommandName)); } if (runCommand == null) { throw new ArgumentNullException(nameof(runCommand)); } using var message = CreateUpdateRequest(resourceGroupName, vmScaleSetName, instanceId, runCommandName, runCommand); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: return(message.Response); default: throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } }
public virtual async Task <ArmOperation <VirtualMachineScaleSetVirtualMachineRunCommandResource> > UpdateAsync(WaitUntil waitUntil, VirtualMachineRunCommandUpdate runCommand, CancellationToken cancellationToken = default) { Argument.AssertNotNull(runCommand, nameof(runCommand)); using var scope = _virtualMachineScaleSetVirtualMachineRunCommandVirtualMachineScaleSetVMRunCommandsClientDiagnostics.CreateScope("VirtualMachineScaleSetVirtualMachineRunCommandResource.Update"); scope.Start(); try { var response = await _virtualMachineScaleSetVirtualMachineRunCommandVirtualMachineScaleSetVMRunCommandsRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, runCommand, cancellationToken).ConfigureAwait(false); var operation = new ComputeArmOperation <VirtualMachineScaleSetVirtualMachineRunCommandResource>(new VirtualMachineScaleSetVirtualMachineRunCommandOperationSource(Client), _virtualMachineScaleSetVirtualMachineRunCommandVirtualMachineScaleSetVMRunCommandsClientDiagnostics, Pipeline, _virtualMachineScaleSetVirtualMachineRunCommandVirtualMachineScaleSetVMRunCommandsRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, runCommand).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
/// <summary> /// The operation to update the run command. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. /// </param> /// <param name='vmName'> /// The name of the virtual machine where the run command should be updated. /// </param> /// <param name='runCommandName'> /// The name of the virtual machine run command. /// </param> /// <param name='runCommand'> /// Parameters supplied to the Update Virtual Machine RunCommand operation. /// </param> public static VirtualMachineRunCommand Update(this IVirtualMachineRunCommandsOperations operations, string resourceGroupName, string vmName, string runCommandName, VirtualMachineRunCommandUpdate runCommand) { return(operations.UpdateAsync(resourceGroupName, vmName, runCommandName, runCommand).GetAwaiter().GetResult()); }
public Response Update(string subscriptionId, string resourceGroupName, string vmScaleSetName, string instanceId, string runCommandName, VirtualMachineRunCommandUpdate runCommand, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); Argument.AssertNotNullOrEmpty(vmScaleSetName, nameof(vmScaleSetName)); Argument.AssertNotNullOrEmpty(instanceId, nameof(instanceId)); Argument.AssertNotNullOrEmpty(runCommandName, nameof(runCommandName)); Argument.AssertNotNull(runCommand, nameof(runCommand)); using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, vmScaleSetName, instanceId, runCommandName, runCommand); _pipeline.Send(message, cancellationToken); switch (message.Response.Status) { case 200: return(message.Response); default: throw new RequestFailedException(message.Response); } }