Coder Social home page Coder Social logo

grunt-azure-cdn-deploy's Introduction

grunt-azure-cdn-deploy

A Grunt plugin for for uploading files to Azure Blob Storage. Wraps a vanilla node package https://github.com/bestander/grunt-azure-cdn-deploy. It is perfect for deploying compiled assets to Microsoft Azure CDN as a last step in a Continuous Integration setup.

Features

  • Ability to execute a "dry run" of deployment. The logging will indicate all files that will be deleted or uploaded but no actual changes to the blob storage will be done
  • Ability to gzip content and set a proper content encoding. If gzipped file becomes larger than original then only the original file will be uploaded
  • Ability to recursively remove files in a path of Azure Blob Storage
  • Ability to control number of concurrent files to be uploaded to avoid network congestion
  • Grunt and gulp plugins available

Installing

npm install grunt-azure-cdn-deploy

Using

Deploying a set of files to a path in blob storage

 grunt.loadNpmTasks('grunt-azure-cdn-deploy');
  grunt.initConfig({
    'azure-cdn-deploy': {
      app: {
        options: {
          containerName: 'test', // container name in blob
          serviceOptions: ['blobstoragename', '/OwQ/MyLongSecretStringFromAzureConfigPanel'], // custom arguments to azure.createBlobService
          folder: '1.2.35-b27', // path within container
          zip: true, // gzip files if they become smaller after zipping, content-encoding header will change if file is zipped
          deleteExistingBlobs: true, // true means recursively deleting anything under folder
          concurrentUploadThreads: 10, // number of concurrent uploads, choose best for your network condition
          metadata: {
            cacheControl: 'public, max-age=31530000', // cache in browser
            cacheControlHeader: 'public, max-age=31530000' // cache in azure CDN. As this data does not change, we set it to 1 year
          },
          testRun: false // test run - means no blobs will be actually deleted or uploaded, see log messages for details
        },
        src: [
          'src/*.{js,json}',
          '*.md',
          '.gitignore'
        ],
        cwd: './node_modules/deploy-azure-cdn'
      }
    }
  });

Debugging

run

grunt azure-cdn-deploy --debug

To see the log of deleted and uploaded files

Parameters

  • deployOptions - azure cdn and upload configs
    • serviceOptions: [] - custom arguments to azure.createBlobService, or you can use Azure SDK environment variables AZURE_STORAGE_ACCOUNT and AZURE_STORAGE_ACCESS_KEY
    • containerName: null - container name, required
    • containerOptions: {publicAccessLevel: "blob"} - container options
    • folder: '', // path within container. Default is root directory of container
    • deleteExistingBlobs: true, // set it to false to skip recursive deleting blobs in folder
    • concurrentUploadThreads : 10, // number of concurrent uploads, choose best for your network condition
    • zip: false, // true if want to gzip the files before uploading. File will be zipped only if compressed file is smaller than original
    • metadata: {cacheControl: 'public, max-age=31556926'} // metadata for each uploaded file
    • testRun: false, // set to true if you just want to check connectivity and see deployment logs. No blobs will be removed or uplaoded.

grunt-azure-cdn-deploy's People

Contributors

bestander avatar alippai avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.