Azure / Azure/azure-functions-host

Add retry logic when reading secrets from Blob Storage

Open
#6,891 0 comments 0 reactions 1 assignee Assigned to @alrod View on GitHub
Dominant language
C#
Stars
2k
Forks
482
Avg merge
2d 10h
Merged PRs (30d)
36

Description

Currently, we only try once when reading secrets from Blob Storage. Perhaps it would make sense to add retry logic for certain scenarios like a transient unavailable storage account issue.

Here is the link to the code that reads from Blob Storage:

https://github.com/Azure/azure-functions-host/blob/dev/src/WebJobs.Script.WebHost/Security/KeyManagement/BlobStorageSecretsRepository.cs#L93

```
public override async Task ReadAsync(ScriptSecretsType type, string functionName)
{
string secretsContent = null;
string blobPath = GetSecretsBlobPath(type, functionName);
try
{
CloudBlockBlob secretBlob = Container.GetBlockBlobReference(blobPath);
if (await secretBlob.ExistsAsync())
{
secretsContent = await secretBlob.DownloadTextAsync();
}
}
catch (Exception e)
{
LogErrorMessage("read");
throw e;
}

return string.IsNullOrEmpty(secretsContent) ? null : ScriptSecretSerializer.DeserializeSecrets(type, secretsContent);
}

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.