【问题标题】:Azure Storage access from Azure web site从 Azure 网站访问 Azure 存储
【发布时间】:2015-12-08 13:27:14
【问题描述】:

我在从 Visual Studio 2015 iisexpress 愉快运行的网站中内置了一个 Blob 存储树显示。将文件上传到 Azure 网站时,带有存储树的页面会导致浏览器错误“重定向过多”。因为它在 Azure 上运行,有什么不同吗?我是 Azure 新手。

这是连接的代码

@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

【问题讨论】:

  • 您需要发布一些代码,似乎该网站将您重定向到重定向的页面等等......。因此,您的登录页面或错误页面中可能存在一些配置错误。检查您何时进行重定向和您的 loginUrl 配置等。我想当您找到重定向您的代码时,您将获得有关如何修复它的答案。 to many 重定向 100% 与您使用 windows-azure-storage 的事实无关。
  • 该代码不会导致 VS 中的重定向,因此我认为该代码很好。只有从 Azure 运行时才会出现问题。它使用 nuget 安装包:WindowsAzure.Storage、Microsoft.Azure.KeyVault.Core、Microsoft.Azure.KeyVault、Microsoft.Azure.Common.Dependencies 和 Microsoft.Azure.Common。所以问题是,在外部 Web 服务器上运行站点和在 Azure 上运行相同站点并访问 Azure Blob 存储之间有什么区别。就我而言,应该没有。很高兴被证明是错误的,因此提出了这个问题。
  • 你能通过 Fiddler 之类的东西追踪请求吗?
  • 刚刚添加了执行连接的代码。没用过Fiddler,试试看。
  • Fiddler 只是告诉我浏览器和站点之间发生了什么,而不是站点和存储之间发生了什么。每次重新加载在文本视图中返回的内容是:- "ac 对象移动

    对象移动到 somesite.net/en-gb/login/">here</a>.</h2 > 0"

标签: azure azure-web-app-service


【解决方案1】:

来自comment2answer:您需要发布一些代码,该网站似乎将您重定向到重定向的页面等等......。因此,您的登录页面或错误页面中可能存在一些配置错误。检查您何时进行重定向和您的 loginUrl 配置等。我想当您找到重定向您的代码时,您将获得有关如何修复它的答案。 to many 重定向 100% 与您使用 windows-azure-storage 的事实无关

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-01-14
    • 1970-01-01
    • 1970-01-01
    • 2016-11-14
    • 1970-01-01
    • 2017-02-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多