---
title: "How to Install TimescaleDB on Azure"
published: 2024-07-22T09:38:05.000-04:00
updated: 2024-07-22T09:38:05.000-04:00
excerpt: "A walkthrough on installing TimescaleDB on Azure with hardware sizing recommendations."
tags: PostgreSQL, Blog, Tutorials
authors: Juan Jose
---

> **TimescaleDB is now Tiger Data.**

[TimescaleDB](https://docs.timescale.com/) is a powerful, open-source time-series database built on top of PostgreSQL to efficiently manage time-series data, events, and analytics. Optimized for fast ingest and complex queries, it speaks “full SQL” and is correspondingly easy to use like a traditional relational database, yet scales in ways previously reserved for NoSQL databases. 

This guide will walk you through the process of setting up TimescaleDB on Microsoft Azure, ensuring you have a scalable and high-performance database ready to handle your time-series data needs.

What you'll learn:

-   Getting started with Azure
-   Setting up your VM instance
-   Installing TimescaleDB
-   Configuring PostgreSQL
-   Using TimescaleDB

## Get Started With Azure and TimescaleDB

First, head over to [Azure](https://azure.microsoft.com/) and create your Azure account. Once you've logged into the Azure portal, you'll see a dashboard similar to this:

![The Azure dashboard](https://timescale.ghost.io/blog/content/images/2024/07/1-azure.png)

### Create a Virtual Machine (VM)

1\. **Navigate to the Azure Marketplace**: In the Dashboard, click on "Create a resource" and search for "Ubuntu Server 20.04 LTS." Select it from the list.

![The Azure marketplace page with the option Ubuntu Server selected with a green frame around it](https://timescale.ghost.io/blog/content/images/2024/07/2-ubuntu.png)

2\. **Configure the VM**: Click on "Create" and follow these steps:

**Basics:** 

-   Subscription: Select your subscription.
-   Resource group: Create a new resource group named `timescale` or use an existing one.
-   Virtual machine name: Enter `timescale-vm`.
-   Region: Select your preferred region.
-   Image: Ensure "Ubuntu Server 20.04 LTS" is selected.
-   Size: Select `Standard_B1s` for this tutorial.

  
**Administrator account:**

-   Authentication type: Select "Password".
-   Username: Enter your preferred username. We will use "timescale".
-   Password: Enter a strong password.   

![The Azure page where you can create a virtual machine](https://timescale.ghost.io/blog/content/images/2024/07/3-startsetup.png)

-   **Disks**: Use the default settings for simplicity.
-   **Networking**: Use the default settings.
-   **Management**: Use the default settings.
-   **Advanced**: Use the default settings.
-   **Tags:** Optionally, add tags for resource management.
-   **Review + create:** Review your settings.

![The create a virtual machine page with the option Review + create selected with a green frame around it](https://timescale.ghost.io/blog/content/images/2024/07/4-endsetup.png)

Click on "Create."

![Azure's Create a VM page. The Create button is highlighted with a green frame around it](https://timescale.ghost.io/blog/content/images/2024/07/5-create.png)

Once the deployment is completed, click on "Go to resource."

![Azure's deployment page. The Go to resource button is highlighted with a green frame around it.](https://timescale.ghost.io/blog/content/images/2024/07/6-complete-2.png)

### Connect to your VM

1. Once your VM is deployed, **go to the "Overview" section of your VM and click on "Connect".**

![](https://timescale.ghost.io/blog/content/images/2024/07/7-overview.png)

Azure's Timescale VM page. The Connect dropdown is highlighted with a green frame around it.

2\. **Select the SSH** using Azure CLI. Click on "Select."

![](https://timescale.ghost.io/blog/content/images/2024/07/8-connect.png)

Azure's Timescale VM page. The Select button is highlighted with a green frame around it.

3\. **Follow the instructions to connect to your VM using SSH**. Check the policies, and then click on "Configure + connect."

![](https://timescale.ghost.io/blog/content/images/2024/07/9-ssh.png)

Azure's Timescale VM page. The Configure + connect button is highlighted with a green frame around it.

4\. A tab will open. **Click on "Apply"** to continue.

![Azure's Timescale VM page. The Apply button is highlighted with a green frame around it.](https://timescale.ghost.io/blog/content/images/2024/07/10-ssh-conect.png)

5\. **Finally, the terminal will open**. The connection is established and now you can go on with the next step, which is installing TimescaleDB.

![Azure's Timescale VM page. The terminal is open at the bottom of the page.](https://timescale.ghost.io/blog/content/images/2024/07/11-ssh-done-1.png)

## Install TimescaleDB

1\. **Add TimescaleDB PPA:**

```bash
sudo apt install gnupg postgresql-common apt-transport-https lsb-release wget

sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh

echo "deb https://packagecloud.io/timescale/timescaledb/ubuntu/ $(lsb_release -c -s) main" | sudo tee /etc/apt/sources.list.d/timescaledb.list

wget --quiet -O - https://packagecloud.io/timescale/timescaledb/gpgkey | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/timescaledb.gpg

sudo apt update
```

![The command output](https://timescale.ghost.io/blog/content/images/2024/07/12-console-2.png)

2\. **Install TimescaleDB**:

```sh
sudo apt install timescaledb-2-postgresql-16 postgresql-client
```

### Configure PostgreSQL

1\. **Check PostgreSQL Version (Ensure it shows `psql (PostgreSQL) 16.x`)**:

```bash
psql --version
```

💡

[If you need help installing psql, here's a step-by-step guide for different operating systems](https://timescale.ghost.io/blog/how-to-install-psql-on-mac-ubuntu-debian-windows/).

![The command output](https://timescale.ghost.io/blog/content/images/2024/07/13-postgre.png)

2\. **Modify configuration**:

```sh
cd /etc/postgresql/16/main
sudo chmod 644 postgresql.conf
nano postgresql.conf
```

![The command output](https://timescale.ghost.io/blog/content/images/2024/07/14-nano.png)

3\. **Update postgresql.conf**:

Set `listen_addresses` to `'*'`:  

```plaintext
listen_addresses = '*'
```

Set `shared_preload_libraries` to `timescaledb`:

```plaintext
shared_preload_libraries = 'timescaledb'
```

Save and exit the editor.

![The command output](https://timescale.ghost.io/blog/content/images/2024/07/15-update.png)

4\. **Tune PostgreSQL**:

```sh
sudo timescaledb-tune
```

![The command output](https://timescale.ghost.io/blog/content/images/2024/07/16-tune.png)

💡

[Need more tips to optimize your PostgreSQL performance? Check our guides](https://www.timescale.com/learn/postgresql-performance-tuning-key-parameters).

  

5\. **Restart PostgreSQL**:

```sh
sudo systemctl restart postgresql
```

6\. **Switch to PostgreSQL user**:

```sh
sudo su - postgres
```

## Using TimescaleDB

1.  **Access PostgreSQL:**

```sh
psql -U postgres
```

2\. **Create database:**

```sql
CREATE DATABASE tutorial;
```

3\. **Connect to the database:**

```sh
\c tutorial
```

4\. **Initialize TimescaleDB extension**:

```sql
CREATE EXTENSION IF NOT EXISTS timescaledb;
```

5\. **Create a hypertable:**

```sql
CREATE TABLE conditions (
    time        TIMESTAMPTZ       NOT NULL,
    location    TEXT              NOT NULL,
    temperature DOUBLE PRECISION  NULL,
    humidity    DOUBLE PRECISION  NULL
);
SELECT create_hypertable('conditions', 'time');
```

💡

[Timescale’s hypertables automatically partition your data, making your queries faster](https://docs.timescale.com/use-timescale/latest/hypertables/about-hypertables/). Read this blog post to learn [how they make PostgreSQL partitioning easier](https://www.timescale.com/learn/is-postgres-partitioning-really-that-hard-introducing-hypertables).

  

6\. **Insert data**:

```sql
INSERT INTO conditions(time, location, temperature, humidity)
VALUES (NOW(), 'office', 70.0, 50.0);
```

7\. **Query data**:

```sql
SELECT * FROM conditions ORDER BY time DESC LIMIT 100;
```

![The query output](https://timescale.ghost.io/blog/content/images/2024/07/17-createdb.png)

## Next Steps

You now have TimescaleDB up and running on Azure. Explore more with sample datasets and advanced tutorials available in the [TimescaleDB documentation](https://docs.timescale.com/). If you have any questions, feel free to join our [Slack community](https://slack.timescale.com/) or check out our [GitHub repository](https://github.com/timescale/timescaledb) (GitHub ⭐ are welcome!). 

For smaller teams wanting to focus on application development and not their database or enterprises looking for scale, cost-effectiveness, and the peace of mind of a managed solution (with one-click high availability, forking, connection pooling, a low-cost storage tier for older data, SOC 2 Type 2 compliance, and much more), [try Timescale Cloud](https://console.cloud.timescale.com/signup). It’s free for 30 days, no credit card required.