Last active
November 4, 2019 15:39
-
-
Save xl1/aef003d3870c610b8d2afd1826fbad3d to your computer and use it in GitHub Desktop.
Azure Storage: Enqueue messages with blob names
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { BlobServiceClient } from '@azure/storage-blob'; | |
import { QueueServiceClient } from '@azure/storage-queue'; | |
const conn = process.env.StorageConnectionString; | |
const containerName = process.env.StorageContainerName; | |
const queueName = process.env.StorageQueueName; | |
async function main() { | |
const blob = BlobServiceClient.fromConnectionString(conn); | |
const queue = QueueServiceClient.fromConnectionString(conn); | |
const container = blob.getContainerClient(containerName); | |
const queueItem = queue.getQueueClient(queueName); | |
for await (const blob of container.listBlobsFlat()) { | |
console.log(blob.name); | |
const msg = Buffer.from(blob.name).toString('base64'); | |
await queueItem.sendMessage(msg); | |
}; | |
} | |
main().catch(console.error); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment