Skip to content

Commit f9b8fdf

Browse files
committed
Change credential vairable to static filed,
1 parent 2e2e816 commit f9b8fdf

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

shared/src/ContentReactor.Shared/BlobRepository/BlobRepository.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,15 @@ public interface IBlobRepository
2828
public class BlobRepository : IBlobRepository
2929
{
3030
private static readonly BlobServiceClient BlobServiceClient;
31+
private static readonly string ServiceUri = Environment.GetEnvironmentVariable("STORAGE_BLOB_SERVICE_URI");
32+
private static readonly string StorageAccountName = Environment.GetEnvironmentVariable("STORAGE_ACCOUNT_NAME");
33+
private static readonly string StorageAccountKey = Environment.GetEnvironmentVariable("STORAGE_ACCOUNT_KEY");
3134

3235
static BlobRepository()
3336
{
3437
// connect to Azure Storage
35-
string serviceUri = Environment.GetEnvironmentVariable("STORAGE_BLOB_SERVICE_URI");
36-
var credential = new StorageSharedKeyCredential(Environment.GetEnvironmentVariable("STORAGE_ACCOUNT_NAME"), Environment.GetEnvironmentVariable("STORAGE_ACCOUNT_KEY"));
37-
BlobServiceClient = new BlobServiceClient(new Uri(serviceUri), credential);
38+
StorageSharedKeyCredential credential = new StorageSharedKeyCredential(StorageAccountName, StorageAccountKey);
39+
BlobServiceClient = new BlobServiceClient(new Uri(ServiceUri), credential);
3840
}
3941

4042
public BlockBlobClient CreatePlaceholderBlob(string containerName, string blobId)
@@ -113,7 +115,7 @@ public async Task UpdateBlobMetadataAsync(BlockBlobClient blob, IDictionary<stri
113115
public string GetSasTokenForBlob(BlockBlobClient blob, BlobSasBuilder sasBuilder)
114116
{
115117
// Create a SharedKeyCredential that we can use to sign the SAS token
116-
var credential = new StorageSharedKeyCredential(Environment.GetEnvironmentVariable("STORAGE_ACCOUNT_NAME"), Environment.GetEnvironmentVariable("STORAGE_ACCOUNT_KEY"));
118+
var credential = new StorageSharedKeyCredential(StorageAccountName, StorageAccountKey);
117119

118120
// Build a SAS URI
119121
UriBuilder sasUri = new UriBuilder(blob.Uri)

0 commit comments

Comments
 (0)