Skip to content

Instantly share code, notes, and snippets.

@xl1
Last active November 4, 2019 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xl1/aef003d3870c610b8d2afd1826fbad3d to your computer and use it in GitHub Desktop.
Save xl1/aef003d3870c610b8d2afd1826fbad3d to your computer and use it in GitHub Desktop.
Azure Storage: Enqueue messages with blob names
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