i'm new to azure and i have the following issue:
i have this key in my web.config:
add key="BlobStorageConnectionString" value="xxxxxxxx"
The thing is when i add it to app settings in azure app service, when i search in the logs i get this:
Getting "BlobStorageConnectionString" from ServiceRuntime: FAIL
Getting "BlobStorageConnectionString" from ConfigurationManager: PASS.
i've already tried a few tutorials, but i still can't find a reason.
I'm running out of ideas, any suggestions?
Asked
Active
Viewed 177 times
1
-
Provide code how you are reading those settings. Also what do you use c#, node js? – Vova Bilyachat Feb 25 '19 at 00:42
-
@VolodymyrBilyachat, i'm using C#, the line of code is: var d = CloudConfigurationManager.GetSetting("BlobStorageConnectionString") – Nicolás Federico Flappo Feb 25 '19 at 00:52
-
https://stackoverflow.com/questions/29655648/cloudconfigurationmanager-vs-webconfigurationmanager – Vova Bilyachat Feb 25 '19 at 00:57
-
Is it Full framework or .net core? Please provide more information about your application and update your question its hard to help with information you did provide. – Vova Bilyachat Feb 25 '19 at 00:58
-
It’s net fwk 4.7.2 – Nicolás Federico Flappo Feb 25 '19 at 00:59
-
Have you tried to use ConfigurationManager ? – Vova Bilyachat Feb 25 '19 at 01:00
1 Answers
2
If you add the Storage Account string in the Application Settings, it will be stored as an environment.So you could read it with Environment.GetEnvironmentVariable("storageconnectionstring")
.
Then parse it the code will be like below shows.
string storageConnectionString = Environment.GetEnvironmentVariable("storageconnectionstring");
// Check whether the connection string can be parsed.
if (CloudStorageAccount.TryParse(storageConnectionString, out storageAccount))
{
try
{
// Create the CloudBlobClient that represents the Blob storage endpoint for the storage account.
CloudBlobClient cloudBlobClient = storageAccount.CreateCloudBlobClient();
........
........
}
}
And you could also configure your connection in your app like WebJob, you could use JobHostConfiguration()
. And the code would be like this.And the connection name should be AzureWebJobsStorage.
var config = new JobHostConfiguration();
config.DashboardConnectionString = "";
Also you could choose to use Configuration Classes,about the details you could refer to this article.
Hope this could help you, if you still have other questions,please let me know.

George Chen
- 13,703
- 2
- 11
- 26