Example #1
0
        public async Task Run()
        {
            var authHelper = new AuthToKeyVault();
            var kv         = new KeyVaultHelpers(KeyVaultUrl, authHelper.AuthenticateToKeyVault);

            await ListAllKeys(kv);
            await ListAllSecrets(kv);

            const string multipleVersionTest = "multiple-secret-version-test";
            //await CreateMultipleVersionsOfSecret(kv, multipleVersionTest);
            //await ListAllSecretVersions(kv, multipleVersionTest);

            var latest = await kv.GetSecret(multipleVersionTest);

            Console.WriteLine("Latest of multiple versions is:");
            Output(latest);
        }
Example #2
0
        private static async Task ListAllSecretVersions(KeyVaultHelpers kv, string secretName)
        {
            var secretVersionPages = await kv.GetSecretVersions(secretName);

            foreach (var secretVersion in secretVersionPages)
            {
                Output(secretVersion);

                var vid        = secretVersion.Identifier;
                var vidVersion = vid.Version;

                if (secretVersion.Attributes.Enabled == true)
                {
                    var secretBundle = await kv.GetSecret(secretName, vidVersion);

                    Output(secretBundle);
                }
            }
        }
Example #3
0
        private static async Task ListAllSecrets(KeyVaultHelpers kv)
        {
            var secretPages = await kv.GetSecrets();

            foreach (var secretItem in secretPages)
            {
                Console.WriteLine();

                Output(secretItem);

                var secretName = secretItem.Identifier.Name;

                if (secretItem.Attributes.Enabled == true)
                {
                    var secretBundle = await kv.GetSecret(secretName);

                    Output(secretBundle);
                }

                await ListAllSecretVersions(kv, secretName);
            }
        }