[
https://issues.apache.org/jira/browse/JCLOUDS-1428?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16998110#comment-16998110
]
Manju commented on JCLOUDS-1428:
--------------------------------
*Using Azure Secret Key: Working fine*
{code:java}
it should "Upload a file" in {
val sasToken = AppConf.getSSAToken("azure")
val azureKey = AppConf.getStorageKey("azure")
val azureToken = AppConf.getStorageSecret("azure")
import org.jclouds.ContextBuilder
import org.jclouds.blobstore.BlobStoreContext
val context = ContextBuilder.newBuilder("azureblob").credentials(azureKey,
azureToken).buildView(classOf[BlobStoreContext])
var blobStore = context.getBlobStore()
blobStore.createContainerInLocation(null, "mycontainer")
val fileObj = new File("src/test/resources/test-data.log")
val payload = Files.asByteSource(fileObj)
val blob =
blobStore.blobBuilder("test1/5453").payload(payload).contentLength(payload.size()).build()
blobStore.putBlob("mycontainer", blob, new PutOptions().multipart())
context.close()
}
{code}
*Using Azure SAS Token: It fails to upload*
{code:java}
it should "Upload a file" in {
val sasToken = AppConf.getSSAToken("azure")
val azureKey = AppConf.getStorageKey("azure")
val azureToken = AppConf.getStorageSecret("azure")
import org.jclouds.ContextBuilder
import org.jclouds.blobstore.BlobStoreContext
val context = ContextBuilder.newBuilder("azureblob").credentials(azureKey,
sasToken).buildView(classOf[BlobStoreContext])
var blobStore = context.getBlobStore()
blobStore.createContainerInLocation(null, "mycontainer")
val fileObj = new File("src/test/resources/test-data.log")
val payload = Files.asByteSource(fileObj)
val blob =
blobStore.blobBuilder("test1/5453").payload(payload).contentLength(payload.size()).build()
blobStore.putBlob("mycontainer", blob, new PutOptions().multipart())
context.close()
}
{code}
*Error: When using SAS Token*
{code:java}
org.jclouds.azure.storage.AzureStorageResponseException: command
[method=org.jclouds.azureblob.AzureBlobClient.public abstract void
org.jclouds.azureblob.AzureBlobClient.putBlock(java.lang.String,java.lang.String,java.lang.String,org.jclouds.io.Payload)[mycontainer,
test1/5453, AAAAAQ==, [content=true, contentMetadata=[cacheControl=null,
contentDisposition=null, contentEncoding=null, contentLanguage=null,
contentLength=7986, contentMD5=null, contentType=application/unknown,
expires=null], written=false, isSensitive=false]], request=PUT
https://test.blob.core.windows.net/mycontainer/test1/5453?comp=block&blockid=AAAAAQ%3D%3D
HTTP/1.1] failed with code 400, error:
AzureError{requestId='c13bc6b2-f01e-0020-5acd-b4114e000000',
code='InvalidQueryParameterValue', message='Value for one of the query
parameters specified in the request URI is invalid.
RequestId:c13bc6b2-f01e-0020-5acd-b4114e000000
Time:2019-12-17T11:31:17.8460459Z', context='{QueryParameterValue=block,
QueryParameterName=comp, Reason=}'}
com.google.common.util.concurrent.UncheckedExecutionException:
org.jclouds.azure.storage.AzureStorageResponseException: command
[method=org.jclouds.azureblob.AzureBlobClient.public abstract void
org.jclouds.azureblob.AzureBlobClient.putBlock(java.lang.String,java.lang.String,java.lang.String,org.jclouds.io.Payload)[mycontainer,
test1/5453, AAAAAQ==, [content=true, contentMetadata=[cacheControl=null,
contentDisposition=null, contentEncoding=null, contentLanguage=null,
contentLength=7986, contentMD5=null, contentType=application/unknown,
expires=null], written=false, isSensitive=false]], request=PUT
https://test.blob.core.windows.net/mycontainer/test1/5453?comp=block&blockid=AAAAAQ%3D%3D
HTTP/1.1] failed with code 400, error:
AzureError{requestId='c13bc6b2-f01e-0020-5acd-b4114e000000',
code='InvalidQueryParameterValue', message='Value for one of the query
parameters specified in the request URI is invalid.
RequestId:c13bc6b2-f01e-0020-5acd-b4114e000000
Time:2019-12-17T11:31:17.8460459Z', context='{QueryParameterValue=block,
QueryParameterName=comp, Reason=}'}
{code}
*Observation:* I think with SAS token *blobStore.blobBuilder("test1/5453")*
when we use a path like this format(test1/5453) then it's breaking.
It works when i just use *blobStore.blobBuilder("test1/5453")*
[~gaul] [~himanshujain] [~jira-bot]
> Support for SAS token based Authentication for Azure Blob Storage
> -----------------------------------------------------------------
>
> Key: JCLOUDS-1428
> URL: https://issues.apache.org/jira/browse/JCLOUDS-1428
> Project: jclouds
> Issue Type: Improvement
> Components: jclouds-blobstore
> Reporter: Himanshu Jain
> Assignee: Andrew Gaul
> Priority: Major
> Labels: azureblob
> Fix For: 2.2.0, 2.1.3
>
> Attachments: azure_stacktrace.txt
>
> Time Spent: 1.5h
> Remaining Estimate: 0h
>
> Hi,
> We have one use case where we want to provide limited access to objects in
> our storage accounts. We figured that the best way to do this is by using
> SAS token based authentication mechanism to upload/download objects to Azure
> Blob Storage - [SAS based
> Authentication|https://docs.microsoft.com/en-us/azure/storage/common/storage-dotnet-shared-access-signature-part-1]
> We found that JClouds client library provides support for Azure Blob Storage
> using account keys which might not fit our use case because of security
> reasons.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)