node.jsazurecompoundjs

Upload blob to windows azure container using NodeJS (CompoundJS)


I am using CompoundJS for my application and now trying to implement a script which would upload images to azure blob from compoundjs.

I searched web and found that there is a module azure (npm install azure) as specified in this link.

Below is the code snippet i used in my application

var azure = require("azure");
var blobService = azure.createBlobService();
blobService.createContainerIfNotExists('container_name', {publicAccessLevel : 'blob'}, function(error){
    if(!error){
        // Container exists and is public
        console.log("Container Exists");
    }
});

I am aware that i should configure ACCESS KEY some where to make this work, but not sure where.

Please suggest.


Solution

  • You would need to provide your account name/key like this:

    var blobService = azure.createBlobService('accountname', 'accountkey');
    

    You can look at the source code here: https://github.com/WindowsAzure/azure-sdk-for-node/blob/master/lib/azure.js.