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 🙏

© 2024 – Pkg Stats / Ryan Hefner

azure-api

v0.0.32

Published

A really simple promise-based NodeJS API for creation and configuration of Azure resources.

Downloads

44

Readme

azure-api

A really simple promise-based NodeJS API for creation and configuration of Azure resources.

You must have azure-cli installed and authenticated to use this.

This API is used in my MEAN stack provisioning script. It's a good example of how to use this.

Todo (please join the effort!):

  • Support for certificates/keys.
  • Functions to delete networks and VMs.

To install:

npm install --save azure-api

Then in your NodeJS script:

var config = {
	verbose: true
};
var azure = require('azure-api')(config);

To create a network:

var networkName = "somenetwork";
var location = "Australia East";

azure.createNetwork(networkName, location)
	.then(function () {
		// network was created sucessfully.
	})
	.catch(function (err) {
		// some error occurred.
	}); 

To create a VM:

var vm = {
	name: "somevm",
	networkName: "somenetwork",
	imageName: "b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu_DAILY_BUILD-trusty-14_04_2-LTS-amd64-server-20150708-en-us-30GB",
	user: "username", // User name for the VM.
	pass: "password", // Password for the VM.
	endpoints: ... list of end points ...
};

azure.createVM(vm)
	.then(function () {
		// VM was created sucessfully.
	})
	.catch(function (err) {
		// some error occurred.
	}); 

End points are specified as follows:

var endpoints = [
	{
		name: 'HTTP',
		externalPort: 80,
		internalPort: 3000,						
	},
	// etc, etc
],

To run a provisioning shell script on the remote machine:

var host = "somevm.cloudapp.net";
var user = "username";
var pass = "password";
var scriptFile = "provision.sh"; // The named script must exist on the local machine.

azure.runSshScript(host, user, pass, scriptFile)
	.then(function () {
		// the script completed successfully.
	})
	.catch(function (err) {
		// some error occurred.
	});

You can also call a function that waits for you VM to have started:

var vmName = "somevm";

azure.waitVmRunning(vmName)
	.then(function () {
		// vm has started.
	})
	.catch(function (err) {
		// some error occurred.
	});

The end result is you can wire all these functions together to provision your cloud:

var networkName = "somenetwork";
var location = "Australia East";
var host = vmName + ".cloudapp.net";

var vm = {
	name: "somevm",
	networkName: networkName,
	imageName: "b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu_DAILY_BUILD-trusty-14_04_2-LTS-amd64-server-20150708-en-us-30GB",
	user: "username", // User name for the VM.
	pass: "password", // Password for the VM.
	endpoints: ... list of end points ...
};

var provisionScriptFile = "provision.sh";

azure.createNetwork(networkName, location)
	.then(function () {
		return azure.createVM(vm);
	})
	.then(function () {
		return azure.waitVmRunning(vm.name);
	})
	.then(function () {
		return azure.runSshScript(host, vm.user, vm.pass, provisionScriptFile)
	})
	.then(function () {
		// provisioning completed successfully.
	})
	.catch(function (err) {
		// some error occurred.
	}); 

Or you could just call provisionVM:

var networkName = "somenetwork";
var location = "Australia East";

var vm = {
	name: "somevm",
	networkName: networkName,
	imageName: "b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu_DAILY_BUILD-trusty-14_04_2-LTS-amd64-server-20150708-en-us-30GB",
	user: "username", // User name for the VM.
	pass: "password", // Password for the VM.
	endpoints: ... list of end points ...
	provisionScript: "provision.sh",
};

var provisionScriptFile = "provision.sh";

azure.createNetwork(networkName, location)
	.then(function () {
		return azure.provisionVM(vm);
	})
	.then(function () {
		// provisioning completed successfully.
	})
	.catch(function (err) {
		// some error occurred.
	}); 

Have fun! Thanks for coming to the party.