Deploy Meilisearch on Azure in One Click
Tags: meilisearch, azure, cloud
Published: 2022-02-18 15:53:41

---
canonical_url: https://www.maneu.net/data/deploy-meilisearch-on-azure-one-click/
---
If you're developing an application, chances are that you need some search capabilities. In this area, users have been accustomed to blazing-fast search experiences like the ones on modern search engines.

Truth is, providing a great search experience from just an autocomplete box is quite hard. Enter  **[Meilisearch](https://www.meilisearch.com/)**, an open-source search API. It's easy to use, blazing fast, and comes with [SDKs for a wide range of languages](https://docs.meilisearch.com/learn/what_is_meilisearch/sdks.html).

So, let's see how easy it is to host it on Azure 🚀

## One-click deploy

If you're in a hurry, just click that big blue button **and** do not forget to replace the _Application Name_ with something more _personal_. 

[![Deploy To Azure](https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/1-CONTRIBUTION-GUIDE/images/deploytoazure.svg?sanitize=true)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fcmaneu%2Fmeilisearch-on-azure%2Fmain%2Fmain.json)  

![Azure portal asking deployment parameters](https://www.maneu.net/images/posts/2022/data/meilisearch-on-azure-1.png)

Click on the **Create** button, wait a few minutes while the deployment is happening...and that's it! Your Meilisearch instance is up and running. You can access your instance via a custom URL of the generated App Service. You can see it by clicking the **Outputs** tab on the left. The API is accessible on the 433 port and not the default 7700 port.

![The deployment output table, showing the Meilisearch API url](https://www.maneu.net/images/posts/2022/data/meilisearch-on-azure-2.png)

## Host Meilisearch on Azure Web Apps for Containers

Let's see under the hood how you can easily host Meilisearch on Azure. As Meilisearch is created in Rust, the best way to host it is probably to use their container image. With [Azure App Service](https://azure.microsoft.com/services/app-service/#overview), you can easily host and scale containers without having to deal with Kubernetes or OS updates.

### Create an Azure App Service

If you're not familiar with Azure App Service, I encourage you to [follow this tutorial](https://docs.microsoft.com/learn/modules/deploy-run-container-app-service/?wt.mc_id=data-46726-chmaneu). Onwards, I'll assume you have a basic knowledge of this service :).

If you try to deploy [getmeili/meilisearch](https://hub.docker.com/r/getmeili/meilisearch) image, it'll not work the first time. This is due to the port exposed by the image - which is by default 7700. We need to inform Azure App Service to map this port behind the SSL termination done by App Service. For this, you must add the environment variable `WEBSITES_PORT` with the value 7700.

Meilisearch recommends setting a master API Key. You can do so by adding the `MEILI_MASTER_KEY` environment variable with some long & complex values.
Once this is done, you can try your instance right away! If you're also new to Meilisearch, [checkout their quick start!](https://docs.meilisearch.com/learn/getting_started/quick_start.html#add-documents).

![Melisearch dashboard hosted on Azure displaying search results with Harry Potter movies](https://www.maneu.net/images/posts/2022/data/meilisearch-on-azure-3.png)

## Setup shared storage

But what happens if you stop or restart your instance? All your indexed data is gone!

![The meilisearch dashboard with no index](https://www.maneu.net/images/posts/2022/data/meilisearch-on-azure-4.png)

Well, this is quite expected. Azure App Service is by default a stateless service: all data written on disk will be lost at some point (service restart, reimaging, ...). So you need to configure what we call **[Path mappings](https://docs.microsoft.com/azure/app-service/configure-connect-to-azure-storage?tabs=portal&pivots=container-linux&wt.mc_id=data-46726-chmaneu)**. This feature will map a folder within the container to a specific file share. Hence all data stored there will be persisted even if the container is restarted.

![Azure portal showing mounted volumes](https://www.maneu.net/images/posts/2022/data/meilisearch-on-azure-5.png)

You can see how to mount a storage mapping to a Linux container in [our documentation](https://docs.microsoft.com/azure/app-service/configure-connect-to-azure-storage?tabs=portal&pivots=container-linux#mount-storage-to-linux-container&wt.mc_id=data-46726-chmaneu).

The last thing you must do is to add the environment variable `MEILI_DB_PATH` with the path used in your path mapping. 

That's it, you now have a Meilisearch instance hosted on Azure :).