Recipe context object

Learn how to use the context object in your recipes

Radius automatically injects the context object into each recipe at deploy time. It carries metadata about the resource being deployed and the application, environment, and runtime it belongs to, along with the Azure and AWS provider scopes configured on the Environment. The context is a normalized recipe contract, not a copy of the Environment resource schema. For example, Radius maps Radius.Core/environments.properties.providers.kubernetes.namespace to context.runtime.kubernetes.namespace. You declare context as a parameter in a Bicep recipe (param context object) or as an input variable in a Terraform recipe (variable "context"), then reference its values to generate names, resolve namespaces, and configure the infrastructure your recipe deploys. For more information, visit the recipe authoring how-to guide.

Usage


variable "context" {
  description = "Radius-provided object containing information about the resource calling the recipe"
  type        = any
}

locals {
  resource_name = var.context.resource.name
  namespace     = var.context.runtime.kubernetes.namespace
}

@description('Radius-provided object containing information about the resource calling the Recipe')
param context object

var resourceName = context.resource.name
var namespace = context.runtime.kubernetes.namespace

Properties

KeyTypeDescription
resourceobjectMetadata about the resource, defined in the application definition, being deployed including its name, ID, type, and properties.
applicationobjectMetadata about the application the resource belongs to. Populated only when the resource is application-scoped.
environmentobjectMetadata about the environment the resource is deployed into.
runtimeobjectDetails about the target runtime that hosts the deployed resources, such as the Kubernetes cluster.
azureobjectThe Azure provider scope (subscription and resource group) for the deployment. Present only when an Azure provider is configured on the environment.
awsobjectThe AWS provider scope (account and region) for the deployment. Present only when an AWS provider is configured on the environment.

resource

KeyTypeDescriptionExample
namestringThe name of the resource being deployedpostgresql
idstringThe ID of the resource being deployed/planes/radius/local/resourceGroups/default/providers/Radius.Data/postgreSqlDatabases/postgresql
typestringThe type of the resource being deployedRadius.Data/postgreSqlDatabases
propertiesobjectThe properties of the resource being deployed{ "size": "S", "database": "appdb" }
connectionsobjectA map of the resource’s connections to other resources, keyed by connection name. Each entry exposes the connected resource’s metadata and properties.

connections

KeyTypeDescriptionExample
namestringThe name of the connected resource.database
idstringThe ID of the connected resource./planes/radius/local/resourceGroups/default/providers/Radius.Data/postgreSqlDatabases/database
typestringThe type of the connected resource.Radius.Data/postgreSqlDatabases
propertiesobjectThe properties of the connected resource.{ "host": "localhost", "port": 5432 }

application

KeyTypeDescriptionExample
namestringThe name of the applicationdemo-default
idstringThe resource ID of the application/planes/radius/local/resourceGroups/default/providers/Radius.Core/applications/demo-default

environment

KeyTypeDescriptionExample
namestringThe name of the environmentdefault
idstringThe resource ID of the environment/planes/radius/local/resourceGroups/default/providers/Radius.Core/environments/default

runtime

KeyTypeDescription
kubernetesobjectAn object with details of the underlying Kubernetes cluster, if configured on the environment

kubernetes

KeyTypeDescriptionExample
namespacestringThe Kubernetes namespace the recipe should deploy its resources into. Set from the environment’s providers.kubernetes.namespace.default

azure

KeyTypeDescription
resourceGroupobjectAn object with details of the Azure resource group, if configured on the environment
subscriptionobjectAn object with details of the Azure subscription, if configured on the environment

resourceGroup

KeyTypeDescriptionExample
namestringThe resource group name where resources are deployed.myrg
idstringThe fully qualified Azure resource group ID./subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myrg

subscription

KeyTypeDescriptionExample
subscriptionIdstringThe GUID of the subscription where resources are deployed.00000000-0000-0000-0000-000000000000
idstringThe fully qualified Azure subscription ID./subscriptions/00000000-0000-0000-0000-000000000000

aws

KeyTypeDescriptionExample
regionstringThe AWS region where resources are deployed.us-west-2
accountstringThe AWS account ID.123456789012