Deploying Containers on Azure
  • 26 Jul 2022
  • 4 Minutes to read
  • Dark
    Light

Deploying Containers on Azure

  • Dark
    Light

Two or more containers cannot be started at the same time.
For containers running on a new database, start only one first so it may set up the database, After that, start other containers one at a time.

Overview

Users may deploy Azure containers via the following methods:

  • With a template .json file
  • Without a template file
  • With a .yaml file in Azure CLI

It is recommended to also set up Azure Log Analytics for the new Azure containers to better organize their logs.

Prerequisites

  • Existing Azure SQL server and SQL database
  • Existing Azure storage account with the following SMB file shares: "filestorage" (1TB capacity recommended) and "logs" (100GB capacity recommended)


Deploying with a Template File

A template file can help speed up container deployment by providing a base structure for container configuration that can then be edited to fit specific connection needs. 

Utilize the provided template.

Editing the Template

To successfully connect, edit this template with the corresponding values.

The template can be edited before or during container creation; however, it is recommended to edit before creation in a text editor such as Notepad++ to view all available settings. 

Change the following template parameters:

Parameter NameDefault ValueDesired Value
Decisions_BuildlatestReplace with the Decisions build of the user's instance found by checking the System Information window
Existing_Storage_Account_NameEXAMPLESTORAGEACCOUNTReplace with the name of the connecting Azure storage account.
Container_Group_NamedecisionsContainerGroupReplace with the resource group to assign to this container. Keeping this blank will create this resource group.
Containers > NamedecisionsReplace with the name of the new container

Change the following environment variables:

Variable NameDefault ValueDesired Value
Server EXAMPLEDBSERVER.database.windows.netReplace with the server name of the Azure SQL server to connect to this container.
Initial CatalogEXAMPLEDBNAMEReplace with the name of the Azure SQL database to connect to this container.
User IDEXAMPLEDBUSERReplace with the connecting server admin's name.
PasswordEXAMPLEDBUSERPASSWORDReplace with the connecting server admin's password.
TZUS/EasternReplace this with the desired time zone

If any of the prerequisite file shares were named differently, edit the following parameters so they match:

Parameter NameDefault ValueDesired Value
Existing_Decisions_File_Storage_Share_NamefilestorageReplace with the name of the desired file share to store Decisions files. 
Existing_Decisions_Logs_Share_NamelogsReplace with the name of the desired file share to store Decisions logs.
Volumesfilestorage / logsReplace these parameters with the name of the file shares to store files/log as well as the storage account name and key for each file share
volumeMountsfilestorage / logsReplace these parameters with the name of the file shares to store files/log as well as their file path mount i.e. backlash plus name.

Container Setup

  1. After editing the template, open the Azure portal. Select Create a resource (plus icon). 
  2. In the Marketplace search for "Template deployment".
  3. For Plan, select Template Deployment (deploy using custom templates). Select Create.
  4. Click Build your own template in the editor.
  5. Once opened, copy and paste the template .json file provided into the text editor. Review the .json for accuracy and edit the template if necessary. Select Save once done.
  6. In the Project Details window, select the desired resource group from the Resource Group dropdown menu. 
  7. Under Instance Details, enter an access key to the connecting storage account in the Storage_Account_Key settings. Notice several other settings automatically populate with the newly added values from the .json.

    Verify and/or edit the values using the above tables as reference. Select Review + Create once done.
    Not all settings present in the .json are displayed on this page.
    To go back and edit any other settings, select Edit Template at the top of the page to return to the in-browser text editor. Once edits are complete, select Save to return to this page.
  8. Azure runs a validation check to check for errors. If validation fails, Azure provides details on where the .json file is producing the error. Select Basics to return to editing. This is the last opportunity to make any changes.

    Once validation passes, select Create to commence container creation.
  9. Azure then attempts to deploy the container. This may take several minutes. Once deployment is complete, select Go to Resource to view the container. Its status should be Running.


Deploying without a Template File

This method lacks volume mapping for the container within Azure.
Volume must be manually mapped after a successful deployment. Deploying without a template is only recommended when testing since data in this container cannot be persisted and volume cannot be mapped.
  1.  Navigate to All Services and search for Container instances in the Azure portal. Select Container instances. 
  2. Select or create the resource group for the container.
  3. Specify the container name.
  4. Under Image source select Docker hub or other registry. Enter the image name into the Image field with the included tag. It is recommended to use decisionscore/platform:latest to pull the latest version.
  5. Change the OS type to be Linux with the recommended size to be 4vcpu with 16GB of memory.
  6. In the Advanced Tab, enter and define both the required and any optional environment variables.
  7. Once finished, review and create the container.


Deploying with Azure CLI

Azure also supports configuring a container via a yaml file. For further information, refer to Microsoft's article YAML Reference: Azure Container Instances.

  1. Create a .yaml or use the example file below:

    If using the template, check all values and then edit where needed for different port numbers, resources values, log folder names, etc. 

  2. Open Azure CLI via Azure Cloud Shell. Switch the language to Bash.
  3. Upload the yaml file by selecting the Upload/Download Files button (document with arrows icon).
  4. Edit the capitalized values then run the yaml with the following command:
    az container create --resource-group RESOURCEGROUPNAME --name CONTAINERNAME --file FILENAME.yaml] 

  5. The new container will deploy based on the yaml's configuration. This may take several minutes. Once deployment is complete, select Go to Resource to view the container. Its status should be Running.


Adding Custom Modules

Due to a limitation with dot notation within Azure, the CustomModules\LocalModule folder needs to be volume mapped before copying custom DLL's for modules into this folder. Visit Microsoft's article on Mapping Volumes in Azure.


Was this article helpful?