我一直在使用我在咨询以下线程后编写的以下代码 -在 Azure 云应用程序中使用 blob-leasing 功能
public static void UploadFromStreamWithLease(CloudBlob blob, Stream src, string leaseID)
{
string url = blob.Uri.ToString();
if (blob.ServiceClient.Credentials.NeedsTransformUri)
{
url = blob.ServiceClient.Credentials.TransformUri(url);
}
HttpWebRequest req = BlobRequest.Put(new Uri(url), 90, blob.Properties, BlobType.BlockBlob, leaseID, 0);
BlobRequest.AddMetadata(req, blob.Metadata);
using (var writer = new StreamWriter(req.GetRequestStream()))
{
byte[] content = new byte[src.Length];
writer.Write(readFully(src));
}
blob.ServiceClient.Credentials.SignRequest(req);
req.GetResponse().Close();
}
上面的 readFully() 方法只是将流中的内容获取到 byte[] 数组。
我一直在使用此代码将一些内容上传到任何具有有效leaseId 的 blob。在我迁移到 Azure SDK 1.4 版之前,这一切正常。在新版本的 azure sdk 中,我在 req.GetResponse() 方法中收到错误 400。
有人可以指出 azure sdk 1.4 发生了什么变化吗?
谢谢卡皮尔