npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

grunt-azureblob

v0.1.2

Published

grunt task to copy html assets to azure blob/cdn storage

Readme

grunt-azureblob

Grunt [task] 1 for copying html assets to azure blob/cdn storage.

Installation

Install npm package next to your projects gruntfile.js file

npm install grunt-azureblob

Add this line to your projects gruntfile.js

grunt.loadNpmTasks('grunt-azureblob');

Environment Requirment

  • Azure SDK provides Node.js package for access to Azure Table Storage. By default, this library uses the following environment variables for authentication (set as required as global, user, or with a task). I've had great success with grunt-env to manage the these settings as a task (sample usage shown below). These environment variables must be set to your appropriate values!
    • AZURE_STORAGE_ACCOUNT
    • AZURE_STORAGE_ACCESS_KEY

AzureBlob Options and default values

grunt-azureblob is a multi task that implicity iterates over all of its name sub-properties (targets). In addition to the default properties , task specific properties are also available inside each task function. Options are essentially available globaly (across tasks), but can be overridden / set at each task level as needed.

{
  serviceOptions: [], // custom arguments to azure.createBlobService
  containerName: null, // container name, required
  containerDelete: false, // deletes container if it exists
  containerOptions: {publicAccessLevel: "blob", timeoutIntervalInMs: 10000}, // container options
  copySimulation: false, // do everything but physically touch storage blob when true
  destPrefix: '', // prefix to use for blob name e.g. 'v0.0.1/'
  maskBaseDir: '',  // mask off directory portion to map files to root in storage container
  metadata: {cacheControl: 'public, max-age=31556926'}, // file metadata properties
  gzip: false // gzip files (when true: only js / css will be gzip'd)
};

Example gruntfile.js

module.exports = function(grunt) {
  grunt.initConfig({
    pkg: grunt.file.readJSON('insight-spa.jquery.json'),
    env : {
      options : {
       //Shared Options Hash
      },
      configCDN : {
        AZURE_STORAGE_ACCOUNT : 'azure storage account name to use',
        AZURE_STORAGE_ACCESS_KEY : 'your-ssh-access-key-string would go here'
      }
    },
    'azureblob': {
      options: {
        containerName: 'assets',
        containerDelete: false,
        metadata: {cacheControl: 'public, max-age=31556926'}, // max-age 1 year for all entries
        gzip: true,
        copySimulation: true,  // set true: dry-run for what copy would look like in output
        destPrefix: '<%= pkg.version %>/'
      },
      css :{
        options: {
          maskBaseDir: '../web/Content/'  // strip off this prefix from files
        },
        src: ['../web/Content/**/*','!../web/Content/themes/**/*'] // copy all files from Content (exclude themes dir)
      },
      js :{
        options: {
          containerDelete: false,
          maskBaseDir: '../web/scripts/'
        },
        src: ['../web/scripts/vendor*.js']
      }
    }
  });

  // Load the plugin that provides all the pirate magic
  grunt.loadNpmTasks('grunt-env'); // https://npmjs.org/package/grunt-env
  grunt.loadNpmTasks('grunt-azureblob');
  // Default task(s).
  grunt.registerTask('blob', ['env:configCDN', 'azureblob']); 
  
  grunt.event.on('qunit.spawn', function (url) {
  grunt.log.ok("Running test: " + url);
});
grunt.event.on('qunit.moduleStart', function (name) {
  grunt.log.ok("Starting module: " + name);
});

Sample console run (from sample/build/gruntfile.js)

c:\sample>grunt blob  

Running "env:configCDN" (env) task

Running "azureblob:css" (azureblob) task
azureblob:css - Create blob containter [assets] ...OK
        Copy index.css => assets/0.2.1/index.css >> skip copy ok
        Copy jquery.ui.all.css => assets/0.2.1/themes/jquery.ui.all.css >> skip copy ok
blobStorage copy completed (2) files...OK

Running "azureblob:js" (azureblob) task
azureblob:js - Create blob containter [assets] ...OK
        Copy amplify.min.js => assets/0.2.1/amplify.min.js >> skip copy ok
        Copy knockout-2.2.1.js => assets/0.2.1/knockout-2.2.1.js >> skip copy ok
        Copy q.min.js => assets/0.2.1/q.min.js >> skip copy ok
blobStorage copy completed (3) files...OK

Done, without errors.

Release History

  • 2013-04-19   v0.0.1  Initial release
  • 2013-05-07   v0.0.2  Release to npm

Optional Ideas (specifically for .net web projects)

  • [Sample] 2 for .net web projects (SPA) to use BLOB/CDN based on version in project.json file

Mentions

Thanks to litek/grunt-azure-storage for inspiration and my first experience with grunt and azure storage.