Ejemplo n.º 1
0
        public async virtual Task <Response <IReadOnlyList <VirtualMachineScaleSetVMExtension> > > GetAllAsync(string expand = null, CancellationToken cancellationToken = default)
        {
            using var scope = _clientDiagnostics.CreateScope("VirtualMachineScaleSetVMExtensionCollection.GetAll");
            scope.Start();
            try
            {
                var response = await _virtualMachineScaleSetVMExtensionsRestClient.ListAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, expand, cancellationToken).ConfigureAwait(false);

                return(Response.FromValue(response.Value.Value.Select(value => new VirtualMachineScaleSetVMExtension(Parent, value)).ToArray() as IReadOnlyList <VirtualMachineScaleSetVMExtension>, response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Ejemplo n.º 2
0
        public virtual AsyncPageable <VirtualMachineScaleSetVmExtension> GetAllAsync(string expand = null, CancellationToken cancellationToken = default)
        {
            async Task <Page <VirtualMachineScaleSetVmExtension> > FirstPageFunc(int?pageSizeHint)
            {
                using var scope = _virtualMachineScaleSetVmExtensionVirtualMachineScaleSetVMExtensionsClientDiagnostics.CreateScope("VirtualMachineScaleSetVmExtensionCollection.GetAll");
                scope.Start();
                try
                {
                    var response = await _virtualMachineScaleSetVmExtensionVirtualMachineScaleSetVMExtensionsRestClient.ListAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, expand, cancellationToken : cancellationToken).ConfigureAwait(false);

                    return(Page.FromValues(response.Value.Value.Select(value => new VirtualMachineScaleSetVmExtension(Client, value)), null, response.GetRawResponse()));
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }

            return(PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, null));
        }