question

LauraM-9394 avatar image
0 Votes"
LauraM-9394 asked LauraM-9394 commented

[Azure storage] Not possible to make blob copy

Hello the community,

I have been looking for this since several days now, but I have no idea why i cannot make a simple Blob copy through my main program.
Hope this post will allow to resolve this issue, and help others too.

I am using azure-storage-blob version 12.10.2 in my Java project.

Here is the main program which detects the incoming file in the Azure blob storage and triggers the program :

    @FunctionName("Importer_QueueTrigger")
     @StorageAccount("AzureWebJobsStorage")
     public void queueHandler(
             @QueueTrigger(name = "message", queueName = "%AzureQueueName%", connection = "AzureWebJobsStorage") String message,
             @BindingName("DequeueCount") int dequeueNumber,
             final ExecutionContext context) {
    
  JsonObject jsonObject = new JsonParser().parse(message).getAsJsonObject();
         String subject = jsonObject.get("subject").getAsString();
         Path fileName = Paths.get(subject);
         String blobFileName = fileName.getFileName().toString();
    
         String accountKey="XXXXXXXXXX";
         String accountName="XXXXXXXXXX";
         String endPoint = "https://<domain>.blob.core.windows.net/";
         String sourceContainerName="workitems";
         String newBlobName="file_2_copied.xml";
    
         StorageSharedKeyCredential key = new StorageSharedKeyCredential(accountName, accountKey);
         BlobServiceClient blobServiceClient = new BlobServiceClientBuilder()
                 .credential(key)
                 .endpoint(endPoint)
                 .buildClient();
    
         BlobContainerClient sourceContainer = blobServiceClient.getBlobContainerClient(sourceContainerName);
         BlobContainerClient targetContainer = blobServiceClient.getBlobContainerClient(sourceContainerName);
         BlobClient sourceClient = sourceContainer.getBlobClient(name);
         BlobClient targetClient = targetContainer.getBlobClient(newBlobName);
    
         BlobSasPermission permissions = new BlobSasPermission();
         permissions.setReadPermission(Boolean.TRUE);
         BlobServiceSasSignatureValues signatureValues = new BlobServiceSasSignatureValues(OffsetDateTime.now().plusDays(1), permissions);
         String token = sourceClient.generateSas(signatureValues);
    
         BlobCopyFromUrlOptions options = new BlobCopyFromUrlOptions(sourceClient.getBlobUrl() + "?" + token);
         Response<String> res = targetClient.copyFromUrlWithResponse(options, Duration.ofDays(1), Context.NONE);
     }

This code is working fine in unit tests, but it looks blocked in the main program.
It seems there is a blocking thread, but i don't know why.

When i debug the main program and i'm stopped on the line to make the blob copy, if i run my unit test to copy the blob, the unit test is well executed. I don't know why the main thread is blocked.
I have tried several things with no result.

Have you any idea to help me on this point ?

Laura.


azure-blob-storage
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Any help ?

0 Votes 0 ·

@LauraM-9394 Firstly, apologies for the delay in responding here and any inconvenience this issue may have caused. I am looking into this thread, I will get back you with concert update

0 Votes 0 ·

@LauraM-9394 Are you aware of any differences in your test mode and live mode environments? Do you have any logging enabled that you can capture and share with us? Or any network traces?

0 Votes 0 ·

0 Answers