DEV Community

Cover image for Deploy Meilisearch on Azure in One Click
Christopher Maneu
Christopher Maneu

Posted on • Originally published at

Deploy Meilisearch on Azure in 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, an open-source search API. It's easy to use, blazing fast, and comes with SDKs for a wide range of languages.

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

Azure portal asking deployment parameters

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

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, 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. Onwards, I'll assume you have a basic knowledge of this service :).

If you try to deploy 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!.

Melisearch dashboard hosted on Azure displaying search results with Harry Potter movies

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

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. 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

You can see how to mount a storage mapping to a Linux container in our documentation.

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 :).

Top comments (1)

mikedigitalegg profile image

Thanks for the guide, got us up an running quickly. Just a gotcha for anyone else using this guide... it looks like the databases are not backwards compatible so you should lock the image to a specific version rather than using getmeili/meilisearch:latest

eg. getmeili/meilisearch:v0.26.0

We had an issue where when the container was restarted it upgraded to latest (which was 0.27) so the app went down with an error due to database incompatibility.