public async Task List()
        {
            #region Snippet:Managing_KeyVaults_ListAllVaults
            VaultCollection vaultCollection = resourceGroup.GetVaults();

            AsyncPageable <VaultResource> response = vaultCollection.GetAllAsync();
            await foreach (VaultResource vault in response)
            {
                Console.WriteLine(vault.Data.Name);
            }
            #endregion
        }
Beispiel #2
0
        public async Task KeyVaultManagementListVaults()
        {
            IgnoreTestInLiveMode();
            int n   = 3;
            int top = 2;

            VaultProperties.EnableSoftDelete = null;

            List <string>        resourceIds = new List <string>();
            List <VaultResource> vaultList   = new List <VaultResource>();

            for (int i = 0; i < n; i++)
            {
                string vaultName = Recording.GenerateAssetName("sdktest-vault-");
                VaultCreateOrUpdateContent parameters = new VaultCreateOrUpdateContent(Location, VaultProperties);
                parameters.Tags.InitializeFrom(Tags);
                ArmOperation <VaultResource> createdVault = await VaultCollection.CreateOrUpdateAsync(WaitUntil.Completed, vaultName, parameters).ConfigureAwait(false);

                VaultResource vaultValue = createdVault.Value;

                Assert.NotNull(vaultValue);
                Assert.NotNull(vaultValue.Id);
                resourceIds.Add(vaultValue.Id);
                vaultList.Add(vaultValue);
            }

            AsyncPageable <VaultResource> vaults = VaultCollection.GetAllAsync(top);

            await foreach (var v in vaults)
            {
                Assert.True(resourceIds.Remove(v.Id));
            }

            Assert.True(resourceIds.Count == 0);

            AsyncPageable <VaultResource> allVaults = VaultCollection.GetAllAsync(top);

            Assert.NotNull(vaults);

            // Delete
            foreach (var item in vaultList)
            {
                await item.DeleteAsync(WaitUntil.Completed);
            }
        }