Enabling WP CLI in Azure Websites

WordPress is the most popular CMS on the Web so there are obviously a great set of tools surrounding it to enable the wide variety of developers who build on the WordPress platform. One of such tools is WP CLI which is a command line interface for managing your WordPress site. In this post, I’m going to cover how to install the WP CLI site extension into your Azure Websites hosted WordPress install to enable command line access to your site.

Steps

  1. Install WordPress on Azure
  2. Install WP CLI Site Extension
  3. Command line to WordPress

Install WordPress on Azure

This step is a little bit out of scope for this topic, if you’re savvy enough to know there is a command line tool for WordPress, I’d assume you’d know how it set it up. If for some reason you don’t know, I’m just going to leave these here:

Install WP CLI Site Extension

To add a site extension, you need to login to the Azure Portal and go into your site.

image

If you scroll to the bottom of the site blade, you will find a part called Extensions which on that which will open the Site Extensions blade.

image

Scroll down the list until you find WordPress CLI, click on the item, then accept the license terms. Click OK and the site will begin to install the extension.

Command line to WordPress

Ok great, I have the Site Extension installed but how does that help me? I want to use the command line. There are two different command lines that I want to show off.

Kudu – Debug Console (Web Based)

When you create an Azure Website in the background a second site is created at http://<site-name>.scm.azurewebsites.net which exposes the Kudu Console (Kudu is the deployment engine for Azure Websites). You can access this site using either OAuth (which is enabled by default) or Basic Auth (http://<site-name>.scm.azurewebsites.net/basicauth). It’s cool that you have web based access to your website.

image

KuduExec (Terminal, PowerShell, Command Prompt)

Although it is really cool to be able to use the command line in a web browser, wouldn’t it be nice to be able to use your command line of choice? Well, the team thought so too, and enabled it using Node.js. KuduExec is a command line tool which gives you command line access to your Azure Website.

Screen Shot 2015-01-22 at 2.43.38 PM

To install KuduExec, first you’ll need to install Node. Once you have node and npm installed run the following command.

npm install kuduexec –g

After kuduexec installs you can run it from the command line to login. To use KuduExec, type in kuduexec then the scm endpoint for your site (hint: http://<site-name>.scm.azurewebsites.net) then use your deployment credentials to login.

Then you have full access to your Azure Websites site.

Enjoy!

Comments are closed.