public async virtual Task <Response <VirtualMachine> > GetAsync(string vmName, InstanceViewTypes?expand = null, CancellationToken cancellationToken = default) { using var scope = _clientDiagnostics.CreateScope("VirtualMachineContainer.Get"); scope.Start(); try { if (vmName == null) { throw new ArgumentNullException(nameof(vmName)); } var response = await _restClient.GetAsync(Id.ResourceGroupName, vmName, expand, cancellationToken : cancellationToken).ConfigureAwait(false); if (response.Value == null) { throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false); } return(Response.FromValue(new VirtualMachine(Parent, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual async Task <Response <VirtualMachine> > GetAsync(CancellationToken cancellationToken = default) { using var scope = _virtualMachineClientDiagnostics.CreateScope("VirtualMachine.Get"); scope.Start(); try { var response = await _virtualMachineRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); if (response.Value == null) { throw new RequestFailedException(response.GetRawResponse()); } return(Response.FromValue(new VirtualMachine(Client, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual async Task <Response <ScVmmVirtualMachineResource> > GetAsync(string virtualMachineName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(virtualMachineName, nameof(virtualMachineName)); using var scope = _scVmmVirtualMachineVirtualMachinesClientDiagnostics.CreateScope("ScVmmVirtualMachineCollection.Get"); scope.Start(); try { var response = await _scVmmVirtualMachineVirtualMachinesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, virtualMachineName, cancellationToken).ConfigureAwait(false); if (response.Value == null) { throw new RequestFailedException(response.GetRawResponse()); } return(Response.FromValue(new ScVmmVirtualMachineResource(Client, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public async virtual Task <Response <VirtualMachine> > GetAsync(string vmName, InstanceViewTypes?expand = null, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(vmName, nameof(vmName)); using var scope = _virtualMachineClientDiagnostics.CreateScope("VirtualMachineCollection.Get"); scope.Start(); try { var response = await _virtualMachineRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, vmName, expand, cancellationToken).ConfigureAwait(false); if (response.Value == null) { throw await _virtualMachineClientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false); } return(Response.FromValue(new VirtualMachine(Client, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }