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 🚀
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.
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.
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.
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!.
But what happens if you stop or restart your instance? All your indexed data is gone!
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.
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 :).