ScVmmVirtualMachineResource IOperationSource <ScVmmVirtualMachineResource> .CreateResult(Response response, CancellationToken cancellationToken)
        {
            using var document = JsonDocument.Parse(response.ContentStream);
            var data = ScVmmVirtualMachineData.DeserializeScVmmVirtualMachineData(document.RootElement);

            return(new ScVmmVirtualMachineResource(_client, data));
        }
Beispiel #2
0
        public virtual async Task <ArmOperation <ScVmmVirtualMachineResource> > CreateOrUpdateAsync(WaitUntil waitUntil, string virtualMachineName, ScVmmVirtualMachineData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(virtualMachineName, nameof(virtualMachineName));
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _scVmmVirtualMachineVirtualMachinesClientDiagnostics.CreateScope("ScVmmVirtualMachineCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _scVmmVirtualMachineVirtualMachinesRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, virtualMachineName, data, cancellationToken).ConfigureAwait(false);

                var operation = new ArcScVmmArmOperation <ScVmmVirtualMachineResource>(new ScVmmVirtualMachineOperationSource(Client), _scVmmVirtualMachineVirtualMachinesClientDiagnostics, Pipeline, _scVmmVirtualMachineVirtualMachinesRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, virtualMachineName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation);
                if (waitUntil == WaitUntil.Completed)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }