Make Better Decisions the Easy Way: Deploy Metabase with Azure Container Apps
Tags: azure, metabase, datascience, docker
Published: 2022-10-12 17:18:33

With a few simple steps, you can deploy [Metabase](https://metabase.com) on Microsoft Azure using [Azure Container Apps](https://azure.microsoft.com/en-us/services/container-apps). This process works for any Docker container hosted on Docker Hub, not just Metabase, so you can try it with your containers.

## Background

I work on improving the Developer Experience on Microsoft Azure and I love spending time in the data engineering and data analysis space. I recently have enjoyed working with Metabase, and deploying it on Azure makes it easy to create some amazing visualizations for my data that is already in the Azure cloud.

![Metabase Dashboard Example](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rsoziyvf2xsrihdvy9io.png)
 
There are several options for running container-based apps on Azure, but Azure Container Apps (ACA) is one of the easiest to get started with.

## The set up

**Prerequisites** you will need:

- [Azure CLI](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli)
- An Azure subscription. If you don't already have one, you can [create one for free](https://azure.microsoft.com/free).
- [Docker Desktop](https://www.docker.com/products/docker-desktop/)

&nbsp;

## Deploy Metabase to Azure Container Apps

1. **Create the Container App and deploy the Metabase image**

    ```powershell
    az containerapp create -g metabase-rg -n metabase --image [myname]metabaseacr.azurecr.io/metabase --environment metabase-aca-env --target-port 3000 --ingress 'external' --cpu 2 --memory 4.0Gi
    ```
    Note: If prompted to install the containerapp extension, choose `Y`.

    You will see the steps as they are running, like `'Creating resource group 'your-resource-group-name'` and `Creating Containerapp your-app-name...`. 

    When the command is complete you will see a line that starts with `Browse to your Container App at: http://metabase`. You will use this URL to open your new Metabase app, but if you do it right now, you'll likely see a `stream timeout` error because Metabase needs more resources than the default .5 CPU and 1GB memory Azure Container Apps allocates. The next step will help you update the resources and get the app running.

    &nbsp;

1. **Update the resources for your Container App**
    To increase the CPU and memory resources allocated to your new Container App, just run the following command:

    ```
    az containerapp update --resource-group metabase-rg --name metabase --cpu 1 --memory 2.0Gi
    ```
    &nbsp;

## Open Metabase and explore

1. **Paste the URL from Step 1 in a browser to start enjoying Metabase!**

    If you need that URL again, you can use this command to quickly find it:

    ```powershell
    az containerapp show -g metabase-rg -n metabase --query properties.configuration.ingress.fqdn
    ```
    
    &nbsp;

    Use the [Metabase Getting Started Guide](https://www.metabase.com/learn/getting-started/getting-started) or search for [Metabase on YouTube](https://www.youtube.com/results?search_query=metabase) if you need help getting started.

    &nbsp;

## Cleanup the resources
When you are done exploring Metabase, don't forget to delete the resources you created if you aren't going to use them any longer.

```powershell
az group delete -g metabase-rg
```
&nbsp;

## Next Step - Set up your Container App for production use
Metabase has a nice doc for configuring Metabase to be used in production: [How to Run Metabase in Production](https://www.metabase.com/blog/how-to-run-metabase-in-production). One of the steps is to migrate from the internal H2 database to PostgreSQL, and you can use Azure Database for PostgreSQL for this purpose. 

You will need to set some environment variables in your Container App to tell Metabase which database to talk to. Azure Container Apps lets you do this easily through the [Azure Portal](https://portal.azure.com) or through the Azure CLI. 

If This step is interesting to you, let me know and I'll add another article.

&nbsp;

## Conclusion

I'm still learning about Metabase myself, but I've been super impressed so far. I would love to hear what you think, and if you run into problems, don't hesitate to drop into the [Metabase Discussion](https://discourse.metabase.com/) and bring your questions.

&nbsp;

![Metabase Dashboard Example](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s17bk2b5bckr71yu7ima.png)

&nbsp; 

I want to give a shout-out to the [Metabase Discussion site](https://discourse.metabase.com/). I've had a number of questions about deploying and using Metabase that I've posted on the site. Most of my questions have been answered within hours and no question has gone unanswered. Amazing support!

&nbsp;

And if you want a little more information on running Metabase in a Docker container, Metabase has a very nice doc that got me off to a good start: [Running Metabase on Docker](https://www.metabase.com/docs/latest/installation-and-operation/running-metabase-on-docker.html)