Getting started with Radius: Run your first app
This guide will show you how to quickly get started with Radius. You’ll walk through both installing Radius and running your first Radius app.
Estimated time to complete: 10 min
1. Have your Kubernetes cluster handy
Radius runs inside Kubernetes. However you run Kubernetes, get a cluster ready.
If you don’t have a preferred way to create Kubernetes clusters, you could try using k3d, which runs a minimal Kubernetes distribution in Docker. Make sure to apply the recommended configuration.
Ensure your cluster is set as your current context:
kubectl config current-context
2. Install Radius CLI
The rad
CLI manages your applications, resources, and environments. You can install it on your local machine with the following installation scripts:
wget -q "https://raw.githubusercontent.com/radius-project/radius/main/deploy/install.sh" -O - | /bin/bash
To try out an unstable release visit the edge docs.
curl -fsSL "https://raw.githubusercontent.com/radius-project/radius/main/deploy/install.sh" | /bin/bash
To try out an unstable release visit the edge docs.
Run the following in a PowerShell window:
iwr -useb "https://raw.githubusercontent.com/radius-project/radius/main/deploy/install.ps1" | iex
You may need to refresh your $PATH environment variable to access rad
:
$Env:Path = [System.Environment]::GetEnvironmentVariable("Path","User")
To try out an unstable release visit the edge docs.
Radius offers a free Codespace option for getting up and running with a Radius environment in seconds:
Azure Cloud Shell is an interactive, authenticated, browser-accessible shell for managing Azure resources.
Azure Cloud Shell for bash doesn’t have a sudo command, so users are unable to install Radius to the default /usr/local/bin
installation path. To install the rad CLI to the home directory, run the following commands:
export RADIUS_INSTALL_DIR=./
wget -q "https://raw.githubusercontent.com/radius-project/radius/main/deploy/install.sh" -O - | /bin/bash
You can now run the rad CLI with ./rad
.
PowerShell for Cloud Shell is currently not supported.
Visit Radius GitHub releases to select and download a specific version of the rad CLI.
You may be prompted for your sudo password during installation, as the installer places the
rad
binary under/usr/local/bin
. If you are unable to sudo you can install the rad CLI to another directory by setting theRADIUS_INSTALL_DIR
environment variable with your intended install path. Make sure you add this to your path (Unix, Windows) if you wish to reference it viarad
, like in the docs.
Verify the rad CLI is installed correctly by running rad version
.
Example output:
RELEASE VERSION BICEP COMMIT
0.40.0 v0.40 0.28.1 2e60bfb46de73ec5cc70485d53e67f8eaa914ba7
3. Initialize Radius
Create a new directory for your app and navigate into it:
mkdir first-app
cd first-app
Initialize Radius. For this example, accept all the default options (press ENTER to confirm):
rad init
Example output:
Initializing Radius...
✅ Install Radius v0.40
- Kubernetes cluster: k3d-k3s-default
- Kubernetes namespace: radius-system
✅ Create new environment default
- Kubernetes namespace: default
- Recipe pack: local-dev
✅ Scaffold application docs
✅ Update local configuration
Initialization complete! Have a RAD time 😎
In addition to starting Radius services in your Kubernetes cluster, this initialization command creates a default application (app.bicep
) as your starting point. It contains a single container definition (demo
). rad init
also creates a bicepconfig.json
file in your application’s directory that has the necessary setup to use Radius with the official Bicep compiler.
|
|
This file will run the
ghcr.io/radius-project/samples/demo:latest
image. This image is published by the Radius team to a public registry, you do not need to create it.
4. Run the app
Use the below command to run the app in your environment, then access the application by opening http://localhost:3000 in a browser.
rad run app.bicep
This command:
- Runs the application in your Kubernetes cluster
- Creates a port-forward from localhost to port 3000 inside the container so you can navigate to the app’s frontend UI
- Creates a port-forward from localhost to port 7007 inside the container so you can navigate to your Radius Dashboard
- Streams container logs to your terminal
In your browser you should see the demo app:
Access your Radius Dashboard by opening http://localhost:7007 in a browser. In your browser, you should see the Radius Dashboard, which includes visualizations of the application graph, environments, and recipes:
Congrats! You’re running your first Radius app.
When you’re ready to move on to the next step, use CTRL+ C to exit the command.
5. Add Database
This step will add a database (Redis Cache) to the application.
You can create a Redis Cache using Recipes provided by Radius. The Radius community provides Recipes for running commonly used application dependencies, including Redis.
In this step you will:
- Add Redis to the application using a Recipe.
- Connect to Redis from the
demo
container using environment variables that Radius automatically sets.
Open app.bicep
in your editor and get ready to edit the file.
First add some new code to app.bicep
by pasting in the content below at the end of the file. This code creates a Redis Cache using a Radius Recipe:
|
|
Next, update your container definition to include connections
inside properties
. This code creates a connection between the container and the database. Based on this connection, Radius will inject environment variables into the container that inform the container how to connect. You will view these in the next step.
|
|
Your updated app.bicep
will look like this:
|
|
6. Rerun the application with a database
Use the command below to run the updated application again, then open the browser to http://localhost:3000.
rad run app.bicep
You should see the Radius Connections section with new environment variables added. The demo
container now has connection information for Redis (CONNECTION_REDIS_HOST
, CONNECTION_REDIS_PORT
, etc.):
Navigate to the Todo List tab and test out the application. Using the Todo page will update the saved state in Redis:
Access your Radius Dashboard again by opening http://localhost:7007 in a browser. You should see a visualization of the application graph for your demo
app, including the connection to the db
Redis Cache:
Press CTRL+ C when you are finished with the websites.
7. View the application graph
Radius Connections are more than just environment variables and configuration. You can also access the “application graph” and understand the connections within your application with the following command:
rad app graph
You should see the following output, detailing the connections between the demo
container and the db
Redis Cache, along with information about the underlying Kubernetes resources running the app:
Displaying application: demo
Name: demo (Applications.Core/containers)
Connections:
demo -> db (Applications.Datastores/redisCaches)
Resources:
demo (kubernetes: apps/Deployment)
demo (kubernetes: core/Secret)
demo (kubernetes: core/Service)
demo (kubernetes: core/ServiceAccount)
demo (kubernetes: rbac.authorization.k8s.io/Role)
demo (kubernetes: rbac.authorization.k8s.io/RoleBinding)
Name: db (Applications.Datastores/redisCaches)
Connections:
demo (Applications.Core/containers) -> db
Resources:
redis-r5tcrra3d7uh6 (kubernetes: apps/Deployment)
redis-r5tcrra3d7uh6 (kubernetes: core/Service)
8. Cleanup
To delete your app, run the rad app delete command to cleanup the app and its resources, including the Recipe resources:
rad app delete first-app -y
Next steps
Now that you’ve run your first Radius app, you can learn more about Radius by reading the following guides:
- Tutorials - Learn how to build and deploy a variety of applications with Radius
Next step: Radius Tutorials
Feedback
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.