Redis cache

Learn how to use a Redis cache in your application


The is a resource which can be deployed to any platform Radius supports.

Resource format

resource redis 'Applications.Datastores/redisCaches@2023-10-01-preview' = {
  name: 'redis'
  properties: {
    environment: environment
    recipe: {
      // Name a specific Recipe to use
      name: 'azure-redis'
      // Set optional/required parameters (specific to the Recipe)
      parameters: {
        size: 'large'

resource redis 'Applications.Datastores/redisCaches@2023-10-01-preview' = {
  name: 'redis'
  properties: {
    environment: environment
    resourceProvisioning: 'manual'
    resources: [{
    username: 'myusername'
    secrets: {
      password: azureRedis.listKeys().primaryKey


Key Required Description Example
name y The name of your resource. cache
location y The location of your resource. See common values for more information. global
properties y Properties of the resource. See below


Property Required Description Example(s)
application n The ID of the application resource this resource belongs to.
environment y The ID of the environment resource this resource belongs to.
host n The Redis host name.
port n The Redis port value. 6379
resourceProvisioning n Specifies how the underlying service/resource is provisioned and managed. Options are to provision automatically via ‘recipe’ or provision manually via ‘manual’. Selection determines which set of fields to additionally require. Defaults to ‘recipe’. manual
recipe n Configuration for the Recipe which will deploy the backing infrastructure. See below
resources n An array of IDs of the underlying resources. See below
username n The username for Redis cache. myusername
secrets n Secrets used when building the resource from values. See below
tls n Indicates if the Redis cache is configured with SSL connections. If the port value is set to 6380 this defaults to true. Otherwise it is defaulted to false. If your Redis cache offers SSL connections on ports other than 6380, explicitly set this value to true to override the default behavior. true


Property Required Description Example(s)
<recipe-name> y The name of the Recipe. Must be unique within the resource-type. myrecipe
parameters n A list of parameters to set on the Recipe for every Recipe usage and deployment. Can be overridden by the resource calling the Recipe. capacity: 1


Property Required Description Example(s)
id n Resource ID of the supporting resource.


Property Required Description Example(s)
connectionString n The connection string for the Redis cache. Write only.,ssl=true,password=...
password n The password for the Redis cache. Write only. mypassword
url n The connection URL for the Redis cache. Set automatically based on the values provided for host, port, username, and password. Can be explicitly set to override default behavior. Write only. redis://username:password@localhost:6380/0?ssl=true


The following methods are available on the Redis cache:

Method Description
connectionString() Get the connection string for the Redis cache.
password() Get the password for the Redis cache.

Resource provisioning

Provision with a Recipe

Recipes automate infrastructure provisioning using approved templates. When no Recipe configuration is set, Radius will use the currently registered Recipe as the default in the environment for the given resource. Otherwise, a Recipe name and parameters can optionally be set to override this default.

Provision manually

If you want to manually manage your infrastructure provisioning without the use of Recipes, you can set resourceProvisioning to 'manual' and provide all necessary parameters and values that enable Radius to deploy or connect to the desired infrastructure.

Environment variables for connections

Other Radius resources, such as containers, may connect to a Redis resource via connections. When a connection to Redis named, for example, myconnection is declared, Radius injects values into environment variables that are then used to access the connected Redis resource:

Environment variable Example(s)
CONNECTION_MYCONNECTION_URL rediss://username:password@localhost:6380/0