0
votes

I’m using azure function with node js to create a zip file(abc.zip) with some files in function app temp folder and on the next step I need to upload the zip file in azure blob storage. Problem is the blob storage path has to be something like ‘/xyz/pqr/ghk’. How to achieve this?

1
Just prepend the folder path to the blob name. For example, if you want to upload abc.zip in xyz/pqr folder, just change the name of the blob to xyz/pqr/abc.zip.Gaurav Mantri
in azure blob storage the folder structure is virtual so you can give path as you want . Eg /xyz/pqr/ghk/test.zip => will create folder inside a folder and then it will add test.zipRahul Shukla

1 Answers

0
votes

As @GauravMantri indicated,Try this :

const {
    BlobServiceClient
  } = require("@azure/storage-blob");

  const connectionString = ''
  const container = ''
  const destBlobName = 'test.zip'
  const blob = 'xyz/pqr/ghk/' + destBlobName

  const zipFilePath = "<some function temp path>/<filename>.zip"

  const blobClient = BlobServiceClient.fromConnectionString(connectionString).getContainerClient(container).getBlockBlobClient(blob)
  blobClient.uploadFile(zipFilePath)

Result: enter image description here

Let me know if you have any more questions :)