Reputation: 69
I'm using the azure change feed to migrate data from one db to the other. But the connection string is rotated every 24 hours. In my code, the connection string is linked to a azure key vault where this value is getting rotated. Everytime this key gets roatated and my change feed is invoked, it still uses the old key and thus errors are observed.
How to enable the change feed read the connection string from the key-vault, everytime it is invoked?
Upvotes: 0
Views: 406
Reputation: 8244
Since the secret is one day old you can use
if (versions.First().CreatedOn.GetValueOrDefault() <= utcNow)
{
continue;
}
Make sure you are using OrderByDescendingAwait
and WhereAwait
for re-arranging the secrets in the reverse-chronological and filtering out.
foreach (var secret in secrets)
{
var versions = await client.GetPropertiesOfSecretVersionsAsync(secret.Name)
.WhereAwait(p => new ValueTask<bool>(p.Enabled.GetValueOrDefault() == true))
.OrderByDescendingAwait(p => new ValueTask<DateTimeOffset>(p.CreatedOn.GetValueOrDefault())).ToListAsync()
.ConfigureAwait(false);
For more information, Please refer KeyVault Secrets Rotation Management.
Upvotes: 1