Ejemplo n.º 1
0
        public async Task ListAtContext()
        {
            var           rgOp1 = await(await Client.GetDefaultSubscriptionAsync().ConfigureAwait(false)).GetResourceGroups().Construct(Location.WestUS2).CreateOrUpdateAsync(Recording.GenerateAssetName("testrg"));
            ResourceGroup rg    = rgOp1.Value;

            _ = await CreateGenericAvailabilitySetAsync(rg.Id);

            ResourceGroup rgOp     = Client.GetResourceGroup(rg.Id);
            var           result   = 0;
            var           pageable = ResourceListOperations.GetAtContextAsync(rgOp);

            await foreach (var resource in pageable)
            {
                result++;
            }
            Assert.AreEqual(1, result);

            result   = 0;
            pageable = ResourceListOperations.GetAtContextAsync(await Client.GetDefaultSubscriptionAsync().ConfigureAwait(false));
            await foreach (var resource in pageable)
            {
                result++;
            }
            Assert.GreaterOrEqual(result, 1);
        }
Ejemplo n.º 2
0
        public static AsyncPageable <GenericResource> GetManagedHsmByNameAsync(this Subscription subscription, string filter, string expand, int?top, CancellationToken cancellationToken = default)
        {
            ResourceFilterCollection filters = new(ManagedHsm.ResourceType);

            filters.SubstringFilter = filter;
            return(ResourceListOperations.GetAtContextAsync(subscription, filters, expand, top, cancellationToken));
        }
Ejemplo n.º 3
0
 public virtual AsyncPageable <GenericResource> GetAllAsGenericResourcesAsync(string nameFilter, string expand = null, int?top = null, CancellationToken cancellationToken = default)
 {
     using var scope = _clientDiagnostics.CreateScope("VirtualNetworkContainer.GetAllAsGenericResources");
     scope.Start();
     try
     {
         var filters = new ResourceFilterCollection(VirtualNetwork.ResourceType);
         filters.SubstringFilter = nameFilter;
         return(ResourceListOperations.GetAtContextAsync(Parent as ResourceGroup, filters, expand, top, cancellationToken));
     }
     catch (Exception e)
     {
         scope.Failed(e);
         throw;
     }
 }
Ejemplo n.º 4
0
 public virtual AsyncPageable <GenericResource> GetAllAsGenericResourcesAsync(string nameFilter, string expand = null, int?top = null, CancellationToken cancellationToken = default)
 {
     using var scope = _clientDiagnostics.CreateScope("SubscriptionLongTermRetentionManagedInstanceBackupCollection.GetAllAsGenericResources");
     scope.Start();
     try
     {
         var filters = new ResourceFilterCollection(SubscriptionLongTermRetentionManagedInstanceBackup.ResourceType);
         filters.SubstringFilter = nameFilter;
         return(ResourceListOperations.GetAtContextAsync(Parent as Subscription, filters, expand, top, cancellationToken));
     }
     catch (Exception e)
     {
         scope.Failed(e);
         throw;
     }
 }