Running Drush on Windows Azure Websites

Drush is a shell-based application used to control, manipulate, and administer Drupal sites. On the surface, drush is an excellent tool for updating site modules and managing your Drupal website. In this article you will learn,

  1. How to setup Drush on WAWS website running Drupal
  2. How to manage your Drupal site using Drush

Setup Drush on WAWS website running Drupal

First you need to download Drush  and use composer to update all the dependencies for Drush . Access your site through FTP and create a new folder “Drush” under your website root (D:\home\site\wwwroot ).Now upload all the files from local copy of the Drush to your website folder site\wwwroot\drush .

Access your Kudu site , enter the URL similar to https://your-sitename.scm.azurewebsites.net/  and select Debug Console à CMD . To learn more about Kudu , check out this article. In the debug console, move to the Drush folder under your site root folder and run the command drush status to see if Drush is working

The Warning error message occurs if you are using older versions of Drush tool. To avoid this Warning message, create an environment variable called COLUMNS and set its value to 80 on your website dashboard in the Azure Management portal Now rerun drush status command in the debug console and the Warning should have disappeared.  

Now you are all set to use Drush command line tool to manage you Drupal site on WAWS. For a list of available commands either visit http://drush.ws or type drush help.For a printable version use drush help –html

Managing a site from the command line using Drush

Here are some common operations you can run to manage your site

  1. To update only Drupal core (in case of a security update)

    drush pm-update drupal

  1. To clear cache for a specific module or overall cache

    drush cache-clear

  1. Set the default theme for your site

    drush vset theme_default theme_name

  2. Show status command for the your website if you are using Drupal multi-site solution

    drush –uri=http://example.com status

  3. Get all the release information of a module , say backup_migrate

    drush pm-releases backup_migrate

  4. To update an existing drupal module

    drush pm-update <modulename>

  5. Backup your site

    drush archive-dump –-destination=<destination path>   Example: drush archive-dump –-destination=D:\home\site\drupal-backup\files.tar.gz   If you want to exclude .git directory, try: drush archive-dump –-destination= D:\home\site\drupal-backup\files.tar.gz –tar-options=”–exclude=.git”

  6. To restore the backup file, use:

    drush archive-restore D:\home\site\drupal-backup\files.tar.gz   REMEMBER: You have to first navigate to the location where you want to extract the backup file.

  7. To enable a module

    drush en <modulename>   Example: To enable content module, run drush en content

  8. Create a new user for Drupal website

    drush user-create newuser –mail=”person@example.com” -password=”letmein”

Limitations:

  1. You cannot run commands that allow you to edit a file in the console, such as drush core-config. In such situations you can use download the file using GIT, FTP and edit the file in question

Additional references

Drush Cheatsheet Drush Commands and Examples

Advertisements

6 thoughts on “Running Drush on Windows Azure Websites

  1. Could you give me some more info on doing this part
    “First you need to download Drush and use composer to update all the dependencies for Drush”

    In particular using the composer to update dependencies.

    thanks,

  2. Thanks for your information setting up Drush on Azure Websites. I recently set this up on my Azure Website and some of your Drush command examples are failing to run successfully.

    Could you confirm if you were able to successfully backup and update Drupal using: drush pm-update drupal. In your example above the command returned “No code updates available.” When I run this command there are updates available both for core Drupal and my installed modules, but running this fails to create a directory. If I exclude backups, the process continues but again fails when trying to install module updates.

  3. Thanks for the tutorial! I followed the steps and Drush status works on my WAWS platform using kudo. Yet, when I attempt to download a module using the drush dl command, the module is downloaded to the appropriate directory, but an unable to untar error is thrown. Any suggestions to resolve this “unable to untar” issue. Thanks in advance!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s