I am currently having a project where I will upload some files in the Blob Container and there are instances that I also want to permanently delete some files but it should be through JavaScript. Are there any ways?
Asked
Active
Viewed 282 times
0

SuperStormer
- 4,997
- 5
- 25
- 35

gwynn causing
- 77
- 6
-
Sure. You will need to use Azure Storage SDK for JavaScript: https://learn.microsoft.com/en-us/azure/storage/blobs/storage-quickstart-blobs-nodejs. – Gaurav Mantri Apr 21 '21 at 02:50
-
Thanks Gaurav Mantri :) The source you have given was very helpful. – gwynn causing Apr 21 '21 at 04:07
1 Answers
1
Try this :
const {
BlobServiceClient
} = require("@azure/storage-blob");
const connectionString = '<storage connection string>'
const container = '<container name>'
const blob = '<blob name>'
const blobClient = BlobServiceClient.fromConnectionString(connectionString).getContainerClient(container).getBlobClient(blob);
blobClient.deleteIfExists().then(result =>{console.log(result._response.status + " blob removed")})
Let me know if you have any more questions.

Stanley Gong
- 11,522
- 1
- 8
- 16