OpenStreetMap

Setting up an OSM Rendering Server in Azure

Posted by SomeoneElse on 26 August 2017 in English. Last updated on 20 March 2018.

Why might you want to do this?

You might want to set up a rendering server for a short period of time, or you might want a server that has lots of memory while you’re importing data, but much less afterwards. An “always on” Azure server will probably cost more that a comparable VPS somewhere else, but if you only want it for an hour or two at a time, it may cost considerably less.

This page describes using Microsoft Azure to do this, but of course other cloud providers are available, and depending on what you want to do may be better suited to your needs.

I have no commercial relationship with Microsoft (beyond occasionally buying hardware with Windows preinstalled and then later removing it) and this isn’t a “recommendation”, beyond providing another option to setting up a server yourself.

Sign up to Azure

If you haven’t already got one that you want to use, create a Microsoft account. Jump through whatever validation hoops you have to (for me that was an email address or a phone number, but this may vary depending on where you are).

Next, go to portal.azure.com and sign in. There will probably be a few “free trial” buttons around; click one of them to get a 30-day trial of up to £150 / $200. You’ll need to provide the Microsoft account details (from above), a phone number (again) and a credit card. If you’re in Germany and want to keep your data there see here.

Create a virtual machine

This page is a good starting point. You’ll want to install the Azure CLI because it’s a lot less fiddly than than the alternatives, though there is a “Cloud Shell” option in the portal (actually that’s an account on a remote Ubuntu 16.04.2 LTS VM!) and a “clicky pointy” interface in there too.

First, create a “resource group” to tie everything associated with this machine together, and make it easier to tidy up later. I created this in “uk south”, you can pick somewhere closed to you:

az group create -n MyResourceGroup -l uksouth

If you already have a public key associated with the account that you are running “az” from (typically $HOME/.ssh/id_rsa.pub) then:

az vm create -n MyVM -g MyResourceGroup --image UbuntuLTS --data-disk-sizes-gb 20

Otherwise use:

az vm create -n MyVM -g MyResourceGroup --image UbuntuLTS --data-disk-sizes-gb 20 --generate-ssh-keys

to create them and create a remote machine. If you’ve generated ssh keys in Cloud Shell you’ll want to store them locally and use them later for access, otherwise you won’t be able to log in again.

That’ll get a a “default sized machine” - you can easily change it later if you want to. Allow access in on ports 80,443 and 22:

az vm open-port --port 80  --resource-group MyResourceGroup --name MyVM
az vm open-port --port 443 --resource-group MyResourceGroup --name MyVM --priority 901
az vm open-port --port 22  --resource-group MyResourceGroup --name MyVM --priority 902

Click “Virtual Machines” in the portal - you can see the IP address to connect to there.

Install software

At this point you can head over to the switch2osm instructions and follow those.

Machine name

Once complete, come back to the portal and click “Virtual Machines” at the left. Click the name of the machine you just created, and then “public IP address” at the right. That’ll allow you to type in a personal DNS name (perhaps “mynameswitch2osm”), and the FQDN will consist of that plus “.azureregion.cloudapp.azure.com”, for example “mynameswitch2osm.uksouth.cloudapp.azure.com”.

If you have control of a DNS you can set up a CNAME record so that the name that you want to refer to the server as (e.g. “myname.mydomain.com” points at “mynameswitch2osm.uksouth.cloudapp.azure.com”), and you can create a certificate for “myname.mydomain.com” using “letsencrypt” if you want to.

Tidying up

When you’ve finished using the server, stop it from the portal (click the three dots to the right of the server name). In the portal the server will change from “running” to “deallocating” and then “Stopped (deallocated)”.

To start it again click the three dots and then “Start” - it’ll take a couple of minutes to start up (you may need to wait a minute or so after it has started before yo can ssh in).

When you want to completely delete the VM and everything associated with it, click “Resource Groups” in the portal, click the resource group you created at the top of this process and then “delete” at the top right. You’ll need to type in the resource group name as confirmation to delete it.

Discussion

Log in to leave a comment