Configure deployments to use a database
Databases can be accessed and used by services within the same project.
The use of database will depend on the implementation in your application or service. Your deployment should be configured to receive connection details from environment variables.
Open the connection details page in your database to view the relevant connection strings and secrets, which you can use to connect to the database from your deployments. You can either add these manually to a specific deployment or secret group, or link the variables to a secret group.
You should not use the administration connection string or administrator account to connect from your deployments.
You can link a database to a secret group so that the desired addon connection details are inherited as variables within that secret group.
These connection details can then be used in any services and jobs that inherit from that secret group.
You can link variables on the connection details page of the database you want to use. Click link to secret groups and configure the relevant secret group.
You can select the suggested variables to automatically include the most useful and commonly used connection details, or manually select which variables to include.
Variables names are generated using the database name and connection detail, e.g.
NF_MY-DATABASE_HOST. If your application is expecting certain variable names you can give aliases to the variables, for example adding
ENV_DB_HOST as aliases to
NF_MY-DATABASE_HOST means that the variable can be accessed by all three of the aliases in the environment.
After linking the variables they will be available in any service that inherits from that project secret group.
Some databases can be configured to use TLS, and to be publicly exposed via TLS on the network settings page.
Enabling TLS means the database will use TLS for all internal connections.
Exposing a database using TLS will make it available online, and new public connection strings will be available.
Please note some databases, such as MySQL, cannot enable or disable TLS after creation.