Deployment


Content


To deploy the infrastructure and code follow the following steps:

For the initial setup use Terraform. Terraform creates all necessary services on Azure. The Terraform script must be executed only once at the beginning. If it has already been deployed, proceed to step 2 (2. Deploy Code To Azure).

0. Clone Git Repository

# SSH
git clone git@github.com:Re-Krass/amos2021ws06-exp-similarity-detector.git
# HTTPS
git clone https://github.com/Re-Krass/gitamos2021ws06-exp-similarity-detector.git

Or download the latest release and unzip the package from:
latest

1. Setup Infrastructure With Terraform

1.1 Install Terraform

Download and install Terraform from: https://learn.hashicorp.com/tutorials/terraform/install-cli

1.2 Setup Environment Variables

Go to the folder: Code/BackendAPI/terraform/.

Copy the file terraform.template.tfvars and rename it to: terraform.tfvars.
Replace the variable placeholders. A description of these is given by the following table:

Variable nameDescription
collectionnameIdentifier for every Azure resource
adminemailE-Mail to receive notifications

1.3 Initialize Terraform Project

terraform -chdir="terraform" init

1.4 Deploy Azure infrastructure

terraform -chdir="terraform" apply

2. Deploy Code To Azure

2.1 Login To The Azure CLI

az login

2.2 Deploy Function App to Azure

Go to the folder: Code/BackendAPI/terraform/.

func azure functionapp publish <function-app-name>

# Example
func azure functionapp publish fa-similarity-detector-func

2.3 Set Environment Variables

Copy the file template.secrets to a file named .secrets and replace "<Please set this variable>" with the right variables.

Azure

  1. Go to Azure Portal.
  2. Go to Home > Function App > <Function App Name>.
  3. Go to the Settings column and Configuration.
  4. Click on Advanced edit and paste the output from the following command under the existing variables (or replace the old ones.)
    python ./scripts/gh_secret_env_vars.py --format_azure
    
  5. Click on OK and Save (Don't forget to save!).