Giter Site home page Giter Site logo

stefangordon / azure-storage-gzip-encoding Goto Github PK

View Code? Open in Web Editor NEW
26.0 3.0 11.0 15 KB

A utility to facilitate configuring Azure Blob storage to return gzip compressed HTTP responses directly, or through Azure CDN.

License: MIT License

C# 100.00%

azure-storage-gzip-encoding's Introduction

Build status

Azure Storage GZip Encoding

A utility to automatically configure HTTP Compression for blobs in Azure Blob storage. Blobs can be consumed directly from a client browser or via Azure CDN.

This tool is inspired by a code sample from David Rousset for optimizing BablyonJS Assets.

Why

Azure storage is an excellent option for storing assets and data consumed by web applications, but it is often preferable to have this data delivered to the browser compressed. Azure CDN can be used to provide compression and performance improvements on top of blob storage but has an upper limit of 1MB for HTTP compression.

Azure Blob Storage is capable of delivering the correct content-encoding: gzip headers directly, but data must be compressed in storage, and the headers must be configured correctly. Then this content is delivered compressed either directly or through CDN.

Managing this manual compression and configuration of headers yourself would be tedious, but this tool can be run to do it for you, and happily ignores files that are already compressed. You can run it automatically as part of a build process, or manually on an as-needed basis.

What it does

The utility can enumerate all of the files in a container. It then filters to files matching your provided extensions. These files are compressed using GZip and the content-encoding and cache headers are configured on them so they are compatible with all browsers HTTP compression features. The tool will not alter a file which is already compressed (based on inspecting the headers), so it is safe to run multiple times to catch new files.

The utility can also automatically configure your storage account with wildcard CORS settings which are often desirable if serving certain types of assets through Azure CDN.

Getting Started

You must provide

  • Either an account name and key, or connection string
  • Container to enumerate (recursively)
  • List of file extensions to operate on
  • Whether to replace existing files with compressed version, or copy with a new extension

Examples

Replacing .css files in-place. Blobs will be replaced with compressed version and headers updated: asge.exe -e .css -f myContainer -r -a myStorageAccount -k <key>

Copy .css and .js to a compressed version and append a .gz extension: asge.exe -e .css .js -f myContainer -n .gz -a myStorageAccount -k <key>

Replacing .js files in-place and enabling CORS for the account: asge.exe -w -e .js -f myContainer -r -a myStorageAccount -k <key>

Replacing .js files in-place using a connection string instead of host/key: asge.exe -e .js -f myContainer -r -c <connection string>

  -a, --account             Storage account host. [mystorage]

  -k, --key                 Storage account key.

  -c, --connectionstring    Storage account key.

  -e, --extensions          Required. Extensions to operate on. [.js, .css,
                            .dat]

  -r, --replace             (Default: False) Replace existing files in-place.

  -s, --simulate            (Default: False) Do everything except write to blob
                            store.

  -n, --newextension        Copy file with a new postfix. [.gz]

  -f, --container           Required. Container to search in.

  -w, --wildcardcors        Enable wildcard CORS for this storage account.

  -x, --cacheage            (Default: 2592000) Duration for cache control max
                            age header, in seconds.  Default 2592000 (30 days).

  --help                    Display this help screen.

Current State

Only block blobs are supported. Please ensure you have a backup of your data before running this tool against your container.

azure-storage-gzip-encoding's People

Contributors

stefangordon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

azure-storage-gzip-encoding's Issues

Convert this project to .net core console application

Thanks for this wonderful tool. Can you please convert this project to .net core console application so that it becomes portable and can be used on Mac and Linux as well. Most people use Jenkins pipeline in Linux and they want to use this tool as a part of their pipeline. Having a Linux binary will allow people to use it in Linux as well.

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.