【发布时间】:2018-12-14 14:27:38
【问题描述】:
我正在使用 Azure Blob,代码一直在工作,但现在不行。我收到错误 412,说明包含租约 ID,但租约已过期。我在上传文件之前更新了租约,所以我不确定它为什么会过期。该文件大小为 3-4 MB。这可能是什么原因造成的,我该如何解决。
using (var memoryStream = new System.IO.MemoryStream())
{
AccessCondition acc = new AccessCondition();
acc.LeaseId = blobLease;
blockBlob.RenewLease(acc);
dataSet1.WriteXml(memoryStream);
string newDataHash = GetHash(memoryStream);
System.Diagnostics.Debug.Print("Old Data Hash {0}",originalDataHash);
System.Diagnostics.Debug.Print("New Data Hash {0}",newDataHash);
if (newDataHash != originalDataHash)
{
memoryStream.Position = 0;
try
{
blockBlob.UploadFromStream(memoryStream, acc);
}
catch (StorageException ex)
{
System.Diagnostics.Debug.Print(ex.Message);
count = 15;
timer1_Tick(this, e);
}
originalDataHash = GetHash(memoryStream);
}
else
{
//if data hasn't changed in 15 minutes let lease expire so someone else can use the blob, try to obtain new lease when the user comes back
if (count >= 15)
{
count = 0;
timer1.Stop();
System.Diagnostics.Debug.Print("Attempting to renew Expired Lease");
awaitNewLease(this, e);
}
}
count = 0;
}
【问题讨论】:
-
您得到的确切错误信息是什么?您可以将其添加到您的问题中吗?
-
提供的答案对您的问题有帮助吗?