3. Add a connection
❗️ Preview Release: This documentation covers a preview of Radius which uses different Resource Types from the current release. Enable it by passing the --preview to the Radius CLI or settingRADIUS_PREVIEW=true.
The Radius Demo application runs on its own, but most applications depend on other resources such as databases and caches. In this step you will add a PostgreSQL database to the application and create a connection from the container to it.
Add a PostgreSQL database and connection
The app-postgresql.bicep definition builds on app.bicep by adding a Radius.Data/postgreSqlDatabases resource, a @secure() password parameter, and a connections entry on the container. The highlighted lines are the additions:
extension radius
@description('The Radius Environment ID. Injected automatically by the rad CLI.')
param environment string
@description('The administrator password for the PostgreSQL database. Pass via the CLI, e.g. -p password=$(openssl rand -hex 16).')
@secure()
param password string
// Environment name derived from the Environment ID, used to keep resource names
// unique per environment (e.g. dev/test/prod) within the same resource group.
var environmentName = last(split(environment, '/'))
resource demoApp 'Radius.Core/applications@2025-08-01-preview' = {
name: 'demo-${environmentName}'
properties: {
environment: environment
}
}
resource demoContainer 'Radius.Compute/containers@2025-08-01-preview' = {
name: 'demo-${environmentName}'
properties: {
environment: environment
application: demoApp.id
containers: {
web: {
image: 'ghcr.io/radius-project/samples/demo:latest'
ports: {
web: {
containerPort: 3000
}
}
}
}
connections: {
postgresql: {
source: postgresql.id
}
}
}
}
resource postgresql 'Radius.Data/postgreSqlDatabases@2025-08-01-preview' = {
name: 'postgresql-${environmentName}'
properties: {
environment: environment
application: demoApp.id
size: 'S'
database: 'appdb'
username: 'myadmin'
password: password
}
}
The postgresql resource is provisioned by the PostgreSQL recipe in the default Recipe Pack. The password parameter is declared with @secure(), which keeps its value out of deployment logs and history and lets you supply the password at deploy time instead of hardcoding it. Because the password property is x-radius-sensitive on the Resource Type, Radius also encrypts it and redacts it from reads.
The connections entry tells Radius that the container depends on the database. Radius provisions the database first, then injects its connection details into the container as environment variables named CONNECTION_POSTGRESQL_<PROPERTY>, such as CONNECTION_POSTGRESQL_HOST and CONNECTION_POSTGRESQL_PORT.
Redeploy the application
Deploy the updated definition from its published URL. The --parameters password= flag sets the database password, and $(openssl rand -hex 16) generates a random value on each deploy. This works in Bash and Zsh; in PowerShell, generate the value separately and pass it in:
rad deploy https://edge.docs.radapp.io/samples/demo/app-postgresql.bicep --parameters password=$(openssl rand -hex 16)
Radius creates the database and updates the container with the connection. Forward a local port to the container and open the application again:
kubectl port-forward svc/demo-default-web 3000:3000
Open http://localhost:3000. The Radius Connections section now lists the postgresql connection.

View the connection in the Dashboard
Start port forwarding for the Dashboard:
kubectl port-forward svc/dashboard 7007:80 -n radius-system
Open http://localhost:7007 and select the demo-default application. The graph shows the demo-default container connected to the postgresql-default database.

To learn more about modeling dependencies between resources, see How to model application dependencies using connections.
Clean up
Delete the Radius Demo application:
rad application delete demo-default --preview
Optionally, uninstall Radius and remove all of its data:
rad uninstall kubernetes --purge
Next steps
You have installed Radius, deployed the Radius Demo application, and connected it to a PostgreSQL database. Continue with the hands-on labs for deeper, real-world scenarios.
Next step: Explore the labsFeedback
Was this page helpful?
Glad to hear it! Please feel free to star our repo and join our Discord server to stay up to date with the project.
Sorry to hear that. If you would like to also contribute a suggestion visit and tell us how we can improve.