Azure Storage access from Azure web site

[亡魂溺海] 提交于 2020-01-07 03:55:06

问题


I have a blob storage tree display built into a website running happily from the Visual Studio 2015 iisexpress. When the files are uploaded to an Azure web site, the page with the storage tree causes a browser error "Too many redirects". Is there anything different because it's running on Azure? I'm an Azure newbie.

Here is the code doing the connection

@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@using Microsoft.WindowsAzure.Storage;
@using Microsoft.WindowsAzure.Storage.Auth;
@using Microsoft.WindowsAzure.Storage.Blob;
@using System.Web.Configuration;
@using System.Text;
@using System.Linq;

@{
    string accountName = WebConfigurationManager.AppSettings["AzureStorageAccountName"];
    string accountKey = WebConfigurationManager.AppSettings["AzureStorageAccessKey"];
    string rootContainer = WebConfigurationManager.AppSettings["AzureStorageRootContainer"];

    try {
        StorageCredentials creds = new StorageCredentials(accountName,accountKey);
        CloudStorageAccount account = new CloudStorageAccount(creds,useHttps :true);

        CloudBlobClient client = account.CreateCloudBlobClient();

        IEnumerable<CloudBlobContainer> containerList = client.ListContainers(rootContainer);

        foreach(var container in containerList) {    
            var blobCount = container.ListBlobs().Count();
            HtmlString listing = getContainerDirectories(container.ListBlobs());

            @Html.Raw(listing); 
        }
    } catch(Exception ex) {
        <p>@Umbraco.GetDictionaryValue("[Global] Sorry try again")</p>
    }
}

TIA


回答1:


From comment2answer: You need to post some code, it seems the site redirects you to a page that redirects and so on ... . So it is probably have some configuration error in your logon page or error page. Check when you do a redirect and your loginUrl configuration etc. I guess when you find the code that redirects you, you will have the answer on how to fix it. The to many redirects is 100% not related with the fact you are using windows-azure-storage



来源:https://stackoverflow.com/questions/34157125/azure-storage-access-from-azure-web-site

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!