Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export async function main() {
// Enter your storage account name and shared key
const account = process.env.ACCOUNT_NAME || "";
const accountKey = process.env.ACCOUNT_KEY || "";
// Use StorageSharedKeyCredential with storage account and account key
// StorageSharedKeyCredential is only avaiable in Node.js runtime, not in browsers
const sharedKeyCredential = new StorageSharedKeyCredential(account, accountKey);
// Create a container
const containerName = `newcontainer${new Date().getTime()}`;
const containerClient = new ContainerClient(
`https://${account}.blob.core.windows.net/${containerName}`,
sharedKeyCredential
);
const createContainerResponse = await containerClient.create();
console.log(`Created container ${containerName} successfully`, createContainerResponse.requestId);
const numberOfBlobs = 7;
for (let i = 0; i < numberOfBlobs; i++) {
// Create a blob
const content = "hello";
const blobName = "newblob" + new Date().getTime();
const blockBlobClient = containerClient.getBlockBlobClient(blobName);
const uploadBlobResponse = await blockBlobClient.upload(content, content.length);
console.log(`Uploaded block blob ${blobName} successfully`, uploadBlobResponse.requestId);
}
async function main() {
// Enter your storage account name and shared key
const account = process.env.ACCOUNT_NAME || "";
const accountKey = process.env.ACCOUNT_KEY || "";
// Use StorageSharedKeyCredential with storage account and account key
// StorageSharedKeyCredential is only avaiable in Node.js runtime, not in browsers
const sharedKeyCredential = new StorageSharedKeyCredential(account, accountKey);
// Create a container
const containerName = `newcontainer${new Date().getTime()}`;
const containerClient = new ContainerClient(
`https://${account}.blob.core.windows.net/${containerName}`,
sharedKeyCredential
);
const createContainerResponse = await containerClient.create();
console.log(`Created container ${containerName} successfully`, createContainerResponse.requestId);
for (let index = 0; index < 7; index++) {
// Create a blob
const content = "hello";
const blobName = "newblob" + new Date().getTime();
const blockBlobClient = containerClient.getBlockBlobClient(blobName);
const uploadBlobResponse = await blockBlobClient.upload(content, content.length);
console.log(`Uploaded block blob ${blobName} successfully`, uploadBlobResponse.requestId);
}
export async function main() {
// Enter your storage account name and shared key
const account = process.env.ACCOUNT_NAME || "";
const accountKey = process.env.ACCOUNT_KEY || "";
// Use StorageSharedKeyCredential with storage account and account key
// StorageSharedKeyCredential is only avaiable in Node.js runtime, not in browsers
const sharedKeyCredential = new StorageSharedKeyCredential(account, accountKey);
// Create a container
const containerName = `newcontainer${new Date().getTime()}`;
const containerClient = new ContainerClient(
`https://${account}.blob.core.windows.net/${containerName}`,
sharedKeyCredential
);
const createContainerResponse = await containerClient.create();
console.log(`Created container ${containerName} successfully`, createContainerResponse.requestId);
for (let index = 0; index < 7; index++) {
// Create a blob
const content = "hello";
const blobName = "newblob" + new Date().getTime();
const blockBlobClient = containerClient.getBlockBlobClient(blobName);
const uploadBlobResponse = await blockBlobClient.upload(content, content.length);
console.log(`Uploaded block blob ${blobName} successfully`, uploadBlobResponse.requestId);
}
async function main() {
const consumerClient = new EventHubConsumerClient(connectionString, eventHubName);
const containerClient = new ContainerClient(storageConnectionString, containerName);
await containerClient.create();
const processEvents = async (events: ReceivedEventData[], context: PartitionContext & PartitionCheckpointer) => {
// events can be empty if no events were recevied in the last 60 seconds.
// This interval can be configured when creating the EventProcessor
if (events.length === 0) {
return;
}
for (const event of events) {
console.log(
`Received event: '${event.body}' from partition: '${context.partitionId}' and consumer group: '${context.consumerGroupName}'`
);
}
// checkpoint using the last event in the batch
async function main() {
// Enter your storage account name and shared key
const account = process.env.ACCOUNT_NAME || "";
const accountKey = process.env.ACCOUNT_KEY || "";
// Use StorageSharedKeyCredential with storage account and account key
// StorageSharedKeyCredential is only avaiable in Node.js runtime, not in browsers
const sharedKeyCredential = new StorageSharedKeyCredential(account, accountKey);
// Create a container
const containerName = `newcontainer${new Date().getTime()}`;
const containerClient = new ContainerClient(
`https://${account}.blob.core.windows.net/${containerName}`,
sharedKeyCredential
);
const createContainerResponse = await containerClient.create();
console.log(`Created container ${containerName} successfully`, createContainerResponse.requestId);
// create some blobs with delimiters in names
const content = "hello";
let blobName = "a1";
let blockBlobClient = containerClient.getBlockBlobClient(blobName);
let uploadBlobResponse = await blockBlobClient.upload(content, content.length);
console.log(`Uploaded block blob ${blobName} successfully`, uploadBlobResponse.requestId);
blobName = "a2";
blockBlobClient = containerClient.getBlockBlobClient(blobName);
export async function main() {
// Enter your storage account name and shared key
const account = process.env.ACCOUNT_NAME || "";
const accountKey = process.env.ACCOUNT_KEY || "";
// Use StorageSharedKeyCredential with storage account and account key
// StorageSharedKeyCredential is only avaiable in Node.js runtime, not in browsers
const sharedKeyCredential = new StorageSharedKeyCredential(account, accountKey);
// Create a container
const containerName = `newcontainer${new Date().getTime()}`;
const containerClient = new ContainerClient(
`https://${account}.blob.core.windows.net/${containerName}`,
sharedKeyCredential
);
const createContainerResponse = await containerClient.create();
console.log(`Created container ${containerName} successfully`, createContainerResponse.requestId);
// create some blobs with delimiters in names
const content = "hello";
let blobName = "a1";
let blockBlobClient = containerClient.getBlockBlobClient(blobName);
let uploadBlobResponse = await blockBlobClient.upload(content, content.length);
console.log(`Uploaded block blob ${blobName} successfully`, uploadBlobResponse.requestId);
blobName = "a2";
blockBlobClient = containerClient.getBlockBlobClient(blobName);