Dan*_*ler 2 .net c# azure azure-storage
有没有办法可以找到有关Azure Storage拒绝邮件的详细信息?有什么方法可以通过Azure打开调试?通过钢丝鲨更多细节?
这发生在 CloudFile.UploadFromStream(...)
在尝试将文件上传到Azure时,我尝试了针对400 Bad Request的 8个解决方案CDN.似乎人们以各种方式指出代码的问题,错误只是没有表达.
我花了大约4个小时没有运气,没有更具体的看法.
请注意,我没有发布代码,因为我不是在寻找解决我的具体问题的方法,而是寻找可以在更多情况下使用的解决方案.
我建议调查StorageException类,特别RequestInformation是那类类的成员RequestResult.它包含有关错误的有用信息.
这是一个例子.
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);
}
}
Run Code Online (Sandbox Code Playgroud)
在这种情况下,我试图获取blob的租约,但我指定10秒作为租约持续时间,这是一个无效的输入.这将导致400Azure存储的状态代码.当我执行代码时,我得到以下信息:
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
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
755 次 |
| 最近记录: |