# Deploying Polarity Server Virtual Machine on Azure

* Setup the Virtual Machine
  * Basics
  * Disk
  * Networking
  * Management, Advanced
  * Tags
  * SSH Access
* Configuring Disks
  * Get Disk Names
  * Partition Disks
  * Format Disks
  * Mount the Partitions
* Install Polarity Server
  * Install the Polarity License
  * Update FQDN in Polarity Config
  * Tune PostgreSQL
    * Polarity Server with 16 GB of RAM
  * Polarity Server with 32 GB of RAM
  * Polarity Server with 64 GB of RAM

### Setup the Virtual Machine <a href="#deployingpolarityservervirtualmachineonazure-setupthevirtualmachine" id="deployingpolarityservervirtualmachineonazure-setupthevirtualmachine"></a>

The following guide walks through setting up a Polarity Server within the Azure Virtual Machine environment using Polarity provided CentOS 7 RPMs. Within Azure, navigate to Virtual Machines and add a new one.

#### Basics <a href="#deployingpolarityservervirtualmachineonazure-basics" id="deployingpolarityservervirtualmachineonazure-basics"></a>

| **Option**           | **Value**                                                                                                                                                                                                                                                                                                                |
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Virtual Machine Name | polarity-server                                                                                                                                                                                                                                                                                                          |
| Region               | *Please pick appropriate region for your users*                                                                                                                                                                                                                                                                          |
| Availability options | No infrastructure redundancy required                                                                                                                                                                                                                                                                                    |
| Image                | RedHat Enterprise Linux 8.6+                                                                                                                                                                                                                                                                                             |
| Size                 | <p>Standard\_D4s\_v4 - 4 vcpus, 16 GiB memory (Pilot Deployment)</p><p>Standard\_D8s\_v4 - 8 vcpus, 32 GiB memory (10-50 users)</p><p>Standard\_D16\_v4 - 16 vcpus, 64 GiB memory (50+ users)</p><p>Please contact <a href="mailto:support@polarity.io"><support@polarity.io></a> for additional sizing information.</p> |
| Authentication type  | SSH public key                                                                                                                                                                                                                                                                                                           |
| Username             | azureuser                                                                                                                                                                                                                                                                                                                |
| Inbound port rules   | Allow selected ports                                                                                                                                                                                                                                                                                                     |
| Inbound Port Rules   | <p>SSH (22), HTTP (80), HTTPS (443)</p><p>\*HTTP inbound access (port 80) is required for LetsEncrypt SSL certificate. Port 80 is redirected to Port 443 by the server and is not required to be open.</p>                                                                                                               |

#### Disk <a href="#deployingpolarityservervirtualmachineonazure-disk" id="deployingpolarityservervirtualmachineonazure-disk"></a>

| **Option**      | **Value**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| OS disk type    | Premium SSD                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| Encryption type | (Default) encryption at-rest with a platform-managed key                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| Data disks      | <p>Add two additional disks (Create and attach a new disk)</p><p>Disk 1:</p><p>Name: polarity-server\_DataDiskVar\_0<br>Size: 128 GiB Premium SSD</p><p>Disk 2:</p><p>Name: polarity-server\_DataDiskApp\_0<br>Size: 64 GiB Premium SSD</p><p>\*Note that while the Polarity server can be run off a single partition (we’d recommend a minimum of 128 GiB for the partition), better performance can be achieved if the PostgreSQL database runs on its own partition (polarity-server\_DataDiskVar\_0).</p> |

#### Networking <a href="#deployingpolarityservervirtualmachineonazure-networking" id="deployingpolarityservervirtualmachineonazure-networking"></a>

| **Option**                 | **Value**                                                                                                                                                                                                  |
| -------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Virtual Network            | \*Use default                                                                                                                                                                                              |
| Subnet                     | \*Use default                                                                                                                                                                                              |
| Public IP                  | \*Use default                                                                                                                                                                                              |
| NIC network security group | Basic                                                                                                                                                                                                      |
| Select inbound ports       | <p>SSH (22), HTTP (80), HTTPS (443)</p><p>\*HTTP inbound access (port 80) is required for LetsEncrypt SSL certificate. Port 80 is redirected to Port 443 by the server and is not required to be open.</p> |
| Accelerated Networking     | On                                                                                                                                                                                                         |
| Load balancing             | No                                                                                                                                                                                                         |

#### Management, Advanced <a href="#deployingpolarityservervirtualmachineonazure-management-advanced" id="deployingpolarityservervirtualmachineonazure-management-advanced"></a>

Use default settings for both Management, and Advanced configuration unless otherwise required by your organization.

#### Tags <a href="#deployingpolarityservervirtualmachineonazure-tags" id="deployingpolarityservervirtualmachineonazure-tags"></a>

Apply system tags as required by your organization.

#### SSH Access <a href="#deployingpolarityservervirtualmachineonazure-sshaccess" id="deployingpolarityservervirtualmachineonazure-sshaccess"></a>

When creating the Virtual Machine, you will be given the option to download the private key in `PEM` format. Download the key and keep it in a safe place. If you are using the `pem` key with Putty you will need to convert it into the `ppk` format using the PuttyGen application <https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html>

### Configuring Disks <a href="#deployingpolarityservervirtualmachineonazure-configuringdisks" id="deployingpolarityservervirtualmachineonazure-configuringdisks"></a>

Most command will need to be run as `root` either via `sudo` or changing to the `root` user.

The following instructions provide information on how to setup two partitions on your Polarity Server. If you have other tools for partitioning your disks you can skip the below instructions. You will want to have `/var` on one partition for the database (128+ GiB recommended), and `/app` on another partition (64+ GiB recommended).

Once the VM is up and running SSH into the server to begin the configuration process. To start we will configure the two additional disks we added when creating the server.

We added two additional disks when setting up the VM. The first 128 GiB disk is will be used to mount `/var` onto. The `/var` directory contains our PostgreSQL database and other system logs.

The second 64 GiB disk will be used to mount `/app` which contains the Polarity server code, Polarity server logs, integrations, and integration logs.

To set up the disks we will need to do the following:

1. Get the names of the disks
2. Create partitions using `fdisk`
3. Format the disks to XFS using `mkfs.xfs`
4. Move `/var` to the new 128 GiB disk and mount the disk
5. Mount the new 64 GiB disk to `/app`

#### Get Disk Names <a href="#deployingpolarityservervirtualmachineonazure-getdisknames" id="deployingpolarityservervirtualmachineonazure-getdisknames"></a>

To check the names of the disk use the command `lsblk`

```
[azureuser@polarity-server ~]$ lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
fd0      2:0    1    4K  0 disk
sda      8:0    0   30G  0 disk
├─sda1   8:1    0  500M  0 part /boot
└─sda2   8:2    0 29.5G  0 part /
sdb      8:16   0   32G  0 disk
└─sdb1   8:17   0   32G  0 part /mnt/resource
sdc      8:32   0  128G  0 disk
sdd      8:48   0   64G  0 disk
sr0     11:0    1 1024M  0 rom
```

In the output above you can see that our 128 GiB disk meant for `/var` is named `sdc` and our 64 GiB disk meant for `/app` is named `sdd`. The disks should also be represented as files in the `/dev` directory.

The disk names may be flipped depending on the order you added the disks to the Virtual Machine. If the disk names are different, ensure `/var` is mapped to the 128 GiB disk, and that `/app` is mapped to the 64 GiB disk.

#### Partition Disks <a href="#deployingpolarityservervirtualmachineonazure-partitiondisks" id="deployingpolarityservervirtualmachineonazure-partitiondisks"></a>

Now that we have the disk names we will create partitions on both disks. We’ll start with `sdc`:

```
fdisk /dev/sdc
```

Type `n` to create a new partition and then `p` for a primary partition.

```
Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p):
```

Use the default partition settings which will create a single primary partition across the entire disk.

Finally, you will need to write the partition to the disk by typing `w`.

```
Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
```

Repeat the same process for `/dev/sdd`

```
fdisk /dev/sdd
```

When running `lsblk` you will now see the partitions `sdc1` and `sdd1`

```
[azureuser@polarity-server ~]$ lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
fd0      2:0    1    4K  0 disk
sda      8:0    0   30G  0 disk
├─sda1   8:1    0  500M  0 part /boot
└─sda2   8:2    0 29.5G  0 part /
sdb      8:16   0   32G  0 disk
└─sdb1   8:17   0   32G  0 part /mnt/resource
sdc      8:32   0  128G  0 disk
└─sdc1   8:33   0  128G  0 part 
sdd      8:48   0   64G  0 disk
└─sdd1   8:49   0   64G  0 part 
sr0     11:0    1 1024M  0 rom
```

#### Format Disks <a href="#deployingpolarityservervirtualmachineonazure-formatdisks" id="deployingpolarityservervirtualmachineonazure-formatdisks"></a>

Now that the disks are partitioned we can format them with `xfs` using the utility `mkfs.xfs`

```
mkfs.xfs /dev/sdc1
mkfs.xfs /dev/sdd1
```

#### Mount the Partitions <a href="#deployingpolarityservervirtualmachineonazure-mountthepartitions" id="deployingpolarityservervirtualmachineonazure-mountthepartitions"></a>

The final step is to mount the new partitions we created. We’ll start with `sdc1` which is the 128 GiB disk as we will need to first transfer the current `/var` contents.

```
mkdir /mnt/newvar
mount /dev/sdc1 /mnt/newvar
```

Next we will copy the current contents of `/var` to the new location

```
rsync -aqxPX /var/* /mnt/newvar
```

The flags on rsync are very important. In particular the `X` flag will ensure selinux contexts are copied.

Now that the contents of `/var` have been copied we can unmount `/mnt/newvar`

```
umount /mnt/newvar/
```

Next, we’ll mount our `/app` directory onto `sdd1`. Since this directory does not currently exist we do not need to copy any contents into it:

```
mount /dev/sdd1 /app
```

Next we’ll want to get the `UUID` values for our two disks so we can permanently add the mount points to our `/etc/fstab` file. We can use the `blkid` command to get the UUIDs of the disks:

```
[azureuser@polarity-server ~]$ blkid
/dev/sdb1: UUID="025f92de-eae0-4443-b815-59b670e17e9d" TYPE="ext4"
/dev/sdc1: UUID="a868cbc7-20cb-430d-820f-1b602164d07d" TYPE="xfs"
/dev/sdd1: UUID="13ea2266-14db-4159-8544-5a53abe8347a" TYPE="xfs"
/dev/sda1: UUID="fa2f8157-21c9-43b6-85e3-ff04422dfa00" TYPE="xfs"
/dev/sda2: UUID="12907c8a-6b2f-4981-b94c-f3cd772270a7" TYPE="xfs"
```

Copy down the UUID value for `/dev/sdc1` and `/dev/sdd1`. Next, open the `/etc/fstab` file for editing and add the following two lines to the bottom. Make sure the UUID for `/app` maps to the 64 GiB drive, and that the UUID for `/var` maps to the 128 GiB drive.

```
vi /etc/fstab
```

Then add the following two lines to the bottom of the file and save the changes.

```
UUID=13ea2266-14db-4159-8544-5a53abe8347a /app                    xfs     defaults        0 2
UUID=a868cbc7-20cb-430d-820f-1b602164d07d /var                    xfs     defaults        0 3
```

Your UUID values will be different than those above

Restart the virtual machine to finish (can be done from the Azure web interface).

When the virtual machine restarts, SSH in and check to make sure all your partitions were mounted correctly.

```
[azureuser@polarity-server ~]$ lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
fd0      2:0    1    4K  0 disk
sda      8:0    0   30G  0 disk
├─sda1   8:1    0  500M  0 part /boot
└─sda2   8:2    0 29.5G  0 part /
sdb      8:16   0   32G  0 disk
└─sdb1   8:17   0   32G  0 part /mnt/resource
sdc      8:32   0  128G  0 disk
└─sdc1   8:33   0  128G  0 part /var
sdd      8:48   0   64G  0 disk
└─sdd1   8:49   0   64G  0 part /app
sr0     11:0    1 1024M  0 rom
```

You should see the `sdc1` partition (128 GiB) with a mountpoint of `/var` and the `sdd1` partition (64 GiB) with a mount point of `/app`.

### Install Polarity Server <a href="#deployingpolarityservervirtualmachineonazure-installpolarityserver" id="deployingpolarityservervirtualmachineonazure-installpolarityserver"></a>

Now that our disks are configured we’re ready to install the Polarity Server.

Please contact your Polarity customer success representative for the latest installation instructions on your preferred Operating System.

<customersucces@polarity.io>

Supported operating systems are RHEL 7, Amazon Linux 2, RHEL 8 and Oracle Linux 8.

Once the Polarity Software is installed you can continue with the below steps.

#### Install the Polarity License <a href="#deployingpolarityservervirtualmachineonazure-installthepolaritylicense" id="deployingpolarityservervirtualmachineonazure-installthepolaritylicense"></a>

At this point you will need to install your Polarity License provided to you by your Polarity support or customer success team. The license file will be named `polarity.lic`. Upload the `polarity.lic` license file to the Polarity Server.

Copy the `polarity.lic` file to the license directory

```
cp polarity.lic /app/polarity-server/license/polarity.lic
```

Ensure the license file is owned by the `polarityd` user

```
chown polarityd:polarityd /app/polarity-server/license/polarity.lic
```

Finally restart your server so the license is loaded

```
systemctl restart polarityd
```

You can now navigate to the polarity web interface by opening a browser (Chrome is recommended) and navigating to `https://<your-polarity-server>`

You can login with the default user `admin` and the password `PolarityServer2015!`

#### Update FQDN in Polarity Config <a href="#deployingpolarityservervirtualmachineonazure-updatefqdninpolarityconfig" id="deployingpolarityservervirtualmachineonazure-updatefqdninpolarityconfig"></a>

By default the Polarity server will assume the FQDN for your server matches the server hostname. If this is not the case, you will need to modify the Polarity Server config file to set the appropriate config.

To modify the Polarity server config begin by opening the config file in an editor.

```
vi /app/polarity-server/config/config.js
```

Find the setting `rest.fullyQualifiedDomainName` and set it to your FQDN

```
"rest": {
   "fullyQualifiedDomainName": "your.fqdn.com"
}
```

Save the change and restart the server:

```
systemctl restart polarityd
```

#### Tune PostgreSQL <a href="#deployingpolarityservervirtualmachineonazure-tunepostgresql" id="deployingpolarityservervirtualmachineonazure-tunepostgresql"></a>

The following parameters were changed from their default values on the PostgreSQL database. To edit the settings open the `postgresql.conf` file located at `/var/lib/pgsql/13/data/postgresql.conf`.

```
vi /var/lib/pgsql/13/data/postgresql.conf
```

Adjust settings per the table below and then restart PostgreSQL and the Polarity Server

```
systemctl restart postgresql-13
systemctl restart polarityd
```

**Polarity Server with 16 GB of RAM**

| **Setting**               | **Value**                                                   |
| ------------------------- | ----------------------------------------------------------- |
| max\_connections          | 100                                                         |
| shared\_buffers           | 1843MB                                                      |
| work\_mem                 | 18MB                                                        |
| maintenance\_work\_mem    | 896MB                                                       |
| random\_page\_cost        | <p>1.5</p><p>\*If using SSDs, otherwise leave unchanged</p> |
| max\_wal\_size            | 4GB                                                         |
| effective\_cache\_size    | 5500MB                                                      |
| cpu\_tuple\_cost = 0.0030 | 0.0030                                                      |
| cpu\_index\_tuple\_cost   | 0.0010                                                      |
| cpu\_operator\_cost       | 0.0005                                                      |

#### Polarity Server with 32 GB of RAM <a href="#deployingpolarityservervirtualmachineonazure-polarityserverwith32gbofram" id="deployingpolarityservervirtualmachineonazure-polarityserverwith32gbofram"></a>

| **Setting**               | **Value**                                                   |
| ------------------------- | ----------------------------------------------------------- |
| max\_connections          | 100                                                         |
| shared\_buffers           | 4700MB                                                      |
| work\_mem                 | 47MB                                                        |
| maintenance\_work\_mem    | 2355MB                                                      |
| random\_page\_cost        | <p>1.5</p><p>\*If using SSDs, otherwise leave unchanged</p> |
| max\_wal\_size            | 4GB                                                         |
| effective\_cache\_size    | 14GB                                                        |
| cpu\_tuple\_cost = 0.0030 | 0.0030                                                      |
| cpu\_index\_tuple\_cost   | 0.0010                                                      |
| cpu\_operator\_cost       | 0.0005                                                      |

#### Polarity Server with 64 GB of RAM <a href="#deployingpolarityservervirtualmachineonazure-polarityserverwith64gbofram" id="deployingpolarityservervirtualmachineonazure-polarityserverwith64gbofram"></a>

| **Setting**               | **Value**                                                   |
| ------------------------- | ----------------------------------------------------------- |
| max\_connections          | 100                                                         |
| shared\_buffers           | 10GB                                                        |
| work\_mem                 | 100MB                                                       |
| maintenance\_work\_mem    | 5GB                                                         |
| random\_page\_cost        | <p>1.5</p><p>\*If using SSDs, otherwise leave unchanged</p> |
| max\_wal\_size            | 4GB                                                         |
| effective\_cache\_size    | 30GB                                                        |
| cpu\_tuple\_cost = 0.0030 | 0.0030                                                      |
| cpu\_index\_tuple\_cost   | 0.0010                                                      |
| cpu\_operator\_cost       | 0.0005                                                      |


---

# 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.polarity.io/polarity-admin-guide/GGQxi8U7L785oCyu5JjE/sever-requirements/deployment-methods/deploying-polarity-server-virtual-machine-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.
