コード例 #1
0
        private async Task ProcessSecret(string secretUri, CancellationToken token)
        {
            var secret = await _dataProvider.GetConfiguredSecretAsync(Secret.FromKeyvaultUri(secretUri).Key, token);

            if (null == secret)
            {
                //what do we do we if can't find the secret?
                _logger?.LogWarning($"Unable to retrieve metadata for seceret {secretUri}");
                return;
            }

            if (secret.SecretType == SecretType.Attached && null == secret.Configuration)
            {
                //what do we do if secret doesn't have config
                _logger?.LogWarning($"Unable to retrieve configuration metadata for seceret {secretUri}");
                throw new InvalidOperationException("Unable to retreive seceret configuration metadata");
            }

            Providers.SecretManagerFactory factory = new Providers.SecretManagerFactory(_config, _dataProvider, _logger);
            await factory.RotateSecretAsync(secret, token);
        }