# Setup Discourse on Azure

**URL:** https://meta.discourse.org/t/setup-discourse-on-azure/89550
**Category:** Sysadmins
**Tags:** how-to, install
**Created:** [June 10, 2018, 1:41pm UTC](https://meta.discourse.org/t/setup-discourse-on-azure/89550 "2018-06-10T13:41:49Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![blake](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/blake/32/157322_2.png) [@blake](https://meta.discourse.org/u/blake)
#### Post date: [June 10, 2018, 1:41pm UTC](https://meta.discourse.org/t/setup-discourse-on-azure/89550/1 "2018-06-10T13:41:49Z")

</div>

This guide is for those who are interested in self-hosting a Discourse site in Azure and will walk you through the initial Azure Portal details needed to get your Linux VM created so that you can then follow the [regular cloud install guide](https://github.com/discourse/discourse/blob/master/docs/INSTALL-cloud.md) that is web host agnostic. If you are not interested in self-hosting but would like us to host your Discourse forum for you please sign-up [here](https://discourse.org/buy).

### 1) Create a Resource Group

Before we create the VM, lets create a Resource Group. This is where everything related to your Discourse site will live like your VM storage disks, networking, security groups, blob storage, etc. To create a Resource Group click the green plus sign and select Resource Group, then fill out the “Resource group name” field, select your “Subscription”, and your “Resource group location”, then press “Create”.

 ![image](https://global.discourse-cdn.com/meta/original/3X/a/0/a0289f30be15a6712d7089aec321ba6a3a129215.png)

### 2) Create the Linux VM

We are going to create an Ubuntu 16.04 LTS VM for this guide, to do that click the green plus sign again and then search for “Ubuntu Server 16.04 LTS” and it should show up as one of the available VM’s.

 ![image](https://global.discourse-cdn.com/meta/original/3X/4/a/4a14f46337e61e23936cb7b01be724a581e72072.png)

Select it, and then make sure the deployment model is on “Resource Manager” and then click “Create”

 ![image](https://global.discourse-cdn.com/meta/original/3X/9/4/9449f51787cebcfc10b937aefa67f07c37e1f014.png)

### 3) Configure basic settings

Now you should be on the “Basics” tab of “Create a virtual machine”. Fill out all the required fields to setup the VM. Select the “discourse” resource group we created earlier, give your VM a name like “discourse”, and choose the Region you would like to use.

 ![image](https://global.discourse-cdn.com/meta/original/3X/5/3/535eea480a85d04ee43b5af479d21262f809e3eb.png)

Still on the same “Basics” tab you will need to choose the size of your VM. It defaults to a “Standard D2s v3” which has 8 GB of memory and costs $71.42 per month, so be sure to select “Change size” and choose an appropriate VM size for your workload.

 ![image](https://global.discourse-cdn.com/meta/original/3X/4/8/48e7a82b248a1396126b85ff45475f70836af886.png)

For the bare minimum you will need to select the “B1ms” option with 2GB of ram. The “B1s” even though it is advertised with having 1GB you only get around 800MB of ram at the OS level and there just isn’t enough left over to run Discourse well. The “B1ms” will cost $17.11 per month.

 ![image](https://global.discourse-cdn.com/meta/original/3X/d/5/d585d7a885a9bf51a75884a1ae531364e4bdadfd.png)

Now fill out the Linux username, and upload your [ssh public key](https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/). Alternatively you can configure a password based login, but the ssh key based login is preferred.

 ![image](https://global.discourse-cdn.com/meta/original/3X/8/0/809dad2126b3933e60773e60ae6e9110a68f9a8d.png)

Now we need to make sure we have web and ssh access to the machine by selecting the “Allow selected ports” radio button and choosing HTTP, HTTPS, and SSH from the “Select inbound ports” dropdown. After setup is complete it is a good idea to limit ssh access to only your IP Address.

 ![image](https://global.discourse-cdn.com/meta/original/3X/b/8/b87092678f24ce810905967f79444a4c2ff0cbb3.png)

Select “Review + create”. Verify everything is good on the Summary page and then press “Create”. The VM creation will take several minutes.

### 4) SSH into the VM

We will need command-line access in order to setup swap and to install Discourse. Once the VM has been created you should be able to select it from the azure portal and on the Overview screen it will display the Public IP address. Open your terminal and ssh into the VM with the username we specified in step 3 of this guide.

If you are unsure how to SSH into the VM you can alternatively use the “Serial console” inside of the Azure Portal by selecting the VM and at the bottom of the navigation on the left you can select “Serial console”.

 ![image](https://global.discourse-cdn.com/meta/original/3X/e/9/e90f862e666637c02cea39d5a736fab77a03c6f9.png)

This will open up a shell where you can type in your username and password that you specified before you created the VM. If you are unsure what your password is you can use the “Reset password” option.

You should now be at a terminal where you can type commands:

 ![image](https://global.discourse-cdn.com/meta/original/3X/f/e/fe6791063a14f97e532dcbf3a2d5b14753aeffca.png)

### 5) Setting up Swap

Each azure VM comes with a temporary disk separate from your OS disk and is usually mounted at `/dev/sdb1`. You want to make sure your swap is setup on this temporary disk and not your OS disk because:

> This temporary storage drive is present on the physical machine which is hosting your VM and hence can have higher IOPS and lower latency when compared to the persistent storage like data disk. - [Understanding the temporary drive on Azure Virtual Machines](https://blogs.msdn.microsoft.com/mast/2013/12/06/understanding-the-temporary-drive-on-windows-azure-virtual-machines/)

Edit the `/etc/waagent.conf` file and update the following lines:

```
ResourceDisk.Format=y
ResourceDisk.EnableSwap=y
ResourceDisk.SwapSizeMB=2048

```

_Note: If you already have a swap setup on the OS drive (maybe because `./discourse-setup` configured it for you) you can turn it off by commenting out the `/swapfile` line in `/etc/fstab`._

If you are unsure how to edit the `/etc/waagent.conf` file with a command-line editor like vim you can simply copy+paste the following command into your terminal and press enter:

`sudo sed -i '/ResourceDisk.Format=n/c\ResourceDisk.Format=y' /etc/waagent.conf && sudo sed -i '/ResourceDisk.EnableSwap=n/c\ResourceDisk.EnableSwap=y' /etc/waagent.conf && sudo sed -i '/ResourceDisk.SwapSizeMB=0/c\ResourceDisk.SwapSizeMB=2048' /etc/waagent.conf`

It may ask you for you password if this is the first time you’ve run a sudo command.

Then restart your VM with `sudo shutdown -r now`.

To verify that swap is working log back into your VM and type `swapon --show` and you should see something like:

```
root@azure:~# swapon --show
NAME TYPE SIZE USED PRIO
/mnt/swapfile file 2G 0B -2

```

Notice that the swap file is located inside of `/mnt` this is good because this is our temporary drive.

You can also type `free -h` and see something like:

```
root@azure:~# free -h
              total used free shared buff/cache available
Mem: 1.9G 174M 1.5G 3.0M 172M 1.5G
Swap: 2.0G 0B 2.0G

```

The swap should have something in the total column which means it has been setup.

### 6) Install Discourse

Now that our Linux VM has been created on Azure and we have a swap partition it is now time to follow the [Official Cloud Install Guide](https://github.com/discourse/discourse/blob/master/docs/INSTALL-cloud.md).

### 7) Install the Azure Blob Storage Plugin (Optional)

Now that Discourse is installed you can follow the install instructions on the [Azure Blob Storage Plugin](https://meta.discourse.org/t/azure-blob-storage-plugin/79392) topic. Installing and enabling this plugin will cause images that users upload to be stored in blob storage instead of on your Linux VM which should help with performance as well as keeping your OS disk from filling up.

---

<div class="post-metadata">

### Author: ![toraritte](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/toraritte/32/266434_2.png) [@toraritte](https://meta.discourse.org/u/toraritte)
#### Post date: [August 14, 2021, 12:27pm UTC](https://meta.discourse.org/t/setup-discourse-on-azure/89550/3 "2021-08-14T12:27:07Z")

</div>

The meta discourse thread [Discourse installation on Azure not reachable](https://meta.discourse.org/t/discourse-installation-on-azure-not-reachable/36880/) was also helpful for me in conjunction with this one.

---

<div class="post-metadata">

### Author: ![ludwikc](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ludwikc/32/438823_2.png) [@ludwikc](https://meta.discourse.org/u/ludwikc)
#### Post date: [August 18, 2024, 2:12pm UTC](https://meta.discourse.org/t/setup-discourse-on-azure/89550/4 "2024-08-18T14:12:07Z")

</div>

Is is possible to run Discourse on Azure as serverless installation? Docker-first, without underlying VM?

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [August 18, 2024, 2:42pm UTC](https://meta.discourse.org/t/setup-discourse-on-azure/89550/5 "2024-08-18T14:42:44Z")

</div>

It’s not supported or well documented, but it should be possible.

User launcher to build and bootstrap an image and push it to a repo. Then use launcher to see what env it launches with. Then use that info to start it up. I’ve done that for aws before.

Even more undocumented is launcher2 which I think exists in the discourse\_docker repo but I’ve not seen it discussed outside of comments in github.

If you would like help and have a budget, please contact me or post in #Marketplace.

---

<div class="post-metadata">

### Author: ![ludwikc](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ludwikc/32/438823_2.png) [@ludwikc](https://meta.discourse.org/u/ludwikc)
#### Post date: [August 18, 2024, 3:01pm UTC](https://meta.discourse.org/t/setup-discourse-on-azure/89550/6 "2024-08-18T15:01:53Z")

</div>

I do have a budget I wanted to invest but that’s using my internal resources and talent.

Can we get some support from Discourse team if we were to run it as PoC?
