public async Task List()
        {
            TenantResource tenant = await Client.GetTenants().GetAllAsync().FirstOrDefaultAsync(_ => true);

            SubscriptionResource subscription = await tenant.GetSubscriptions().GetAllAsync().FirstOrDefaultAsync(_ => true);

            string rgName            = Recording.GenerateAssetName("testRg-");
            ResourceGroupResource rg = await CreateResourceGroup(subscription, rgName);

            string          vnName1 = Recording.GenerateAssetName("testVn-");
            string          vnName2 = Recording.GenerateAssetName("testVn-");
            string          vnName3 = Recording.GenerateAssetName("testVn-");
            GenericResource vn1     = await CreateGenericVirtualNetwork(subscription, rg, vnName1);

            GenericResource vn2 = await CreateGenericVirtualNetwork(subscription, rg, vnName2);

            GenericResource vn3 = await CreateGenericVirtualNetwork(subscription, rg, vnName3);

            string resourceLinkName1 = Recording.GenerateAssetName("link-");
            string resourceLinkName2 = Recording.GenerateAssetName("link-");

            _ = await CreateResourceLink(tenant, vn1, vn2, resourceLinkName1);

            _ = await CreateResourceLink(tenant, vn1, vn3, resourceLinkName2);

            int count = 0;

            await foreach (var resourceLink in tenant.GetResourceLinks(vn1.Id).GetAllAsync())
            {
                count++;
            }
            Assert.AreEqual(count, 2);
        }
        public async Task CreateOrUpdate()
        {
            TenantResource tenant = await Client.GetTenants().GetAllAsync().FirstOrDefaultAsync(_ => true);

            SubscriptionResource subscription = await tenant.GetSubscriptions().GetAllAsync().FirstOrDefaultAsync(_ => true);

            string rgName            = Recording.GenerateAssetName("testRg-");
            ResourceGroupResource rg = await CreateResourceGroup(subscription, rgName);

            string          vnName1 = Recording.GenerateAssetName("testVn-");
            string          vnName2 = Recording.GenerateAssetName("testVn-");
            GenericResource vn1     = await CreateGenericVirtualNetwork(subscription, rg, vnName1);

            GenericResource vn2 = await CreateGenericVirtualNetwork(subscription, rg, vnName2);

            string resourceLinkName           = Recording.GenerateAssetName("link-");
            ResourceLinkResource resourceLink = await CreateResourceLink(tenant, vn1, vn2, resourceLinkName);

            Assert.AreEqual(resourceLinkName, resourceLink.Data.Name);
            Assert.ThrowsAsync <ArgumentNullException>(async() => _ = await tenant.GetResourceLinks(null).CreateOrUpdateAsync(WaitUntil.Completed, null));
            Assert.ThrowsAsync <ArgumentNullException>(async() => _ = await tenant.GetResourceLinks(rg.Id).CreateOrUpdateAsync(WaitUntil.Completed, null));
        }
Beispiel #3
0
        public async Task Delete()
        {
            TenantResource tenant = await Client.GetTenants().GetAllAsync().FirstOrDefaultAsync(_ => true);

            SubscriptionResource subscription = await tenant.GetSubscriptions().GetAllAsync().FirstOrDefaultAsync(_ => true);

            string rgName            = Recording.GenerateAssetName("testRg-");
            ResourceGroupResource rg = await CreateResourceGroup(subscription, rgName);

            string          vnName1 = Recording.GenerateAssetName("testVn-");
            string          vnName2 = Recording.GenerateAssetName("testVn-");
            GenericResource vn1     = await CreateGenericVirtualNetwork(subscription, rg, vnName1);

            GenericResource vn2 = await CreateGenericVirtualNetwork(subscription, rg, vnName2);

            string resourceLinkName           = Recording.GenerateAssetName("link-");
            ResourceLinkResource resourceLink = await CreateResourceLink(tenant, vn1, vn2, resourceLinkName);

            await resourceLink.DeleteAsync(WaitUntil.Completed);

            var ex = Assert.ThrowsAsync <RequestFailedException>(async() => await resourceLink.GetAsync());

            Assert.AreEqual(404, ex.Status);
        }
Beispiel #4
0
 /// <summary>
 /// Gets the Azure subscriptions.
 /// </summary>
 /// <returns> Subscription collection. </returns>
 public virtual SubscriptionCollection GetSubscriptions() => _tenant.GetSubscriptions();