How to use the @azure/storage-blob.ContainerURL.fromServiceURL function in @azure/storage-blob

To help you get started, we’ve selected a few @azure/storage-blob examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Azure / azure-iot-sdk-node / device / samples / upload_to_blob_v2.js View on Github external
// STORAGE BLOB CODE
  const pipeline = StorageURL.newPipeline(new AnonymousCredential(), {
    retryOptions: { maxTries: 4 },
    telemetry: { value: 'HighLevelSample V1.0.0' }, // Customized telemetry string
    keepAliveOptions: {
      enable: false
    }
  });

  const serviceURL = new ServiceURL(
    `https://${blobInfo.hostName}/${blobInfo.sasToken}`,
    pipeline
  );  

  // initialize the blockBlobURL to a new blob
  const containerURL = ContainerURL.fromServiceURL(serviceURL, blobInfo.containerName);
  const blobURL = BlobURL.fromContainerURL(containerURL, blobInfo.blobName);
  const blockBlobURL = BlockBlobURL.fromBlobURL(blobURL);

  // get file stats
  let fileStats = await getFileStats(localFilePath);

  // parallel uploading
  let uploadStatus = await uploadStreamToBlockBlob(
    Aborter.timeout(30 * 60 * 1000), // Abort uploading with timeout in 30mins
    fs.createReadStream(localFilePath),
    blockBlobURL,
    4 * 1024 * 1024, // 4MB block size
    20, // 20 concurrency
    {
      progress: ev => console.log(ev)
    }
github Azure / azure-iot-sdk-node / device / samples / upload_to_blob_advanced.js View on Github external
// Create a new Pipeline
        const pipeline = StorageURL.newPipeline(new AnonymousCredential(), {
            retryOptions: { maxTries: 4 },
            telemetry: { value: 'HighLevelSample V1.0.0' }, // Customized telemetry string
            keepAliveOptions: {
            enable: false
            }
        });
        const serviceURL = new ServiceURL(
            `https://${blobInfo.hostName}/${blobInfo.sasToken}`,
            pipeline
        );

        // Initialize the blockBlobURL to a new blob
        const containerURL = ContainerURL.fromServiceURL(serviceURL, blobInfo.containerName);
        const blobURL = BlobURL.fromContainerURL(containerURL, blobInfo.blobName);
        const blockBlobURL = BlockBlobURL.fromBlobURL(blobURL);

        // Parallel Uploading
        // We use a to() method to wrap the uploadStreamToBlockBlob so that
        // instead of a try catch we can have it return the err as a result of the operation,
        // similar to the older callback format.
        let err, uploadStatus;
        [err, uploadStatus] = await to(uploadStreamToBlockBlob(
            Aborter.timeout(30 * 60 * 1000), // 30mins
            createReadStream(dummyFilePath),
            blockBlobURL,
            fileSize,
            20,
            {
                progress: ev => console.log(ev)
github microsoft / BotFramework-WebChat / scripts / setJavaScriptContentType.js View on Github external
async function main(accountName, accountKey, container, prefix) {
  const containerURL = ContainerURL.fromServiceURL(
    new ServiceURL(
      `https://${ accountName }.blob.core.windows.net`,
      StorageURL.newPipeline(new SharedKeyCredential(accountName, accountKey))
    ),
    container
  );

  const { segment } = await containerURL.listBlobHierarchySegment(
    Aborter.timeout(BLOB_OPERATION_TIMEOUT),
    BLOB_DELIMITER,
    null,
    { prefix }
  );

  console.log([
    `Found ${ segment.blobItems.length } blob in container "${ container }" with prefix "${ prefix || '' }"`,
github Azure / ng-deploy-azure / src / builders / actions / deploy.ts View on Github external
export async function uploadFilesToAzure(
  serviceURL: ServiceURL,
  context: BuilderContext,
  filesPath: string,
  files: string[]
): Promise {
  context.logger.info('preparing static deploy');
  const containerURL = ContainerURL.fromServiceURL(serviceURL, '$web');

  const bar = new ProgressBar('[:bar] :current/:total files uploaded | :percent done | :elapseds | eta: :etas', {
    total: files.length
  });

  bar.tick(0);

  await promiseLimit(5).map(files, async function(file: string) {
    const blobURL = BlobURL.fromContainerURL(containerURL, file);
    const blockBlobURL = BlockBlobURL.fromBlobURL(blobURL);

    const blobContentType = lookup(file) || '';
    const blobContentEncoding = charset(blobContentType) || '';

    await uploadStreamToBlockBlob(
      Aborter.timeout(30 * 60 * 60 * 1000),
github Azure-Samples / azure-storage-js-v10-quickstart / v10 / index.js View on Github external
async function execute() {

    const containerName = "demo";
    const blobName = "quickstart.txt";
    const content = "Hello Node SDK";
    const localFilePath = "../readme.md";

    const credentials = new SharedKeyCredential(STORAGE_ACCOUNT_NAME, ACCOUNT_ACCESS_KEY);
    const pipeline = StorageURL.newPipeline(credentials);
    const serviceURL = new ServiceURL(`https://${STORAGE_ACCOUNT_NAME}.blob.core.windows.net`, pipeline);
    
    const containerURL = ContainerURL.fromServiceURL(serviceURL, containerName);
    const blockBlobURL = BlockBlobURL.fromContainerURL(containerURL, blobName);
    
    const aborter = Aborter.timeout(30 * ONE_MINUTE);

    await containerURL.create(aborter);
    console.log(`Container: "${containerName}" is created`);

    console.log("Containers:");
    await showContainerNames(aborter, serviceURL);

    await blockBlobURL.upload(aborter, content, content.length);
    console.log(`Blob "${blobName}" is uploaded`);
    
    await uploadLocalFile(aborter, containerURL, localFilePath);
    console.log(`Local file "${localFilePath}" is uploaded`);
github microsoft / VoTT / src / providers / storage / azureBlobStorage.ts View on Github external
private getContainerURL(serviceURL?: ServiceURL, containerName?: string): ContainerURL {
        return ContainerURL.fromServiceURL(
            (serviceURL) ? serviceURL : this.getServiceURL(),
            (containerName) ? containerName : this.options.containerName,
        );
    }
github serverless / multicloud / azure / src / services / azureBlobStorage.ts View on Github external
public async read(opts: ReadBlobOptions): Promise {
    const containerURL = ContainerURL.fromServiceURL(this.service, opts.container);
    const blobURL = BlobURL.fromContainerURL(containerURL, opts.path);

    const stream = await blobURL.download(Aborter.none, 0)
    return stream.readableStreamBody
  }
}
github serverless / serverless-azure-functions / src / services / azureBlobStorageService.ts View on Github external
private getContainerURL(containerName: string): ContainerURL {
    Guard.empty(containerName, "containerName");
    this.checkInitialization();

    return ContainerURL.fromServiceURL(
      this.getServiceURL(),
      containerName
    );
  }