1

I have requirement where in azure blob storage suppose A , I have a folder structure as below

CNS -> master -> 123-456 -> cm -> Inside cm multiple files and folder are present.

I need to get all the files and folder from cm folder , zip and upload to blob storage B.

Can any one provide best solution how I can perform this using java script only.

Thanks in advance

Satish Bhuria
  • 81
  • 2
  • 13
  • 1
    Please edit your question and include: 1) Is it for File Storage or Blob Storage and 2) What you have tried so far? Show us some code that you have written and the issues you're running into. Lastly, why tag `azure-functions`? – Gaurav Mantri Nov 06 '17 at 08:52
  • I haven't try much on this. I didn't find anything on this. Azure time trigger function I am using that is why it is tagged. And it is a blob storage – Satish Bhuria Nov 06 '17 at 10:12
  • 1
    You have to try something. Let me make this somewhat easier for you by breaking your requirements in following tasks: 1) First you list the blobs. 2) You download the blobs. 3) You zip the downloaded files and 4) You upload the zip file. I suggest you use Node SDK for Azure to do 1, 2, and 4. For 3, you will need to find a Nod package that will zip the files for you. HTH. – Gaurav Mantri Nov 06 '17 at 10:48

1 Answers1

2

See this documentation for how to create a timer-triggered function in node.js which runs every hour: https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-timer

Example function.json file content:

{
  "bindings": [
    {
        "schedule": "0 0 * * * *",
        "name": "myTimer",
        "type": "timerTrigger",
        "direction": "in"
    }
  ],
  "disabled": false
}

As for how to use blob storage APIs from JavaScript, see the following documentation: https://learn.microsoft.com/en-us/azure/storage/blobs/storage-nodejs-how-to-use-blob-storage.

In particular, the following topics seem relevant to what you're trying to accomplish:

As for how to do the file zipping, there is a related topic in another StackOverflow post here: Zip archives in node.js.

Chris Gillum
  • 14,526
  • 5
  • 48
  • 61
  • But it seems the approach is very time consuming , I was searching for approach that would be better in performance because there are multiple files and folders needs to be zipped not only once but for different instances. – Satish Bhuria Nov 07 '17 at 04:43