简体   繁体   English

将文件上传到Azure CDN时如何获取有关400错误请求错误的更多信息

[英]How to get more info on the 400 Bad Request Error when uploading file to Azure CDN

Is there a way I can find out more details about why Azure Storage rejected the message? 有没有办法找到有关Azure存储为何拒绝该消息的更多详细信息? Some way to turn on debugging via Azure? 通过Azure打开调试的某种方法吗? More details via wire shark? 通过钢丝鲨有更多细节吗?

This happens from CloudFile.UploadFromStream(...) 这是从CloudFile.UploadFromStream(...)

I've tried about 8 solutions for the 400 Bad Request when trying to upload a file to an Azure CDN . 尝试将文件上传到Azure CDN时,我已经尝试了8种解决400错误请求的解决方案。 It seems like people point out issues with the code, in various ways that the error just does not express. 人们似乎以各种方式指出了代码存在的问题,而这些错误只是无法表达。

I've spent about 4 hours with no luck, and nothing more specific to look at. 我花了大约4个小时没有运气,也没有什么比这更具体的了。

Please note, I have not posted the code, as I am not looking for a solution to my specific issue as much as finding a solution that I can use in more situations. 请注意,我没有发布代码,因为我不希望找到针对特定问题的解决方案,而是寻找可以在更多情况下使用的解决方案。

I would suggest looking into StorageException class, especially RequestInformation member of that class which is of type RequestResult . 我建议查看StorageException类,尤其是该类的RequestInformation成员,该成员的类型为RequestResult It contains useful information about the error. 它包含有关错误的有用信息。

Here's an example. 这是一个例子。

    static void UnderstandStorageException()
    {
        var cred = new StorageCredentials(accountName, accountKey);
        var account = new CloudStorageAccount(cred, true);
        var client = account.CreateCloudBlobClient();
        var container = client.GetContainerReference("container");
        var blockBlob = container.GetBlockBlobReference("something.txt");
        try
        {
            blockBlob.UploadFromFile(@"D:\test.txt");
            blockBlob.AcquireLease(TimeSpan.FromSeconds(10), Guid.NewGuid().ToString());
            blockBlob.Delete();
        }
        catch (StorageException excep)
        {
            var requestInformation = excep.RequestInformation;
            Console.WriteLine(requestInformation.HttpStatusCode);
            Console.WriteLine(requestInformation.HttpStatusMessage);
            Console.WriteLine(requestInformation.ExtendedErrorInformation.ErrorCode);
            Console.WriteLine(requestInformation.ExtendedErrorInformation.ErrorMessage);
        }
    }

In this case, I am trying to acquire a lease on a blob but I am specifying 10 seconds as lease duration which is an invalid input. 在这种情况下,我试图获取Blob上的租约,但我将10秒钟指定为租约持续时间,这是无效的输入。 This will result in 400 status code from Azure Storage. 这将产生来自Azure存储的400状态代码。 When I execute the code, I get following information back: 当我执行代码时,我会得到以下信息:

HTTP Status Code: 400
HTTP Status Message: The value for one of the HTTP headers is not in the correct format.
Storage Error Code: InvalidHeaderValue
Storage Error Message: The value for one of the HTTP headers is not in the correct format.
RequestId:04969aab-0001-001c-5965-6df5fe000000
Time:2017-01-13T06:23:25.4667820Z

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 通过REST将文件上传到OneDrive时出现400错误请求错误 - Getting a 400 Bad Request error when uploading file to OneDrive through REST 上传文件到 SharePoint 时收到“远程服务器返回错误:(400)错误请求” - Receiving "The remote server returned an error: (400) Bad Request" when uploading file to SharePoint “ 400错误:错误的请求” Azure存储连接 - “400 Error: Bad request” Azure Storage Connection 上载文件时一驱动器Rest api服务器错误请求400 - One drive Rest api server bad request 400 when uploading file 上传到 Azure Blob 存储时出现 400 错误 - 400 error when uploading to Azure Blob Storage 部署更新API时如何解决400错误的错误请求 - How to resolve 400 error with bad request in update api when it is deployed 在C#ASP.NET MVC3中获取名称包含&字符的文件时出现错误400(错误请求) - Error 400 (Bad Request) when get a file which name contains & character in C# ASP.NET MVC3 发布到Azure Blob存储时非常偶尔出现400错误的请求错误 - Very occasional 400 Bad Request error when posting to Azure Blob Storage 通过 Azure Devops 发送提交多个 wiki 页面时出现 400 错误请求错误 - 400 Bad Request Error when send submitting Multiple wiki pages through Azure Devops MS Azure-错误请求400 - MS Azure - Bad Request 400
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM