Fork me on GitHub

Microsoft Azure SDK for Node.js - Storage Management

This project provides a Node.js package that makes it easy to manage Microsoft Azure Storage Resources.Right now it supports:

  • Node.js version: 6.x.x or higher

How to Install

npm install azure-arm-storage

A working sample

A sample that can be cloned and is ready to used can be found over here.

How to Use

Authentication, client creation and listing storageAccounts as an example

 var msRestAzure = require('ms-rest-azure');
 var storageManagementClient = require('azure-arm-storage');

 // Interactive Login
 msRestAzure.interactiveLogin(function(err, credentials) {
  var client = new storageManagementClient(credentials, 'your-subscription-id');
  client.storageAccounts.list(function(err, result) {
    if (err) console.log(err);
    console.log(result);
  });
 });

Create the StorageManagementClient

var storageManagementClient = require('azure-arm-storage');
var client = new storageManagementClient(credentials, 'your-subscription-id');

Create a storageAccount

var createParameters = {
  location: 'West US',
  sku: {
    name: 'Standard_LRS'
  },
  kind: 'Storage'
  tags: {
    tag1: 'val1',
    tag2: 'val2'
  }
};
client.storageAccounts.create(groupName, accountName, createParameters, function (err, result, request, response) {
  if (err) {
    console.log(err);
  }
  console.log(result);
});

Get properties of a storageAccount

client.storageAccounts.getProperties(groupName, accountName, function (err, result, request, response) {
  if (err) {
    console.log(err);
  }
  console.log(result);
});

List all the storage accounts in a specific resource group

client.storageAccounts.listByResourceGroup(groupName, function (err, result, request, response) {
  if (err) {
    console.log(err);
  }
  console.log(result);
});

List all the storage accounts in the current subscription

client.storageAccounts.list(function (err, result, request, response) {
  if (err) {
    console.log(err);
  }
  console.log(result);
});

Regenerate the storage account keys of a storage account

client.storageAccounts.regenerateKey(groupName, accountName, 'key1', function (err, result, request, response) {
  if (err) {
    console.log(err);
  }
  console.log(result);
});

Delete a storageAccount

client.storageAccounts.deleteMethod(groupName, accountName, function (err, result, request, response) {
  if (err) {
    console.log(err);
  }
  console.log(result);
});

Related projects