简体   繁体   中英

Error on azure web app deployment

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 :

在此处输入图片说明

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!!!

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM