1

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?

1 Answers1

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