1
votes

I am new in azure application development. As per the requirements given to me, I had developed an application on azure and successfully deployed it on azure cloud.Blob storage was also being used in that application. Everything was working fine.

When I was deploying it on cloud then that time I was not very much aware about azure deployment so I had deployed it as a cloud service. It worked fine but the only issue was about slow loading at the very first time. Then after doing lot of research I found some solutions so I have deployed it as web app then the slow loading problem was resolved. But with web app deployment, I am facing another problem with a single page which is using blob storage. Below is the error I am getting when opening that specific page :

enter image description here

Below is the code which I had written :

public List<string> ListContainer()
        {
            List<string> blobs = new List<string>();

            if (!Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.IsAvailable) return null;

            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.GetConfigurationSettingValue("FileStorageAccount"));
            CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

            IEnumerable<CloudBlobContainer> containers = blobClient.ListContainers();

            foreach (CloudBlobContainer item in containers)
            {
                foreach (IListBlobItem blob in item.ListBlobs())
                {
                    blobs.Add(string.Format("{0}", blob.Uri));
                }
            }

            return blobs;
        }

It is working fine when running on visual studio but on deployment If I am going with cloud service deployment then I am not getting this specific error. Other pages are working fine with web deployment. The page which causing an error uses blob storage.

I had done lot of research but no luck. Please help!!!

1

1 Answers

1
votes

I suspect you have not defined the "FileStorageAccount" Setting in the CSCFG file. Try using the CloudConfigurationManager.GetSetting method. It will read configuration values from the web.config or service configuration file. See also https://stackoverflow.com/a/19643516/5382426.