kudu-api
Node wrapper for the Kudu REST API.
Install
npm install kudu-api
Or from GitHub:
git clone git@github.com:itsananderson/kudu-api.git
cd kudu-api
npm install
Usage
Instantiating
var kudu = website: "website" username: "$username" password: "password";
kudu.scm
Source Control kuduscm; // Runs 'git clean -xdff' on the repositorykuduscm); // Deletes the Git repositorykuduscm);
kudu.command
Run commands kuducommand; // Leaving out the directory will default to D:\homekuducommand;
kudu.vfs
Virtual File System kuduvfs; kuduvfs; // By default, uploadFile uploads with `If-Match` set to "*", overwriting any existing filekuduvfs; // You can provide an etag so that the file is only uploaded if the old version's etag matches// If the version doesn't match, "err" will contain a JSON object containing the error messagekuduvfs; kuduvfs; kuduvfs; kuduvfs;
kudu.zip
Zip // Zips a folder on the server and downloads it to the local pathkuduzip; // Uploads a zip from the local machine and unzips it into the destination path// The destination path must existkuduzip;
kudu.deployment
Deployment kududeployment
kudu.sshkey
SSH Key // Acquires the public key used for deploymentskudusshkey // You can have Kudu generate a key if none existskudusshkey;
kudu.environment
Kudu Environment // Get some basic information about the Kudu environmentkuduenvironment;
kudu.settings
Settings kudusettings; kudusettings; kudusettings; kudusettings;
kudu.dump
Diagnostics Dump // Downloads all the diagnostic logs as a zip filekududump;
kudu.diagnostics
Diagnostics Settings kududiagnostics; kududiagnostics; // This is a no-op on the pre-defined diagnostics settings// But if you accidentally define non-standard fields, they can be deletedkududiagnostics; kududiagnostics;
kudu.logs
Diagnostic Logs // Returns most recent 100 logs by defaultkudulogs; // Can query for up to 1000 most recent logskudulogs;
kudu.extensions
Site Extensions kuduextensionsfeed; // You can filter the list by passing in a stringkuduextensionsfeed; // Or retrieve a specific extension by IDkuduextensionsfeed; // You can also list/filter/get currently installed extensionskuduextensionssite;kuduextensionssite;kuduextensionssite; // You can delete an installed extensionkuduextensionssite; // Enable or update an extension by passing its full objectkuduextensionsfeed;
kudu.webjobs
WebJobs Wrappers for the Kudu WebJobs API.
// List all jobskuduwebjobs; // List triggered jobskuduwebjobs; // List triggered jobs in Swagger formatkuduwebjobs; // Get a triggered job by namekuduwebjobs; // Upload a triggered job with the specified name and filekuduwebjobs; // Delete a triggered jobkuduwebjobs; // Run a triggered jobkuduwebjobs; // Run a triggered job with argumentskuduwebjobs; // List the history of a triggered job by namekuduwebjobs; // Get a single triggered job history item by name and idkuduwebjobs; // List continuous jobskuduwebjobs; // Get a continuous jobkuduwebjobs; // Upload a continuous job with the specified name and filekuduwebjobs; // Delete a continuous job by namekuduwebjobs; // Start a continuous job by namekuduwebjobs; // Stop a continuous job by namekuduwebjobs; // Get settings for a continuous job by namekuduwebjobs; // Set settings for a continuous job by namekuduwebjobs;
Misc Usage Notes
All callbacks receive a response object as their final argument.
You can use it if you need to check a response.statusCode
from the server, or (in the case of the vfs
api) get response.headers.etag
.
Testing
Tests can be run with mocha
or npm test
The tests are pretty sparse right now, but they should at least attempt to hit all the endpoints.
Because the tests integrate against a Azure Kudu api, you'll need to configure the following environment variables to point them at an Azure website.
WEBSITE
: The name of the Azure website.USERNAME
: The Azure Deployment Credentials user.PASSWORD
: The Azure Deployment Credentials password.
For my setup, I have a simple script that I use to set these variables and run the tests:
WEBSITE=foo USERNAME='$foo' PASSWORD=12345fake npm test -- $1
I have the $1
so I can run ./mocha test/scm.js
to only run part of the tests.
You can also just configure these environment variables globally if you wish. Steps for doing this depend on your operating system.