简体   繁体   中英

The connection string is not updating on rotation for change feed in Azure

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?

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM