0

我一直在使用我在咨询以下线程后编写的以下代码 -在 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 发生了什么变化吗?

谢谢卡皮尔

4

1 回答 1

0

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

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

于 2011-10-23T17:05:58.607 回答