# Install on Azure

The instructions provided help you to get your Squidex installation running on an Azure WebApp with the assets & MongoDB data hosted on Azure Storage and MongoDB running on an Azure Container Instance.

{% hint style="info" %}
Please note, that Azure also supports Docker Compose files so you can follow the Docker tutorial, especially if it is important for you to be independent from your Cloud provider (avoid vendor lock-in).
{% endhint %}

This tutorial does not cover the basics of Azure. You should be familiar with them before you begin with the installation instructions. We have attempted to keep the instructions simple enough so they can be followed by anyone.

This tutorial demonstrates running MongoDB as a single container and is recommended for non-production or trial environments. For production environments, it is best to use one of the MongoDB Atlas (or Enterprise) offerings from [Azure Marketplace](https://azuremarketplace.microsoft.com/en-us/marketplace/apps?search=mongodb\&page=1) with at least 3 members for High Availability etc.

## Requirements

Before you start you have to setup a few things first:

1. An active Azure subscription
2. A Resource Group for all your Squidex resources.
3. An App Service plan (Linux) to host Squidex.
4. A *Standard (General Purpose v2)* Storage Account for assets and MongoDB.
5. An installation of the [Azure-CLI](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest) on your developer machine (optional).
6. An installation of a MongoDB tool like [MongoDB Compass](https://www.mongodb.com/try/download/compass2) on your developer machine (optional).
7. The [Microsoft.ContainerInstance](https://azure.microsoft.com/en-gb/services/container-instances/) provider registered in your Azure subscription.

## 1. Setup your Storage Account

Execute the following steps in the storage account.

{% hint style="info" %}
You must have a storage account before continuing. The steps do not cover the process of storage account creation.
{% endhint %}

1. Click **Containers** (1) under *Data Storage* and then click **+ Container** (2) to load the *New container blade*.<br>

   <figure><img src="https://2730255609-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LrL94QfeasZ0wF6YAvB%2Fuploads%2FDEVQrlcCc0AHC4XHYeDs%2F2022-10-17_19-45.png?alt=media&#x26;token=f8835db8-6e41-492b-985b-1aa4f30305cc" alt=""><figcaption></figcaption></figure>
2. Create a container named `etc-squidex-assets`(3). Do not make any other modifications, click **Create** (4).<br>

   <div align="left"><figure><img src="https://2730255609-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LrL94QfeasZ0wF6YAvB%2Fuploads%2FU7iVYyfyP5YyTUdvQpYL%2F2022-10-17_19-55.png?alt=media&#x26;token=646f4d84-26cd-482a-8ec2-5d94a4479a16" alt=""><figcaption></figcaption></figure></div>
3. Similarly, select **File shares** (5), click **+ File share** (6) and create a file share named `etc-squidex-mongodb` (7). Click **Create** (8).<br>

   <figure><img src="https://2730255609-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LrL94QfeasZ0wF6YAvB%2Fuploads%2FgIZmTIvQNe7vq0CVv2QK%2F2022-10-17_20-03.png?alt=media&#x26;token=f342b624-979e-474b-94d3-deb597d55f21" alt=""><figcaption></figcaption></figure>
4. Next, note down the storage account *Connection String* and one of the *Access Keys* for use in the subsequent steps.\
   \
   To do so, go to **Access Keys** (9) and click **Show** (10) next to *Key* in key1. Copy this Access Key safely somewhere. Similarly click **Show** (11) next to *Connection string* and copy it.<br>

   <figure><img src="https://2730255609-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LrL94QfeasZ0wF6YAvB%2Fuploads%2FkaaI83CgKMtblMZYoPL3%2F2022-10-17_20-15.png?alt=media&#x26;token=5a6c6c92-6152-4fa1-a54d-c5e696d6b6c6" alt=""><figcaption></figcaption></figure>

## 2. Create the MongoDB Instance

To create the MongoDB Azure Container Instance we will use the Azure CLI. Using the browser based Azure Shell is the easiest and quickest way to run the command.&#x20;

<figure><img src="https://2730255609-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LrL94QfeasZ0wF6YAvB%2Fuploads%2FZ6fmTyXsXfskcpxLE11Q%2F2022-10-22_12-34.png?alt=media&#x26;token=70ed38f8-5348-4449-8854-41d11840197a" alt=""><figcaption></figcaption></figure>

You can also execute them through an installation of Azure CLI on your developer machine. If you are using your own installation of Azure CLI, on the command prompt run `az login` first to login to Azure (this step is not required if you are using Azure Shell).

{% hint style="info" %}
The following creation of the container instance can only be done using the Azure CLI at the moment.
{% endhint %}

Run the following command to create the MongoDB container instance. You will need the following values noted down from earlier:

* \[YOUR\_RESOURCE\_GROUP]
* \[YOUR\_STORAGE\_ACCOUNT]
* \[YOUR\_STORAGE\_KEY]

```bash
az container create --resource-group [YOUR_RESOURCE_GROUP] --name mongodb --image mongo --azure-file-volume-account-name [YOUR_STORAGE_ACCOUNT] --azure-file-volume-account-key "[YOUR_STORAGE_KEY]" --azure-file-volume-share-name etc-squidex-mongodb --azure-file-volume-mount-path "/data/mongoaz" --ports 27017 --cpu 2 --ip-address public --memory 2 --os-type Linux --protocol TCP --command-line "mongod --dbpath=/data/mongoaz --bind_ip_all --auth"
```

This creates a single container instance running MongoDB.

### 2.1 Create an Admin User

At this point the MongoDB instance is running but requires authentication. But we do not have any users, so we will go ahead and create a user for use with the database.&#x20;

Connect to your MongoDB container console from Azure:

1. Go to **Container instances** (1) and select your container, usually **mongodb** (2).
2. Click **Containers** (3) and then select the **Connect** tab (4).
3. Select **/bin/bash** and click **Connect** (5) button.

<figure><img src="https://2730255609-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LrL94QfeasZ0wF6YAvB%2Fuploads%2FFhhmPlY1Nv0s01W9QNXf%2F2022-10-18_17-06.png?alt=media&#x26;token=e9957fac-5d70-4988-9f3c-970810a51c81" alt=""><figcaption></figcaption></figure>

Execute the following steps inside the container to create a MongoDB user.

{% hint style="info" %}
For security reasons provide your own choice of username and password
{% endhint %}

```
// Switch to Mongo shell
mongosh

// Switch to admin db
use admin

// Create user
db.createUser({ "user": "root", "pwd": "1q2w3e$R", "roles": ["root"] })
```

Now that the user is created, you can optionally connect to it from a tool like [MongoDB Compass](https://www.mongodb.com/try/download/compass2) and verify connectivity. To connect, you will need the Public IP address of the MongoDB instance. To do so, go to **Container instances** (1), select your **container** (2) and from **Overview** (3) copy the **Public IP address** (4). Make a note of it as it will be needed again in future steps.

<figure><img src="https://2730255609-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LrL94QfeasZ0wF6YAvB%2Fuploads%2FouK8zYEE2x8bSDz5D6Lr%2F2022-10-18_17-29.png?alt=media&#x26;token=a4f98a5a-231f-4272-89cd-6aad75506410" alt=""><figcaption></figcaption></figure>

To connect to it from MongoDB Compass, create a connection string that contains the username and password similar to the example below.

`mongodb://root:1q2w3e$R@[IP_ADDRESS]`

## 3. Create & Configure the Web App

### 3.1 Create Web App

1. Start by creating a new Web App with the following settings. The wizard also lets you create a new App Service Plan (think Hosting Plan) if there isn't any.​

   1. Select the existing **Resource Group** (1) from previous steps
   2. Enter a **Web App Name** for the FQDN provided by Azure Web App.

      <div data-gb-custom-block data-tag="hint" data-style="info" class="hint hint-info"><p>This Name should be globally unique.</p></div>
   3. Select **Docker Container** (3)
   4. Choose **Linux** (4) for the Operating System
   5. Set your preferred **Region** (5), preferably the same region as other resources
   6. The default *Sku and size* selected is ideal for production environments and costs more. If this is a sandbox, trial or a non-production environment it is best to change this to a lower Sku. Click **Change size** (6) to do so and change it to *F1* or *B1*.
   7. Click **Next: Docker** to continue with the next steps.<br>

   <div align="left"><figure><img src="https://2730255609-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LrL94QfeasZ0wF6YAvB%2Fuploads%2FIwrxJ4ubSj7Q3Wa9iKgE%2F2022-10-22_09-32.png?alt=media&#x26;token=4e7bd02d-a58d-4d22-9573-114b81edb239" alt=""><figcaption></figcaption></figure></div>

   <figure><img src="https://2730255609-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LrL94QfeasZ0wF6YAvB%2Fuploads%2FiFgddzOXTxwrbEBkMxwY%2F2022-10-22_09-58.png?alt=media&#x26;token=840c2bea-d85b-41c1-b392-080ce99111c7" alt=""><figcaption></figcaption></figure>
2. In the *Docker* settings tab, configure as following:

   1. Set *Options* as **Single Container** (8)
   2. Set *Image Source* as **Docker Hub** (9)
   3. Set *Access Type* to **Public** (10)
   4. Enter *Image and tag value* as `squidex/squidex:latest`
   5. Click **Review + create** (12).

   <figure><img src="https://2730255609-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LrL94QfeasZ0wF6YAvB%2Fuploads%2FrfnTngNWPhBi5hdyxlHI%2F2022-10-22_10-03.png?alt=media&#x26;token=fb802200-b4db-4712-93cb-5da1ca1afd1b" alt=""><figcaption></figcaption></figure>
3. In the Review page, click **Create**.
4. Once deployment is complete, click **Go to resource** (14) and continue with the next section on configuring the environment variables.

   <figure><img src="https://2730255609-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LrL94QfeasZ0wF6YAvB%2Fuploads%2FzIBz6E7Kd0Vv6JHZyDdW%2F2022-10-22_11-02.png?alt=media&#x26;token=2e94205e-542e-463c-85db-aaa20066bafd" alt=""><figcaption></figcaption></figure>

### 3.2 Configure Web App

During this step, we will add the configuration values to the Web App and restart the Web App. Before proceeding ensure you have the following info handy, you will need it:

<table><thead><tr><th width="306.3333333333333">Key</th><th>Description</th><th>Sample</th></tr></thead><tbody><tr><td><code>[AZURE_CONNECTIONSTRING]</code></td><td>The connection string to your storage account. See step 1.</td><td></td></tr><tr><td><code>[MONGO_USERNAME]</code></td><td>The username of the MongoDB user.</td><td>For example in this instruction: "root"</td></tr><tr><td><code>[MONGO_PASSWORD]</code></td><td>The password of the MongoDB user.</td><td>For example in this instruction: "1q2w3e$R"</td></tr><tr><td><code>[MONGO_IP]</code></td><td>The IP address to your MongoDB container.</td><td>See Step 2.1</td></tr><tr><td><code>[WEBAPP_NAME]</code></td><td>The name of your webapp. </td><td>For example in this instruction "squidexio"</td></tr></tbody></table>

1. From the previous step you should already be in the Web App page. Click **Configuration** (1) and then **Advanced edit** (2).

   <div align="left"><figure><img src="https://2730255609-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LrL94QfeasZ0wF6YAvB%2Fuploads%2FrBPFfRlI3XOCj2gOvq0K%2F2022-10-22_11-23.png?alt=media&#x26;token=58eb2672-ef70-4991-aa7e-246fc6f0ed8d" alt=""><figcaption></figcaption></figure></div>
2. Copy and paste the following JSON into the code window (**DO NOT click OK.**)

   ```javascript
   [
     {
       "name": "ASSETSTORE__AZUREBLOB__CONNECTIONSTRING",
       "value": "[AZURE_CONNECTIONSTRING]",
       "slotSetting": false
     },
     {
       "name": "ASSETSTORE__AZUREBLOB__CONTAINERNAME",
       "value": "etc-squidex-assets",
       "slotSetting": false
     },
     {
       "name": "ASSETSTORE__TYPE",
       "value": "AzureBlob",
       "slotSetting": false
     },
     {
       "name": "DOCKER_REGISTRY_SERVER_PASSWORD",
       "value": "",
       "slotSetting": false
     },
     {
       "name": "DOCKER_REGISTRY_SERVER_URL",
       "value": "https://index.docker.io",
       "slotSetting": false
     },
     {
       "name": "DOCKER_REGISTRY_SERVER_USERNAME",
       "value": "",
       "slotSetting": false
     },
     {
       "name": "EVENTSTORE__MONGODB__CONFIGURATION",
       "value": "mongodb://[MONGO_USER]:[MONGO_PASSWORD]@[MONGO_IP]:27017",
       "slotSetting": false
     },
     {
       "name": "IDENTITY__GITHUBCLIENT",
       "value": "",
       "slotSetting": false
     },
     {
       "name": "IDENTITY__GITHUBSECRET",
       "value": "",
       "slotSetting": false
     },
     {
       "name": "IDENTITY__GOOGLECLIENT",
       "value": "",
       "slotSetting": false
     },
     {
       "name": "IDENTITY__GOOGLESECRET",
       "value": "",
       "slotSetting": false
     },
     {
       "name": "IDENTITY__MICROSOFTCLIENT",
       "value": "",
       "slotSetting": false
     },
     {
       "name": "IDENTITY__MICROSOFTSECRET",
       "value": "",
       "slotSetting": false
     },
     {
       "name": "STORE__MONGODB__CONFIGURATION",
       "value": "mongodb://[MONGO_USER]:[MONGO_PASSWORD]@[MONGO_IP]:27017",
       "slotSetting": false
     },
     {
       "name": "URLS__BASEURL",
       "value": "https://[WEBAPP NAME].azurewebsites.net/",
       "slotSetting": false
     },
     {
       "name": "VIRTUAL_HOST",
       "value": "[WEBAPP NAME].azurewebsites.net",
       "slotSetting": false
     },
     {
       "name": "WEBSITE_HTTPLOGGING_RETENTION_DAYS",
       "value": "10",
       "slotSetting": false
     }
   ]
   ```
3. Replace all placeholders with your values (without additional quotes). It should look similar to the screenshot below. Click **OK** (3) when done.\
   Configuration values for external authentication providers are empty to turn them off.

   <div align="left"><figure><img src="https://2730255609-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LrL94QfeasZ0wF6YAvB%2Fuploads%2FAyX7Tzw6GBBZRd9dkCHd%2F2022-10-22_11-35.png?alt=media&#x26;token=f27035be-dd2c-4517-9835-ca090817f589" alt=""><figcaption></figcaption></figure></div>
4. Click **Save** (4).

   <div align="left"><figure><img src="https://2730255609-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LrL94QfeasZ0wF6YAvB%2Fuploads%2F1MLSu77JoXtZTJMHCqgR%2F2022-10-22_11-37.png?alt=media&#x26;token=132e5967-af24-40b5-b613-cc3edb1df6fd" alt=""><figcaption></figcaption></figure></div>
5. Click **Overview** (5) and then click **Restart** (6). Click **Yes** (7) when prompted.<br>

   <figure><img src="https://2730255609-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LrL94QfeasZ0wF6YAvB%2Fuploads%2F4Ye6Yl0C7pJ2og5RoWSW%2F2022-10-22_11-46.png?alt=media&#x26;token=ea0050f5-d140-4210-af76-bd67a4694206" alt=""><figcaption></figcaption></figure>
6. You can now access Squidex at the App Service URL and continue with setting up Squidex.

{% hint style="info" %}
**IMPORTANT:** It may take a few minutes before Squidex welcome page loads due to background configurations and setup processes by Azure.&#x20;

If the restart in Step 5 above does not work, stop and start the Web App.
{% endhint %}

### 3.3 Turn on Logging

While this is an optional step, logging can make diagnostics easier.

{% hint style="info" %}
You can then use the *Log stream* to view all log entries
{% endhint %}

1. Next from the left menu scroll down (or search) and click on **App Service logs** (1). Enable Application logging by clicking on **File System** (2) and click **Save** (3).<br>

   <div align="left"><figure><img src="https://2730255609-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LrL94QfeasZ0wF6YAvB%2Fuploads%2FYtLCYWnMN5JuvlP3xO7L%2F2022-10-22_12-15.png?alt=media&#x26;token=1e0f808d-82e6-49ab-bebd-8c7792e68fee" alt=""><figcaption></figcaption></figure></div>

## More issues?

For other issues, it is likely that you have a configuration problem not related to hosting under Azure. Checkout the following documentation:

{% content-ref url="../configuration" %}
[configuration](https://docs.squidex.io/id-01-getting-started/installation/configuration)
{% endcontent-ref %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.squidex.io/id-01-getting-started/installation/platforms/install-on-azure.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
