[英]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.