WordPress Networks & IIS Rewrite Rules on Azure App Service


This is a bit of an extension to my previous post.

One of the last blogs I moved was a MU or a multi-user WordPress blog, which is now known as a Network. This turned out to be a bit more challenging than the single WP blogs. To setup a new instance, these instructions should mostly do the trick however, based on my testing you’ll still need the rewrite rules below.

From this post and this post, I was able to assemble the following rewrite rules that have worked for my WPMU blog running on the Azure App Services (as of Sept. 13, 2016)! Don’t miss the <httpRedirect enabled="false" ....> line at the bottom – that was very important. You’ll also need those MU settings out of your wp-config.php file too.


<rule name="WordPress Rule 1" stopProcessing="true">
<match url="^index\.php$" ignoreCase="false" />
<action type="None" />
<rule name="WordPress Rule 2" stopProcessing="true">
<match url="^([_0-9a-zA-Z-]+/)?files/(.+)" ignoreCase="false" />
<action type="Rewrite" url="wp-includes/ms-files.php?file={R:2}" appendQueryString="false" />
<rule name="WordPress Rule 3" stopProcessing="true">
<match url="^([_0-9a-zA-Z-]+/)?wp-admin$" ignoreCase="false" />
<action type="Redirect" url="{R:1}wp-admin/" redirectType="Permanent" />
<rule name="WordPress Rule 4" stopProcessing="true">
<match url="^" ignoreCase="false" />
<conditions logicalGrouping="MatchAny">
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" />
<action type="None" />
<rule name="WordPress Rule 5" stopProcessing="true">
<match url="^" ignoreCase="false" />
<conditions logicalGrouping="MatchAny">
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" />
<add input="{URL}" pattern="([a-zA-Z0-9\./_-]+)\.axd" />
<action type="None" />
<rule name="WordPress Rule 6" stopProcessing="true">
<match url="^[_0-9a-zA-Z-]+/(wp-(content|admin|includes)?.*)" ignoreCase="false" />
<action type="Rewrite" url="{R:1}" />
<rule name="WordPress Rule 7" stopProcessing="true">
<match url="." ignoreCase="false" />
<action type="Rewrite" url="index.php" />
<httpRedirect enabled="false" destination="http://www.examplesite.com" />


define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', false);
define('DOMAIN_CURRENT_SITE', 'www.examplesite.com');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);

WordPress on Azure App Service using MySQL In-app!


Well, after a very long hiatus from blogging, I thought it was about time I started again. And what better way to start than with an update to my previous post on hosting your WordPress blog in the Azure App Service!

If you have been watching the Azure blogs, specifically from the App Service Team, you may have noticed an interesting one titled “Announcing MySQL in-app (Preview) for Web Apps“. For those of us that just want to host a small blog somewhere and are not concerned about scaling the web app across multiple instances (aka no auto-scaling), this is a pretty intriguing option. I should also note that as of writing this post (September 12, 2016), MySQL in-app is still in preview and not yet at general availability. You should take a look at the product team’s post for a full list of limitations.

Migrating to this service was fairly straightforward! Below is the approach I took.

  1. You’ll need to have an App Service Plan for this. I prefer to create a plan before the web app, but you can create both at the same time. Here’s some quick instructions on how to create one. When selecting a specific plan type (Free, Shared, Basic, Standard, or Premium), you should make yourself aware of the limitations to each plan. For example, Always On is not supported by Free and Shared plans. Backup is only support in Standard and Premium. RAM scales up as the plans go up. You can always scale up and down after you create the plan too.
  2. Create your new web app. For this you’ll want to pick the ‘WordPress’ template. This link will get you right to the correct blade in the Azure Portal.
  3. Fill out the fields as per your requirements. For the Database Provider field, be sure to pick “MySQL In App (Preview)” as shown below. Application Insights is enabled by default, your call on leaving this way. There is a WordPress plugin to fully enable it in your blog should you so desire however, I am not sure how frequently it’s maintained, so use as your own risk. I do have plugin version 2.2 running on my blog, which is at version 4.6.1.
  4. Once your web app is spun up, there’s a few things I like to do and these are optional:
    • Configure your custom domain, found under Custom domains > Add
    • Enable Always On, found under Application settings > Always On.
    • Turn off the Affinity Cookie because you can only have a single instance of your site using MySQL in-app., found under Application settings > APR Affinity. More info here.You’re now ready to migrate your blog over to your new web app!
  5. For moving MySQL, I grabbed a backup of the database in .sql format. You may need to compress it of it’s greater 8MB. You’ll need to take that file and import it into your MySQL instance. Because it’s in a protected sandbox environment, MySQL cannot be accessed remotely so you’ll need to use phpMyAdmin. To get there, open the “MySQL In App (Preview)” blade in your web app and click “Manage” as show below. Once in phpMyAdmin, make sure there’s an empty DB called “azuredb”. Select it, click the “Import” tab and follow the instructions.
  6. Next up – your content! You’ll probably need everything in your WordPress home directory including things like the folders wp-admin, wp-content, wp-includes, and files wp-config.php, wp-login.php to name a few. Once you’ve got the files required all together, you’ll need to make a small change to your wp-config.php. From the product team blog post mentioned above, they include some sample code for parsing the db connection string provided by the app service. I’ve included it below. Be sure to just replace the MySQL settings in your wp-config.php or your site may not work. You may also need to adjust an references to the home directory, if a plugin has added them to your wp-config.php. The web app hosted home directory will be “D:\home\site\wwwroot”. Good idea to keep a backup of that file as well.
    /*Add at the begining of the file*/
    $connectstr_dbhost = '';
    $connectstr_dbname = '';
    $connectstr_dbusername = '';
    $connectstr_dbpassword = '';
    foreach ($_SERVER as $key =&gt; $value) {
        if (strpos($key, "MYSQLCONNSTR_localdb") !== 0) {
        $connectstr_dbhost = preg_replace("/^.*Data Source=(.+?);.*$/", "\\1", $value);
        $connectstr_dbname = preg_replace("/^.*Database=(.+?);.*$/", "\\1", $value);
        $connectstr_dbusername = preg_replace("/^.*User Id=(.+?);.*$/", "\\1", $value);
        $connectstr_dbpassword = preg_replace("/^.*Password=(.+?)$/", "\\1", $value);
    // ** MySQL settings - You can get this info from your web host ** //
    /** The name of the database for WordPress */
    define('DB_NAME', $connectstr_dbname);
    /** MySQL database username */
    define('DB_USER', $connectstr_dbusername);
    /** MySQL database password */
    define('DB_PASSWORD', $connectstr_dbpassword);
    /** MySQL hostname : this contains the port number in this format host:port . Port is not 3306 when using this feature*/
    define('DB_HOST', $connectstr_dbhost);
  7. Upload your files to your web app. I used FTP to move them, FileZilla specifically, but use whatever works best for you. Make sure your WordPress root ends up under “D:\home\site\wwwroot”. As a best practice, I delete the WordPress files created as part of the web app creation, but do what you think is best. You can find your FTP credentials under the Properties blade. I prefer to use FTPS whenever possible. If you don’t know your FTP user’s password, it can be reset under the Deployment credentials blade.
  8. You may need to adjust any DNS entries to reflect the different host and to align with your WordPress config. I use Fiddler to run a quick test to make sure the site is operational and run some quick tests before I flip my DNS entries.
  9. One last thing to do – update your Permalinks config. In your blog, just go to Settings > Permalinks, validate that your preferred structure is selected and click ‘Save Changes’. This will cause your web.config file to be updated to correctly support permalinks. This is especially important if you have moved from Apache on a Linux box. Other than that – you’re all set!

Hopefully that helps you move your blog to an Azure Web App using MySQL in-app…. And yes… this blog is hosted in an Azure Web App with MySQL in-app.

Hosting a WordPress Site on Azure Web Apps


As I am sure you’ve been able to guess, this site WordPress is hosted on Azure using an Azure Web App with a ClearDB hosted MySQL database behind the scenes. It’s fairly straightforward to set this up, but I have found lately that I need to use both Azure Preview Portal and the current Azure Portal for best results. Here are the steps I follow:

  1. Create your MySQL database.

    I use the Azure Preview Portal for this as the integration with ClearDB is much more complete, in fact, you may not even realize it’s a different service provider in the background. I know you are supposed to be able to do this together with creating the “Scalable WordPress” app under “Web + Mobile” , but I find it often doesn’t allow you to select the Mercury (free) or Titan ($3.50/mo) pricing tiers for the database. Fill in all the blanks being sure to set the location to the same location that you want to host your WordPress app in. It’s good to create a new Resource Group here which will also be used with your Web App.

  2. Create your WordPress Web App.

    Switch over to the Azure Portal. Reason being: The preview portal doesn’t let you select the MySQL database created in step #1. In the Azure Portal, select “Web Apps” and then click the new button. You’ll be able to find “WordPress” under the “From Gallery” category.  Give it a Url. Under Database be sure to select “Use and existing MySQL database”. Select the correct “Subscription” (aka “App Service Plan”) under Webscalegroup and the correct subscription under “Subscription” (clear as mud, right?). Lastly there are a bunch of Deployment Settings to complete. These deployment keys can be generated here. As I am sure you have noticed, they cannot be directly copied into the Configure Web App screen in the Azure Portal and even if you could, some of the characters are not valid for Azure. To fix this up, Luis Cantero has published tool to help you out. It can be found at the bottom of his post on this very topic. As his instructions state: “Just paste the entire code from the WP API above and press the button”. Simply grab that result from key generator, publish it in his tool, then copy each of the individual keys to the corresponding line in the Configure Web App screen. Once you’re done, click the next button ( forward arrow), select the database you created in step one, review and accept the term, and click the check button to create your site. It will take a few minutes for the site to create, be patient and then head over to your azurewebsites.net url, run the wizard and you’re all done.

Happy Blogging!

Enterprise Search in SharePoint 2013


As I have been increasingly working with Enterprise Search in SharePoint 2013, I have found myself continuously re-researching specific topics. Thus, I have decided to publish this post and keep ot up to date with search content and configuration selfishly for my own reference, but if some else finds it useful – yayy! 🙂

Search Schemahttp://technet.microsoft.com/en-us/library/jj219669.aspx
Large article encompassing search topics such as, crawled properties, managed properties, the seach index, and the variety of settings in search.

Search Relevancehttp://technet.microsoft.com/en-us/library/cc835623.aspx
Obviously a huge topic in SharePoint search. The above link is really just a reference point to several topics.

Search Architectural Diagramshttp://www.microsoft.com/en-ca/download/details.aspx?id=30374
PDF and VSD files containing the full search architeture in SharePoint 2013 Search.

Search Dictionaieshttp://office.microsoft.com/en-us/office365-sharepoint-online-enterprise-help/manage-search-dictionaries-HA103629159.aspx
Information regarding company names and spelling correction dictionaries.

Company Name Extractionhttp://technet.microsoft.com/en-us/library/jj591605.aspx
Functionality which allows administrators to provide SharePoint search with one or more company names. These can then be used as refiners to help narrow search results for users. Additionally this functionality supports both inclusion and exclusion lists.

Understanding Query Ruleshttp://office.microsoft.com/en-ca/sharepoint-server-help/understanding-query-rules-HA102848833.aspx
Pretty self-explanatory, but contains some high-level examples.

Changing the ranking of search results in SharePoint 2013http://blogs.technet.com/b/tothesharepoint/archive/2013/06/25/changing-the-ranking-of-search-results-in-sharepoint-2013.aspx

SharePoint 2013 Search Guidance – http://planningservices.partners.extranet.microsoft.com/en/SDPS/SAPSDocuments/SharePoint%202013%20Search%20Guidance.docx

Building Search Queries in SharePoint 2013 – http://msdn.microsoft.com/en-us/library/jj163973(v=office.15).aspx

I’ll keep updating this post as I find more useful information!

Trouble Upgrading to Windows 8.1?


I know I sure had a lot of trouble upgrading! I did all the updates like I was supposed to and the download would just not show up in the store! Very frustrating experience. So I did was all good IT folks to – Googled it!

The end procedure was simple actually:

  • Crack open IE on your target upgrade box
  • Paste the following link in your address bar and hit enter


  • This should open the Windows Store to a nice Windows 8.1 download
  • Click download and wait for it to start prompting you for action

This procedure seems to work for both Windows RT and Windows Pro. Special thank you to francescob who was kind enough to post the above Windows Store link in the comments section of this article.

Uploading a File to an Azure Storage Container


Here’s the scenario: You have a file or blob of sorts that needs to be stored in an Azure Storage Container. That’s great – how do you get it to the container?? I have done this a few times and PowerShell is definitely my preferred method but I can never remember the steps. So, for my benefit and maybe others, here they are:

1: Get-AzurePublishSettingsFile

This will actually pop open IE (or your default browser), have you log into Azure, and then automatically download a .publishsettings file. You’ll need this file to import and set up your subscriptions. More information on this command can be found on MSDN here.

2: Import-AzurePublishSettingsFile <pathToPublishSettingsFile>

This import command does exactly as it describes, allows you to import the .publishsettings file from step 1 to your local PowerShell environment. When this import completes, it will tell you which subscription (only matters if you have multiple) has been set as the default subscription. If you need to change this, use step 3, if not, proceed to step 4. More information on this command can be found on MSDN here.

3: Select-AzureSubscription <subscriptionName>

This command is optional and simply sets the current Azure subscription to be used in the existing context. More information on this command can be found on MSDN here.

4: $context = New-AzureStorageContext -StorageAccountName <storageAccountName> -StorageAccountKey <storageAccountKey>

This command generates a new Azure Storage Context and stores it in the variable $context. This will be used to tell PowerShell where the new blob is going to be stored in Azure. Your storage account name and key are both found within the Azure management site. More information on this command can be found on MSDN here.

5: Set-AzureStorageBlobContent -Blob “<blobName>” -Container <containerName> -File “<sourceFileName>” -Context $context -Force

This is where the magic happens. Set-AzureStorageBlobContent, again, does exactly as it describes. The Blob parameter is what the file (or blob) will be called once uploaded to the Azure container. Container is the target container within your Azure storage account. The File parameter is the full path and name of the source file that you want to uploaded to the Azure container. Context is the context variable from step 4. Once executed, you will see a status appear at the top of your PowerShell console which shows the percentage uploaded until the upload is complete. More information on this command can be found on MSDN here.

For bulk uploading, the best thought I have is to read a directory that is to be uploaded, then run this command in a loop. If anyone has a better way – please feel free to comment on this post and I’ll update it and give credit for the suggestion!

News on the Office Store Front: Subscription Apps!


This is really big news on the Office Store front, at least in my humble opinion, and straight from the Office News blog: http://blogs.office.com/b/office-news/archive/2013/10/01/office-store-investments-bring-new-opportunities-to-developers.aspx.

It reads as though we’ll be able to submitting updates to existing apps and submitting new apps for approval which leverage a subscription model sometime this month (October 2013). These apps will be available for purchase in the store starting in November! Looks like some of the supporting pricing model documentation has been updated too.

Now, I am personally a bit less concerned with Apps for Office and more concerned about Apps for SharePoint – naturally – but this is a big deal for both! What is the significance of the addition of this subscription pricing model? The answer is two-fold for me:

1) Constant revenue stream

This is a big problem I have had with the whole movement toward apps in general. For phones, tablets, you name it – anything you buy apps for. I know Apple addressed it a while ago – which was great – but for those of us taking a hard look at SharePoint 2013 app feasibility – how do you build a business focused app, sell it for a one-time fee, and support it forever? It’s not exactly a business model I’d be to ecstatic to jump into.

There was the option of making the app free and building your own subscription model into it, but knowing sometime down the road that Microsoft was going to release this functionality to the store didn’t really drive me to dedicate resources to building one of my own.

2) Support / maintenance costs

This really goes hand-in-hand with the requirement of a constant revenue stream, but I like to highlight it due to the importance of it in planning an app. Typically a solid app is going to require some kind of back-end system or infrastructure  as well as people to support it. I know there are apps or services out there, such as some of the platform agnostic messaging apps, which are reliant on outside capital to support their infrastructure and development while the business grows. There is nothing wrong with the outside capital approach and it could very well be used to when developing subscription apps – but the subscription model provides that clear revenue path to support and maintain what is required for the app to function. It also makes the business model a bit more desirable if you do need capital.

Take a document conversion app for SharePoint Online as an example, the conversion itself needs to happen somewhere outside of SharePoint and someone needs to pay for that processing power. A subscription takes care of these costs. Don’t get me wrong, a large enough single purchase price could as well, but a small monthly cost is easier to sell than a large one-time cost.

There are many more reasons why this announcement is important to app developers and businesses, I for one am just happy the Office app subscription model is becoming a reality!

CalSPUG – October 17, 2013


I am very excited to tell you that Ruven Gotz (yes his blog is also part of spinsiders.com) will be presenting the topic “Taxonomies, Content Types and Metadata, Oh My!” this October at our regular CalSPUG meeting day on the third Thursday of the month (Oct. 17th). Doors open at 5:00, presentation should start around 5:30 with food and drinks provided! To register, please do so here: http://calspug-2013-10-17.eventbrite.ca/.

For those keen individuals, you may have also noticed that we haven’t announced anything for September yet. While it doesn’t look likely that we will be having an event this month (due to scheduling conflicts), we are working diligently with presenter to organize a possible second event in October. Please keep an eye to your inbox for further details.


Visio Shapes for Office 365 / SharePoint 2013


This little things are pretty useful for diagramming out Office 365 & SharePoint 2013 environments: http://www.microsoft.com/en-us/download/details.aspx?id=35772

One little trick to using them: After you add the shape to your diagram it will be blue, just turn off the theme for that item (or select many and turn of the theme for them all).