Add New SSH Login to Azure Linux VM

Some time ago, I created an Ubuntu virtual machine in Azure using a password-based login. Over time, I got annoyed with having to enter the password each time I logged in, so I decided to switch over to using SSH public keys. Unfortunately, the Azure documentation regarding such a scenario assumes only that you will be creating a new virtual machine from scratch to create a public key based login. Have no fear. I have figured out how to do this without having to recreate your virtual machine.

Requirements

  • Linux-based client (your computer)
  • Linux-based virtual machine in Azure with password-based login (Azure)

Create the RSA Keys on Your Computer

Azure requires RSA keys with 2048-bit encryption, so you should do this:

Just press ENTER when asked where to store the file unless you really want to put it somewhere other than the default. In most cases, the default is fine. After you pick the location, enter a good password to unlock the private key when prompted during login.

Transfer the Keys from Your Computer to Your Server

In order to copy your keys to the server on which you want to login, you will need to have a password-based login already setup. If this is your case, do the following:

Enter your server’s password-based login when prompted to begin the copying process.… Continue reading

Don’t Bother with WordPress on Windows/IIS

I’ve written in the past about how to setup WordPress on an Azure App Service and about connecting that WordPress instance to MySQL in an Azure VM. While these articles do contain some useful information about setting up WordPress and its interaction with Azure services, I’ve come to the conclusion that WordPress simply doesn’t function as nicely when hosted on IIS.

For about 1-2 years, I hosted several WordPress blogs in Azure App Services which connected to MySQL instances on an Azure VM (exactly as described in my articles above). I struggled endlessly with strange plugin issues and constant timeouts when attempting to connect to MySQL. For example:

  • Certain caching plugins complained that certain settings could not be applied due to IIS
  • WordPress.com and JetPack integration sometimes didn’t detect plugin and WordPress updates properly
  • When attempting to update plugins from WordPress.com or JetPack, it would simply fail with no error messages
  • Random and intermittent “Database connection” failures would occur even though I could guarantee the username/password/connection information was correct (especially since connections would succeed and then fail 30 seconds later)

I tried debugging these issues for months including monitoring incoming traffic on the VM to diagnose MySQL connection timeouts but was ultimately unsuccessful in determining a solution. Actually, that’s not entirely accurate. I did come up with a solution. I stopped using WordPress on Azure App Services.

So what to use then? I decided on using my existing VM to host the classic LAMP stack. It was already running Linux and MySQL, so I just had to add Apache and PHP.… Continue reading

A Quick Reference to Azure Key Vault via Powershell

Azure Key Vault has been generally available in certain regions since June 2015. You can’t use the Azure Portal to work with the key vault yet, so you have to drop down into Azure Powershell and run a few commands. It’s a little confusing to get started since development is ongoing and Azure Powershell itself changes frequently.

Here’s how I have been achieving some simple Azure Key Vault commands via Azure Powershell. I’m using Azure Powershell version 0.9.8, so keep that in mind if you’re comparing these commands to the Getting Started guide linked previously in this article.

Check Your Azure Powershell Version (optional)

If you don’t know what version of Azure Powershell you’re using, try this:

Switch to AzureResourceManager Mode if Necessary (optional)

Since you’re using version 0.9.8 like me, you need to switch into Azure Resource Manager mode.

Login to Azure

Login to your Azure account and enter your credentials in the popup window. It seems kind of odd that it wouldn’t just make you login via Powershell parameters.

Create a Resource Group (optional)

You need an Azure Resource Group to add the Azure Key Vault to. If you don’t have one already, create it now. If you already have one, skip this step.

Create a Key Vault

Now create the Azure Key Vault.… Continue reading

Setup a blank WordPress site in Azure

One of the reasons WordPress is hugely popular is because it’s super easy to setup and has a large developer base around it which is responsible for creating many useful plugins. If you’re interested in setting up WordPress in Azure, look no further! Make sure you understand the pricing structure of Azure before you go this route. Often, the cost isn’t really worth the return unless you have 5+ blogs that you want to setup on Azure. You can stick to the Free or Shared ($10/mo) tiers, but the performance can suffer quite a bit depending on your site’s popularity and you may not get certain features like custom domains and SSL support.

Azure can be a little confusing for newcomers who don’t realize that some functionality is split across two different portal/management sites. One of these (the “new” portal) is in Preview status while the other (the “old” portal) is the status quo which should be used for most operations. You can follow either section below to achieve the same result, though one may be simpler than the other depending on your use cases.

“Old” Azure Portal

  1. Login to the “old” Azure Portal with your Microsoft Account.
  2. In the lower left, click New > Computer > Web App > Quick Create.
  3. Enter the URL name that you want. If you end up selecting the Shared pricing tier or above (Basic, Standard, Premium) you will have the option of setting up a custom domain. See my guide to doing this with Namecheap.
Continue reading

Redirect your azurewebsites.net URL to your custom domain URL

If you’ve attached a custom domain to your Azure Websites setup, you probably want people and search engine crawlers to use the custom domain URL instead of the free azurewebsites.net URL. You can setup your application’s web.config to include the following.

Add the following to the system.webServer section of your web.config, but make sure you replace the “yourdomain” text with your own domain information.

Continue reading

Connect WordPress to Custom MySQL with Azure VM

The title is a bit of a mouthful, but I promise it’s not as crazy as it seems. If you’re anything like me, you became interested in cloud computing and stumbled upon Microsoft’s Azure platform. There are plenty of wizards built directly in to the Azure Dashboard which allow you to automatically create and setup websites, virtual machines, and databases without ever needing to perform extra configuration. However, there are some cases where you might want to setup a custom database for a specific purpose. WordPress is one great example which may require you to setup your own MySQL databases in a virtual machine. In fact, this guide assumes that you already have a WordPress Azure Website setup.… Continue reading

Setting up a custom domain with Namecheap and Azure Websites

There are a ton of domain name registrars and hosts out there. Finding specific instructions to match the two together is something a bit of a challenge. To make things tougher, instructions aren’t always updated when user interfaces and processes are changed in the tools provided by these services. Hopefully, this article will provide simple instructions.

  1. Log in to your Azure account and go to the management portal.
    • Your website must be set to “Shared”, “Basic” or “Standard” tiers in order to use custom domains.
    • If you want to eventually setup SSL on your custom domain, you will need to set the website to “Basic” or “Standard” tier.
    • Read more on pricing.
  2. Navigate to the dashboard of the Azure Website you are working with.
  3. In the bottom toolbar, click “Manage Domains”.
  4. Make note of the IP address listed at the bottom of the popup.
  5. Log in to your Namecheap account.
  6. Under “account information”, click to view your domains.
  7. On the left sidebar, click “Your Domains”.
  8. Click the domain you want to connect with Azure from the middle section.
  9. On the left sidebar, click “All Host Records”.
  10. Copy the IP address from step 4 to the IP Address / URL of the root host name “@”. Change that record type to “A Record”.
  11. Copy the “xxx.azurewebsites.net” domain name to the IP Address / URL of the host name “www” where “xxx” is your website name. Change that record type to “CNAME”.
  12. Under the subdomains section, add “awverify” and “awverify.www” subdomains. Set both IP Address / URL to awverify.xxx.azurewebsites.net where “xxx” is your website name.
Continue reading

Resolving the problem where “WADLogsTable” is not created in Windows Azure Diagnostics

I’ve been using Windows Azure to host a Worker Role in a Cloud Service for an in-development version of my new app, Steam Community Viewer. This service will allow users to be notified of when their friends come online or start playing a game through Windows 8 Toast Notifications. Additionally, it will push updates to Live Tiles for new Steam deals.

During my tests, I tried to turn diagnostics on, but failed to save them to a permanent storage because the table that gets created when you enable basic logging wasn’t actually being created! Windows Azure Basic Logs will be saved in Azure Storage Tables under “WADLogsTable” based on a logging level (error, critical, verbose, etc…). This table is supposed to be automatically created when the service is uploaded and deployed with tracing enabled. If you find that the official Windows Azure documentation on using diagnostics is not helping you with this task, try the code below in your service OnStart() overload.