Exemplo n.º 1
0
        public async virtual Task <Response <IReadOnlyList <ServerfarmVirtualNetworkConnection> > > GetAllAsync(CancellationToken cancellationToken = default)
        {
            using var scope = _clientDiagnostics.CreateScope("ServerfarmVirtualNetworkConnectionCollection.GetAll");
            scope.Start();
            try
            {
                var response = await _appServicePlansRestClient.ListVnetsAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false);

                return(Response.FromValue(response.Value.Select(value => new ServerfarmVirtualNetworkConnection(Parent, value)).ToArray() as IReadOnlyList <ServerfarmVirtualNetworkConnection>, response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
        public virtual AsyncPageable <ServerfarmVirtualNetworkConnection> GetAllAsync(CancellationToken cancellationToken = default)
        {
            async Task <Page <ServerfarmVirtualNetworkConnection> > FirstPageFunc(int?pageSizeHint)
            {
                using var scope = _serverfarmVirtualNetworkConnectionAppServicePlansClientDiagnostics.CreateScope("ServerfarmVirtualNetworkConnectionCollection.GetAll");
                scope.Start();
                try
                {
                    var response = await _serverfarmVirtualNetworkConnectionAppServicePlansRestClient.ListVnetsAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken : cancellationToken).ConfigureAwait(false);

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

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