0
votes

I am using the AzureBlobCache config and would like to set the CacheStorageAccount parameter (and other parameters) at runtime because I don't want to commit my storage account credentials into source control in the config file.

I am deploying to Azure App Service and would like to set my CacheStorageAccount in Azure App Service's AppSettings so it could read at runtime instead of reading from the config file.

How can/should I achieve this? Should I modify the web.config in Global.asax?

1

1 Answers

1
votes

Managed to find the solution. I set this in the Global.asax Application_Start() event to overwrite the settings in the config files.

var appSettings = ConfigurationManager.AppSettings;
var config = ImageProcessorConfiguration.Instance;

var cachedStorageAccount = appSettings["CachedStorageAccount"];
if (!string.IsNullOrEmpty(cachedStorageAccount))
{
    config.ImageCacheSettings["CachedStorageAccount"] = cachedStorageAccount;
}