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!

New Windows Azure SDK for PHP Feature: RunPHP (on Windows)

If you are developing PHP on Windows for use on Windows Azure, there is a fancy new feature which may catch your attention. First things first, let’s run through the basics of installing the Windows Azure SDK for PHP in order to set up your environment to get ready for PHP development for Windows Azure.

This new feature is part of the Windows Azure PowerShell and Windows Azure Emulators components which is downloadable through the Web Platform Installer.

Install Windows Azure PowerShell and Windows Azure Emulators for PHP

  1. Open Web Platform Installer via the Windows Azure PowerShell and Windows Azure Emulators deep link.
  2. Click Run.

    image

  3. Accept UAC prompt.

    image

  4. Click Install.

    clip_image001

  5. Click I Accept.

    clip_image001[6]

  6. Go to the kitchen and grab a cup of coffee.

    clip_image001[9]

  7. Click Finish.

    image

How To: Use RunPHP to test a PHP Application on Windows

In order to understand how to use runphp, let’s quickly build a sample PHP application to show off the functionality of runphp.

Now that we have a simple application set up, let’s open a command prompt to use runphp. I will use Windows PowerShell to execute commands, in order to use runphp, PowerShell will need to be run as Administrator.

To run PowerShell as Administrator, right click on the PowerShell icon and select Run as Administrator.

Navigate to the path which contains your application, then execute the command runphp.

image

There are a number of things going on when executing RunPHP, let’s enumerate the high level steps:

  1. Copies an apphost.config file to the current directory
  2. Runs appcmd.exe from IIS Express
    1. Creates a new Website based on the current directory
    2. Configures a HTTP Handler to map *.php files to php-cgi.exe interpreter
  3. Starts IIS Express and binds the website to an open port.

To view and test your website, open a browser visit the localhost address with the appropriate port which the website was bound to during the runphp process.

http://localhost:8080

Once you finish testing, you can shut down IIS Express by opening the PowerShell window and pressing the ‘Q’ key.

Now that you’ve finishing testing your application on your local machine, you can deploy to Windows Azure Web Sites.

Windows Azure Training Kit Update Released – August 2012

Today, My team has released a new drop of the Windows Azure Training Kit, it’s available for download now!

What is the Windows Azure Training Kit?

The Windows Azure Training Kit (WATK) is one of the best ways to learn, practice or teach how to leverage Windows Azure and it’s supporting services.

Official Description

Windows Azure Training Kit includes a comprehensive set of technical content to help you learn how to use Windows Azure.

What’s new in the Windows Azure Training Kit?

This release [August 2012] of WATK includes 41 hands-on labs and 35 presentations.

Hands-on Labs

We have pulled in some changes from our GitHub Repository and addressed a number of bug fixes for our hands-on labs for this release. Feel free to Report Issues if you run across a problem in a hands-on lab or presentation.

Presentations

This release introduces a new agenda for Windows Azure DevCamps which contains 7 new presentations:

  • DevCamps Keynote
  • DevCamps Websites
  • DevCamps Cloud Services
  • DevCamps Virtual Machines
  • DevCamps Data
  • DevCamps Windows 8 + Windows Azure
  • DevCamps Windows Phone + Windows Azure

In addition to the new agenda, the following presentations were added to the foundation agenda:

  • Security & Identity
  • Building Scalable, Global and Highly Available  Web Apps
  • Windows Azure SQL Database
  • Windows Azure SQL Federations
  • Windows Azure Reporting
  • Windows Azure Data Sync

Have any feedback?

I’d love to hear any feedback that you have in regards to our training kit. Please leave a comment below.

Stay Cloudy my Friends…

Workaround for Deleted Folder Still Exists in Windows Azure Web Sites

Depending on how much you’ve been experimenting with your 10 Free Windows Azure Web Site accounts you may come across an issue when deleting then immediately recreating a folder. I noticed this issue when upgrading to the recently refreshed Windows Azure Storage for WordPress Plugin.

WAWS-Deleted-folder-still-exists

 

 

 

 

 

Workaround: Stop/Start your Web Site

In order to work around this, I did a quick Stop/Start on my Windows Azure Web Site. There are a two ways in which you can Stop and Start your Web Site, first, the Windows Azure Management Portal, second, the Cross Platform Command Line Tools.

Stop/Start a Web Site from the Windows Azure Portal

  1. Login to the Windows Azure Management Portal.
  2. Click on Web Sites in the left hand menu.

    image

  3. Select a Web Site from the list.
    image
  4. Click Stop from the bottom control bar.
    image
  5. Click Start from the bottom control bar.
    image

Stop/Start a Web Site from the Cross Platform CLI Tools

  1. Follow the instructions on How to install the Windows Azure Command-Line Tools for Mac or Linux (they work on Windows too!)
  2. Follow the instructions on How to download and import publish settings.
  3. Execute azure site stop 'site-name'.
  4. Execute azure site start 'site-name'.

After Stop/Starting your website you should be able to recreate the folder which was previously deleted.

Happy Clouding!