This setup makes deploy Flowise on Azure App Service with a PostgreSQL Flexible Server. It's based on the best practices of Azure for web application deployments.
Create a terraform.tfvars file based on the example provided:
subscription_name ="subscrpiton_name"subscription_id ="subscription id"project_name ="webapp_name"db_username ="PostgresUserName"db_password ="strongPostgresPassword"flowise_username ="flowiseUserName"flowise_password ="strongFlowisePassword"flowise_secretkey_overwrite ="longandStrongSecretKey"webapp_ip_rules =[{name="AllowedIP"ip_address="X.X.X.X/32"headers=nullvirtual_network_subnet_id=nullsubnet_id=nullservice_tag=nullpriority=300action="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
Plan the Deployment: Run the Terraform plan command to see what resources will be created:
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.
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
(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
Search for Container Instances in Marketplace and click Create:
Container Instances entry in Azure's Marketplace
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
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.
Set Restart policy to On failure. Next, add 2 Environment variables FLOWISE_USERNAME and FLOWISE_PASSWORD. 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.
Review final settings and click "Create":
Final review and create page for a Container Instance.
Once creation is completed, click on "Go to resource"
Resource creation result page in Azure.
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
Create a resource group (if you don't already have one)
Create a Container Instance
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:
Create a resource group (if you don't already have one)
Create the Storage Account resource (or use existing one) inside above resource group. You can check how to do it here.
Inside Azure Storage create new File share. You can check how to do it here.
Create a Container Instance
Visit the IP address (including port :3000) printed from the output of the above command.
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:
az group create --name flowise-rg --location "West US"
az container create -g flowise-rg \
--name flowise \
--image flowiseai/flowise \
--command-line "/bin/sh -c 'flowise start'" \
--environment-variables FLOWISE_USERNAME=flowise-user FLOWISE_PASSWORD=flowise-password DATABASE_PATH=/opt/flowise/.flowise APIKEY_PATH=/opt/flowise/.flowise SECRETKEY_PATH=/opt/flowise/.flowise LOG_PATH=/opt/flowise/.flowise/logs BLOB_STORAGE_PATH=/opt/flowise/.flowise/storage \
--ip-address public \
--ports 80 3000 \
--restart-policy OnFailure \
--azure-file-volume-share-name here goes the name of your File share \
--azure-file-volume-account-name here goes the name of your Storage Account \
--azure-file-volume-account-key here goes the access key to your Storage Account \
--azure-file-volume-mount-path /opt/flowise/.flowise