none
如何Java 使用 Blob 存储 RRS feed

  • 问题

  • 按照这个教程一步步操作的,http://www.windowsazure.cn/zh-cn/develop/java/how-to-guides/blob-storage/

    还是有Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature这个异常,奇怪的是我用Azure Storage Explorer访问我在azure管理门户创建的存储账户,也得到相同的错误。而访问创建虚拟机自动创建的存储账户时,得到的错误是无法连接到远程服务器。是不是还需要对存储进行权限设置才能正常访问啊?怎么解决?


    enhua2008

    2014年5月13日 9:28

答案

  • hi,该问题是由于缺少Shared Access Signature的问题, 您可能需要在您的代码中加入类似于这样的一段代码:

    //Create the shared access permissions and policy
                    BlobContainerPermissions containerPermissions = new BlobContainerPermissions();
                    string sas = container.GetSharedAccessSignature(new SharedAccessPolicy()
                        {
                            SharedAccessExpiryTime = DateTime.UtcNow.AddMinutes(30), Permissions = 
                                SharedAccessPermissions.Write | SharedAccessPermissions.Read
                        });
                    //Turn off public access
                    containerPermissions.PublicAccess = BlobContainerPublicAccessType.Off;
                    container.SetPermissions(containerPermissions);
    
                    string uniqueBlobName = string.Format(@"<storagecontainername>/<filename>_{0}.config", 
                           Guid.NewGuid().ToString());
    
                    //assign the shared access policy
                    CloudBlobClient blobClient = new CloudBlobClient(account.BlobEndpoint, new 
                           StorageCredentialsSharedAccessSignature(sas));
    
                    CloudBlob blb = blobClient.GetBlobReference(uniqueBlobName);

    在代码中您可以获取SharedAccessSignature并且指定给blobclient。您可以参考这个case,出现同样的错误( http://blogs.msdn.com/b/skaufman/archive/2012/10/15/blob-storage-and-shared-access-signatures.aspx )。同时为了更好的理解这个问题,建议您看这个blog (http://blogs.msdn.com/b/windowsazurestorage/archive/2012/06/12/introducing-table-sas-shared-access-signature-queue-sas-and-update-to-blob-sas.aspx

    希望对您有所帮助。

    Regards,

    Will


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    2014年5月14日 8:17
    版主