Azure

Learn how to deploy Flowise on Azure


Flowise as Azure App Service with Postgres: Using Terraform

Prerequisites

  1. Azure Account: Ensure you have an Azure account with an active subscription. If you do not have one, sign up at Azure Portal.

  2. Terraform: Install Terraform CLI on your machine. Download it from Terraform's website.

  3. Azure CLI: Install Azure CLI. Instructions can be found on the Azure CLI documentation page.

Setting Up Your Environment

  1. Login to Azure: Open your terminal or command prompt and login to Azure CLI using:

az login --tenant <Your Subscription ID> --use-device-code 

Follow the prompts to complete the login process.

  1. Set Subscription: After logging in, set the Azure subscription using:

az account set --subscription <Your Subscription ID>
  1. Initialize Terraform:

Create a terraform.tfvars file in your Terraform project directory, if it's not already there, and add the following content:

subscription_name = "subscrpiton_name"
subscription_id = "subscription id"
project_name = "webapp_name"
db_username = "PostgresUserName"
db_password = "strongPostgresPassword"
flowise_secretkey_overwrite = "longandStrongSecretKey"
webapp_ip_rules = [
  {
    name = "AllowedIP"
    ip_address = "X.X.X.X/32"
    headers = null
    virtual_network_subnet_id = null
    subnet_id = null
    service_tag = null
    priority = 300
    action = "Allow"
  }
]
postgres_ip_rules = {
  "ValbyOfficeIP" = "X.X.X.X"
  // Add more key-value pairs as needed
}
source_image = "flowiseai/flowise:latest"
tagged_image = "flow:v1"

Replace the placeholders with actual values for your setup.

The file tree structure is as follows:

Each .tf file in the Terraform configuration likely contains a different aspect of the infrastructure as code:

`database.tf` would define the configuration for the Postgres database.
`main.tf` could be the main configuration file that may include the Azure provider configuration and defines the Azure resource group.
`network.tf` would include networking resources such as virtual networks, subnets, and network security groups.
`providers.tf` would define the Terraform providers, such as Azure.
`variables.tf` would declare variables used across all `.tf` files.
`webapp.tf` Azure App Services that includes a service plan and linux web app

Note: The .terraform directory is created by Terraform when initializing a project (terraform init) and it contains the plugins and binary files needed for Terraform to run. The .terraform.lock.hcl file is used to record the exact provider versions that are being used to ensure consistent installs across different machines.

Navigate to your Terraform project directory and run:

This will initialize Terraform and download the required providers.

Configuring Terraform Variables

Deploying with Terraform

  1. Plan the Deployment: Run the Terraform plan command to see what resources will be created:

  2. Apply the Deployment: If you are satisfied with the plan, apply the changes:

    Confirm the action when prompted, and Terraform will begin creating the resources.

  3. Verify the Deployment: Once Terraform has completed, it will output any defined outputs such as IP addresses or domain names. Verify that the resources are correctly deployed in your Azure Portal.


Azure Continer Instance: Using Azure Portal UI or Azure CLI

Prerequisites

  1. (Optional) Install Azure CLI if you'd like to follow the cli based commands

Create a Container Instance without Persistent Storage

Without persistent storage your data is kept in memory. This means that on a container restart, all the data that you stored will disappear.

In Portal

  1. Search for Container Instances in Marketplace and click Create:

Container Instances entry in Azure's Marketplace
  1. Select or create a Resource group, Container name, Region, Image source Other registry, Image type, Image flowiseai/flowise, OS type and Size. Then click "Next: Networking" to configure Flowise ports:

First page in the Container Instance create wizard
  1. Add a new port 3000 (TCP) next to the default 80 (TCP). Then Select "Next: Advanced":

Second page in the Container Instance create wizard. It asks for netowrking type and ports.
  1. Set Restart policy to On failure. Add Command override ["/bin/sh", "-c", "flowise start"]. Finally click "Review + create":

Third page in the Container Instance create wizard. It asks for restart policy, environment variables and command that runs on container start.
  1. Review final settings and click "Create":

Final review and create page for a Container Instance.
  1. Once creation is completed, click on "Go to resource"

Resource creation result page in Azure.
  1. Visit your Flowise instance by copying IP address and adding :3000 as a port:

Container Instance overview page
Flowise application deployed as Container Instance

Create using Azure CLI

  1. Create a resource group (if you don't already have one)

  1. Create a Container Instance

  1. Visit the IP address (including port :3000) printed from the output of the above command.

Create a Container Instance with Persistent Storage

The creation of a Container Instance with persistent storage is only possible using CLI:

  1. Create a resource group (if you don't already have one)

  1. Create the Storage Account resource (or use existing one) inside above resource group. You can check how to do it here.

  2. Inside Azure Storage create new File share. You can check how to do it here.

  3. Create a Container Instance

  1. Visit the IP address (including port :3000) printed from the output of the above command.

  2. From now on your data will be stored in an SQLite database which you can find in your File share.

Watch video tutorial on deploying to Azure Container Instance:

Last updated