How do I configure an ACI which is container group to access an Azure Postgres Server?

Travis Polland 0 Reputation points
2023-09-13T04:26:05.8966667+00:00

Hi,

I'm a bit green around the ears when it comes to Azure.

I have a YMAL file that creates a container group with two Linux containers: the application and the other a sidecar for TLS. The application I am running is FlowiseAI, which can connect and leverage a Postgres database instead of a local deployment of SQLite.

I deployed an Azure Database for PostgreSQL (single server) burstable and have allowed Azure services access. I can connect to the database from my laptop using pgAdmin, which works (there is a firewall rule for my home network).

api-version: 2019-12-01
location: eastus
name: flowise-ssl
properties:
  containers:
  - name: flowise
    properties:
      image: flowiseai/flowise
      ports:
      - port: 80 
      - port: 3000
      command:
      - "/bin/sh"
      - "-c"
      - "flowise start" 
      environmentVariables:
      - name: PASSPHRASE
        value: 
Azure Container Instances
Azure Container Instances
An Azure service that provides customers with a serverless container experience.
757 questions
{count} votes

1 answer

Sort by: Most helpful
  1. vipullag-MSFT 26,487 Reputation points Moderator
    2023-09-20T05:45:47.1466667+00:00

    Hello Travis Polland

    It looks like you have started defining a YAML file for deploying a container group with the FlowiseAI application. To connect the application to your PostgreSQL database, you will need to add an environment variable to the container definition with the connection string for the database.

    Here is an example YAML file that includes the connection string as an environment variable:

    api-version: 2019-12-01
    location: eastus
    name: flowise-ssl
    properties:
      containers:
      - name: flowise
        properties:
          image: flowiseai/flowise
          ports:
          - port: 80 
          - port: 3000
          command:
          - "/bin/sh"
          - "-c"
          - "flowise start" 
          environmentVariables:
          - name: PASSPHRASE
            value: "mysecretpassword"
          - name: DATABASE_URL
            value: "postgresql://username:password@hostname:port/database"
      - name: sidecar
        properties:
          image: myregistry.azurecr.io/sidecar
          ports:
          - port: 443
          command:
          - "/bin/sh"
          - "-c"
          - "sidecar start"
    

    Replace mysecretpassword with the password for your PostgreSQL server. Replace username, password, hostname, port, and database with the appropriate values for your PostgreSQL server, as described in my previous message.

    Note that I have added a second container definition for the sidecar, which is used for TLS. You can remove this if you don't need it.

    Once you have updated the YAML file with the correct connection string, you can deploy the container group using the Azure CLI or the Azure portal.

    Hope this helps.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.