windows azure blob在sdk1.4租赁

时间:2011-10-22 21:45:09

标签: azure azure-storage-blobs

在咨询以下主题后,我一直在使用以下代码 - Use blob-leasing feature in the Azure cloud app

    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中发生了哪些变化,搞砸了吗?

由于 卡皮尔

1 个答案:

答案 0 :(得分:0)

400代码表示“错误请求”应该有一些额外的错误消息,有关示例,请参阅http://paulsomers.blogspot.com/2010/10/azure-error-400-bad-request.html。您应该尝试调试或嗅探网络以获取错误消息。

在版本1.4中有一些下载blob的错误,但它们可能不会影响你。但是,您应该升级到最新版本。

相关问题