# Azure Container App

<figure><img src="https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_i6vKdtG6Z2n6zWgJ%2Fuploads%2FiyM8WoJ64cPCYwYOK5Ms%2FAzure%20Container%20Service.jpg?alt=media&#x26;token=232a22f7-8d04-455c-9e6d-fc4133d5ca45" alt=""><figcaption></figcaption></figure>

## Overview

This guide provides step-by-step instructions to publish Keeper Automator to the Azure Container App service. This provides a simple and straightforward way to host the Automator service in the cloud.

{% hint style="info" %}
For environments such as **Azure Government**, **GCC High** and **DoD**, use the [Azure App Services method](https://docs.keeper.io/en/sso-connect-cloud/device-approvals/automator/azure-app-services), since the Azure Container App service may not be available in those regions.
{% endhint %}

### (1) Create an Automator Config key

Open a command line interface and generate a 256-bit AES key in URL-encoded format using one of the methods below, depending on your operating system:

#### Generate a Key

{% tabs %}
{% tab title="Mac/Linux" %}

```
openssl rand -base64 32
```

{% endtab %}

{% tab title="Windows (PowerShell)" %}

```powershell
[Byte[]]$key = New-Object Byte[] 32; [System.Security.Cryptography.RNGCryptoServiceProvider]::Create().GetBytes($key); [System.Convert]::ToBase64String($key)
```

{% endtab %}
{% endtabs %}

Save the resulting value produced by this command for **Step (3)**.

<figure><img src="https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_i6vKdtG6Z2n6zWgJ%2Fuploads%2FG7t1VQUdCjutMBikVSzM%2FScreenshot%202023-12-12%20at%2012.39.19%20PM.png?alt=media&#x26;token=39ff6d4c-e0e3-4a5e-b4fc-56dac5799aeb" alt="" width="375"><figcaption><p>Example of generated key value in Mac/Linux</p></figcaption></figure>

<figure><img src="https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_i6vKdtG6Z2n6zWgJ%2Fuploads%2FZnls6xq1ILfPIShOzhz4%2Fpowershell_ise_CWVvD57ReW.png?alt=media&#x26;token=c88f625f-def8-4004-ac81-4f82c9dc5c52" alt=""><figcaption><p>Example of generated key value in PowerShell</p></figcaption></figure>

### (2) Create a Container Registry

If you do not already have a container registry, you must create one and configure as you see fit. Example below.

<figure><img src="https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_i6vKdtG6Z2n6zWgJ%2Fuploads%2FX0sWfXD1OLOdsN6GOySS%2Fimage.png?alt=media&#x26;token=6cb2523e-bbda-427b-805b-ad1c597f10a7" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_i6vKdtG6Z2n6zWgJ%2Fuploads%2FCz9C645mTtgysG4mORpE%2Fimage.png?alt=media&#x26;token=205f43ce-47f1-48e8-b892-b82b796d7620" alt=""><figcaption></figcaption></figure>

### (3) Create a Container App

From Azure, create a new Container App.

<figure><img src="https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_i6vKdtG6Z2n6zWgJ%2Fuploads%2FW3LPFJ5buGX1dV0eHePh%2Fimage.png?alt=media&#x26;token=c7cfa00c-ec22-4ae7-a6a0-89e0af24de0e" alt=""><figcaption></figcaption></figure>

* Select or create a new Resource Group
* Set the Container App Name to "keeperautomator" or whatever you prefer
* Select "Container Image" as the Deployment Source
* Select the region where you would like the service hosted
* Create a new Apps Environment or select an existing environment
* Click **`Next : Container >`**

<figure><img src="https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_i6vKdtG6Z2n6zWgJ%2Fuploads%2F4tsoj3svGDp9OZYuN77y%2Fimage.png?alt=media&#x26;token=aa418c1e-2e3b-49b6-81c6-f92db78ad185" alt=""><figcaption></figcaption></figure>

### (4) Setup Container Details

In the "Container" step, make the following selections:

* Uncheck the "**Use quickstart image**"
* Select "**Docker Hub or other registries**"
* Select "**Public**"
* Select Registry login server as **`docker.io`**
* Set the Image and tag as **`keeper/automator:latest`**
* Skip to "Container resource allocation"
* For CPU and Memory, **0.5 CPU** cores and **1Gi** memory is sufficient, but this can be updated based on your volume of new device logins.
* Create an environment variable called **`AUTOMATOR_CONFIG_KEY`** with the value from Step 1 above of the setup guide.
* Create an environment variable called **`AUTOMATOR_PORT`** with the value of **`8089`**
* Create an environment variable called **`SSL_MODE`** with the value of **`none`**
* Click "**Next : Ingress >"**

<figure><img src="https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_i6vKdtG6Z2n6zWgJ%2Fuploads%2FNWrBajjoTL4A3kkhutyw%2Fimage.png?alt=media&#x26;token=a2327378-f24a-4d6c-9906-66635c9c725e" alt=""><figcaption></figcaption></figure>

### (5) Ingress Setup

On the Ingress setup screen, select the following:

* **`Enable`** Ingress
* Ingress traffic **`Accepting traffic from anywhere`** (we'll modify this in a later step)
* Ingress type **`HTTP`**
* Target port set to **`8089`**

<figure><img src="https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_i6vKdtG6Z2n6zWgJ%2Fuploads%2F6p7HI3bIhSIHLK0G7iln%2Fimage.png?alt=media&#x26;token=61efb806-b28d-44ce-bc0d-a16ab97ccb50" alt=""><figcaption></figcaption></figure>

### (6) Create Container App

Click "**Review + Create"** and then click "**Create"**

After a few minutes, the container app will be created and automatically start up.

Clicking on "Go to Resource" will take you to the container environment.

<figure><img src="https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_i6vKdtG6Z2n6zWgJ%2Fuploads%2Femv4RBoEMpo3oalntOvt%2Fimage.png?alt=media&#x26;token=b50742ae-1ffc-49fd-a519-91c87d0925d2" alt=""><figcaption></figcaption></figure>

### (7) Customize the Ingress Setup

To restrict communications to the Keeper Automator service, click on the "Ingress" link on the left side of the screen under the "Network" section

* Click on "**Ingress"**
* Select "**Allow traffic from IPs configured below, deny all other traffic**"
* Click "**Add**" to add [two of Keeper's IPs](https://docs.keeper.io/en/sso-connect-cloud/device-approvals/automator/ingress-requirements) and any of your IPs required for testing the service. Ingress Requirements information: [Located Here](https://docs.keeper.io/en/sso-connect-cloud/device-approvals/automator/ingress-requirements)
* Click **Save**

<figure><img src="https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_i6vKdtG6Z2n6zWgJ%2Fuploads%2Fwztn8Q6tNSHScXtvYlYy%2Fimage.png?alt=media&#x26;token=85e33d55-b8f8-400a-837f-04759d5aa492" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
If you want to be able to run a health check, then consider adding your own IP address. Find your IP address at <https://checkip.amazonaws.com>
{% endhint %}

### (8) Set Scaling

* Select Application > Scale and set min and max replicas to 1
* Click "Save as a new revision"

<figure><img src="https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_i6vKdtG6Z2n6zWgJ%2Fuploads%2FeXLMCCZt7ZfEvgoIuD8J%2Fimage.png?alt=media&#x26;token=e719180c-e414-48f9-97d1-e0ac790ac358" alt=""><figcaption></figcaption></figure>

### (9) Create Volume

* Select Application > Volumes and click "+ Add"
* Add a Ephemeral Storage and name it as you wish and click "Add"

<figure><img src="https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_i6vKdtG6Z2n6zWgJ%2Fuploads%2F3XIV3CpY790VFw7gpUpO%2Fimage.png?alt=media&#x26;token=fdbd2725-2860-451f-8438-48e2a1148d96" alt=""><figcaption></figcaption></figure>

* Then click "Save as a new revision"

<figure><img src="https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_i6vKdtG6Z2n6zWgJ%2Fuploads%2FAZpBaOrTzwZ7zztRfE62%2Fimage.png?alt=media&#x26;token=189b3050-398a-47a8-8c32-10014240354d" alt=""><figcaption></figcaption></figure>

### (10) Set up Health Probes and Volume Mount

Navigate to the "Application > Revisions and Replicas" section"

Click on "Create new revision"

<figure><img src="https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_i6vKdtG6Z2n6zWgJ%2Fuploads%2FuS8DD2RWzqD2pRa4xPrT%2Fimage.png?alt=media&#x26;token=398c7761-97ba-4d22-b4f6-930eb7fee054" alt=""><figcaption></figcaption></figure>

Click on Application > Revisions and replicas an observe a new revision being activated

* Next, click on the "**Container**" tab
* Click on the container image name link, in this case "**keeperautomator**" at the bottom

<figure><img src="https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_i6vKdtG6Z2n6zWgJ%2Fuploads%2FMrGYBnDqhUCsKg0R1ERc%2FOpen%20Container%20to%20edit%20health%20and%20liveness%20probes.jpg?alt=media&#x26;token=e8470f07-6e03-4d7b-b6a3-bebdf13fdb19" alt=""><figcaption></figcaption></figure>

**Navigate to Health Probes and enter the following under each section:**

**Under "Liveness probes":**

* **Enable** liveness probes
* Transport: **`HTTP`**
* Path: **`/health`**
* Port: **`8089`**
* Initial delay seconds: **`5`**
* Period seconds: **`30`**

<figure><img src="https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_i6vKdtG6Z2n6zWgJ%2Fuploads%2F4kwBiw83kFwEbPComHYg%2Fchrome_oINWWurlIE.png?alt=media&#x26;token=a72780ce-2aec-4372-9c8c-41b01b9652b7" alt="" width="563"><figcaption><p>Liveness probes</p></figcaption></figure>

**Under "Startup probes":**

* **Enable** startup probes
* Transport: **`HTTP`**
* Path: **`/health`**
* Port: **`8089`**
* Initial delay seconds: **`5`**
* Period seconds: **`30`**

**Under "Volume Mounts" tab:**

* Select "+ Add"
* Select the volume you created in a previous step and Add Mount Path as **`/usr/mybin/config`**

<figure><img src="https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_i6vKdtG6Z2n6zWgJ%2Fuploads%2FFMTQ8OrQWKcfmW8N6eVT%2Fimage.png?alt=media&#x26;token=df28de65-d05f-4ace-adec-4f16e066d5b8" alt=""><figcaption></figcaption></figure>

**Finish the configuration**

* Click on **`Save`**
* Then click on **`Create`** to build the new configuration
* After a few minutes, the new containers should start up

### (11) Retrieve the Application URL

Wait until the revision is done activating.

From the Overview section of the Container App, on the right side is the "Application URL" that was assigned. Copy this and use this Application URL in the next step.

For example, <https://craigautomator1.xyx-1234.azurecontainerapps.io>

<figure><img src="https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_i6vKdtG6Z2n6zWgJ%2Fuploads%2FxM55uGuCaW5JpNYeAWwA%2F5-copy-url.png?alt=media&#x26;token=8302e2f2-b0e0-4553-8ec7-d92389302a17" alt=""><figcaption><p>Retrieve the Application URL</p></figcaption></figure>

### (12) Login to Keeper Commander

Keeper Commander is required to perform the final step of Automator configuration. This can be run from anywhere, it does not need to be installed on the server.

On your workstation or server, install Keeper Commander CLI. The installation instructions including binary installers are here:\
[https://docs.keeper.io/secrets-manager/commander-cli/commander-installation-setup](https://docs.keeper.io/keeperpam/commander-cli/commander-installation-setup)\
\
After Commander is installed, launch Keeper Commander, or from an existing terminal you can type `keeper shell` to open the session, then login using the `login` command. In order to set up Automator, you must login as a Keeper Administrator, or an Admin with the ability to manage the SSO node.

```
$ keeper shell

My Vault> login admin@company.com

  _  __  
 | |/ /___ ___ _ __  ___ _ _ 
 | ' </ -_) -_) '_ \/ -_) '_|
 |_|\_\___\___| .__/\___|_|
 v16.x.xxx    |_|

 password manager & digital vault

Logging in to Keeper Commander
Enter password for admin@company.com
Password: ********************
Successfully authenticated with Master Password
Syncing...
Decrypted [58] record(s)

My Vault>
```

### (13) Create the Automator

\
Create the Automator using a series of commands, starting with `automator create` with your node name.

```
My Vault> automator create --name "My Automator" --node "Azure Cloud"
```

The Node Name (in this case "Azure Cloud") comes from the Admin Console UI as seen below.

![Automator Create](https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MB_i6vKdtG6Z2n6zWgJ%2F-MjGtCqu00Eduh1ZVB0V%2F-MjGwSk57QheWM55KqUd%2FScreen%20Shot%202021-09-10%20at%203.59.58%20PM.png?alt=media\&token=732b0e49-b10f-4718-a78e-f48af15ef50c)

The output of the command will display the Automator settings, including metadata from the identity provider.

```
                    Automator ID: 1477468749950
                            Name: My Automator
                             URL: 
                         Enabled: No
                     Initialized: No
                          Skills: Device Approval
```

Note that the "URL" is not populated yet. This is the Application URL from Step 8.

Run the "automator edit" command as displayed below, which sets the URL and also sets up the skills (`team`, `team_for_user` and `device`).

{% code overflow="wrap" %}

```
automator edit --url https://<application URL> --skill=team --skill=team_for_user --skill=device "My Automator"
```

{% endcode %}

Next we exchange keys: The enterprise private key encrypted with the Automator public key is provided to Automator:

```
automator setup "My Automator"
```

Initialize the Automator with the new configuration

```
automator init "My Automator"
```

Enable the service

```
automator enable "My Automator"
```

At this point, the configuration is complete.

For external health checks, you can use the below URL:

https\://\<server>/health

Example `curl` command:

```
$ curl https://craigautomator1.xyz.azurecontainerapps.io/health
OK
```

### Testing the User Experience

Now that Keeper Automator is deployed, you can test the end-user experience. No prompts for approval will be required after the user authenticates with the SSO identity provider.

The easiest way to test is to open an incognito mode window to the Keeper Web Vault and login with SSO Cloud. You will not be prompted for device approval.

### Advanced

Azure Container Apps have many advanced capabilities that are beyond the scope of this documentation. A few of the capabilities are provided below.

#### Scaling with Multiple Containers

If you would like to have multiple containers running the Keeper Automator service:

* Click on "**Scale and replicas**"
* Click "**Edit and deploy**"
* Click on the "**Scale**" tab
* Select the min and max number of containers. The minimum should be at least 1.
* Click **Create**
* After a minute, the new version will deploy
* Run `automator setup xxx` multiple times (one for each container)
* Run `automator init xxx` multiple times (one for each container)

#### Logging

The Keeper Automator logs can be viewed and monitored using the "Console" or "Log stream" section.

For example, to tail the log file of a running Automator service:

* Click on Console
* Select "/bin/sh"
* Click Connect
* At the prompt, type: `tail -f logs/keeper-automator.log`

#### Advanced Settings

Environment variables can be passed into the Container to turn on/off features of the runtime environment. The variables with their description can be found at the [Advanced Settings](https://docs.keeper.io/en/sso-connect-cloud/device-approvals/automator/advanced-settings) page.
