nemesis88
nemesis88

Reputation: 13

Upload zip from local in azure blob subcontainer

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?

Upvotes: 1

Views: 3526

Answers (1)

Stanley Gong
Stanley Gong

Reputation: 12153

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 :)

Upvotes: 1

Related Questions