application-modeling
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRadius Application Modeling
Radius 应用建模
Use this skill for all Radius-related tasks: authoring application Bicep, configuring environments with recipes, and creating custom resource types. This skill covers the full lifecycle from defining an app to deploying it on Kubernetes.
本技能适用于所有与Radius相关的任务:编写应用Bicep文件、使用Recipe配置环境、创建自定义资源类型。涵盖从定义应用到在Kubernetes上部署的完整生命周期。
Workflow
工作流程
- Read the platform constitution. Check for in the repository root. Note approved cloud providers, compute platforms, and IaC tooling.
Platform-Engineering-Constitution.md - Check current Radius state. Run ,
rad workspace show,rad environment list, andrad recipe list.rad resource-type list - If asked to create an application definition, inspect the workspace first. Look for environment definitions, existing shared resources, container artifacts, and application code that implies required connections.
- Prompt only for missing values. Ask for OCI registry details, boolean choices without a safe default, and long free-text inputs such as AI prompts.
- Author or update the application Bicep, resource types, and/or environment configuration as needed.
- Validate against the constitution and test with .
rad run
- 查阅平台规范文档。检查仓库根目录下的,记录已批准的云服务商、计算平台和IaC工具。
Platform-Engineering-Constitution.md - 检查当前Radius状态。运行、
rad workspace show、rad environment list和rad recipe list命令。rad resource-type list - 若需创建应用定义,先检查工作区。查看环境定义、现有共享资源、容器制品以及隐含所需连接的应用代码。
- 仅询问缺失的必要信息。询问OCI仓库详情、无安全默认值的布尔选项,以及长文本输入(如AI提示词)。
- 编写或更新应用Bicep文件、资源类型和/或环境配置(如有需要)。
- 验证是否符合平台规范,并使用进行测试。
rad run
Interactive App Definition Flow
交互式应用定义流程
Use this flow when the user says things like , , or .
Create an application definitionCreate app.bicepScaffold a Radius application当用户提出、或等需求时,使用此流程。
创建应用定义生成app.bicep搭建Radius应用脚手架Discovery Order
发现顺序
- Inspect environment-definition files first. Treat files such as ,
env.bicep,environment.bicep, and similar workspace Bicep files as the primary source of truth for shared resources and environment names.shared-resources.bicep - Model shared resources from workspace files as in
existing. If PostgreSQL, blob storage, or other shared resources are declared in files likeapp.biceporenv.bicep, reference them withshared-resources.bicepin the generated app definition even if they might not be deployed yet.existing - Inspect the repository for container artifacts. Look for ,
Dockerfile, OCI build configs, or application folders that clearly map to a container workload.Containerfile - Choose the container resource type deliberately. Use for straightforward single-container application workloads unless the repository explicitly needs recipe-based container features from
Applications.Core/containers.Radius.Compute/containers - Infer container ports from workload files, not base-image defaults. Prefer explicit signals such as in
EXPOSE,Dockerfiledirectives inlisten, or app server startup arguments over assumptions like nginx using port 80.nginx.conf - Inspect the code for required connections. Search for connection names, SDK usage, or environment variables that imply dependencies such as PostgreSQL, blob storage, or AI agent endpoints.
- Inspect for AI-agent expectations. If the code expects an agent endpoint or agent-style integration, add a resource.
Radius.AI/agents - Wire connections by responsibility. Connect the AI agent to the data and knowledge resources it needs. Connect the application container only to the AI agent unless the code clearly shows the container itself must talk to other resources directly.
- 优先检查环境定义文件。将、
env.bicep、environment.bicep及类似工作区Bicep文件视为共享资源和环境名称的主要可信来源。shared-resources.bicep - 将工作区文件中的共享资源在中标记为
app.bicep。若PostgreSQL、Blob存储或其他共享资源在existing或env.bicep等文件中已声明,即使尚未部署,也要在生成的应用定义中使用shared-resources.bicep引用它们。existing - 检查仓库中的容器制品。查找、
Dockerfile、OCI构建配置或明确对应容器工作负载的应用文件夹。Containerfile - 谨慎选择容器资源类型。对于简单的单容器应用工作负载,默认使用,除非仓库明确依赖
Applications.Core/containers的Recipe容器特性。Radius.Compute/containers - 从工作负载配置推断容器端口,而非基础镜像默认值。优先选择明确的配置信号,如中的
Dockerfile指令、EXPOSE中的nginx.conf配置或应用服务器启动参数,而非假设基础镜像的默认端口(如nginx的80端口)。listen - 检查代码中的必要连接。搜索连接名称、SDK使用情况或隐含依赖的环境变量,如PostgreSQL、Blob存储或AI Agent端点。
- 检查是否有AI Agent需求。若代码需要Agent端点或类Agent集成,添加资源。
Radius.AI/agents - 按职责建立连接。将AI Agent连接到其所需的数据和知识资源。除非代码明确显示容器需直接与其他资源通信,否则仅将应用容器连接到AI Agent。
Required Questions
必要询问项
Ask the user only when the value cannot be inferred safely:
- OCI registry host for the container image.
- Enable observability? Ask explicitly for because it is boolean and should not be guessed.
Radius.AI/agents.enableObservability - Prompt value for the AI agent.
仅当无法安全推断时,才向用户询问以下信息:
- 容器镜像的OCI仓库地址。
- 是否启用可观测性? 针对需明确询问,因为这是布尔值,不应默认猜测。
Radius.AI/agents.enableObservability - AI Agent的提示词内容。
Authoring Rules For This Flow
此流程的编写规则
- Always create when it does not already exist.
app.bicep - Always ensure includes the needed Radius extensions for every resource type used in the generated app.
bicepconfig.json - Use resources for shared infrastructure already defined by the environment, especially PostgreSQL and blob storage when those are pre-provisioned.
existing - Treat workspace Bicep files as authoritative for shared resources even when those resources are not deployed yet.
- Add a container resource when the repository clearly contains a deployable application container.
- Prefer for simple frontend or service containers and only switch to
Applications.Core/containerswhen the repo clearly depends on recipe-based container behavior.Radius.Compute/containers - Do not connect the frontend container directly to shared data resources when an AI agent resource already encapsulates those integrations.
- Infer the image repository name from the workload folder or existing repo conventions. If the repo contains , default the image repository to
src/web/Dockerfilerather than a generic repository name.frontend-ui - Infer the container port from explicit workload configuration. Prefer , web-server config, or application startup args over generic defaults from the base image.
EXPOSE - Prompt for the OCI registry instead of hardcoding one.
- Prompt for AI observability instead of assuming or
true.false - If the AI prompt is long or multi-line, do not inline it in the resource. Model it as and set
param agentPrompt string.prompt: agentPrompt - If the AI prompt is short and single-line, it may be inlined unless the user prefers parameterization.
- Prefer minimal app scaffolds that connect to existing shared resources rather than duplicating them.
- 当不存在时,必须创建该文件。
app.bicep - 确保包含生成应用中使用的所有Radius扩展。
bicepconfig.json - 对环境中已定义的共享基础设施使用资源,尤其是预配置的PostgreSQL和Blob存储。
existing - 将工作区Bicep文件视为共享资源的可信来源,即使这些资源尚未部署。
- 当仓库明确包含可部署的应用容器时,添加容器资源。
- 对于简单前端或服务容器,优先使用,仅当仓库明确依赖Recipe容器行为时,才切换为
Applications.Core/containers。Radius.Compute/containers - 当AI Agent资源已封装集成时,不要将前端容器直接连接到共享数据资源。
- 从工作负载文件夹或现有仓库约定推断镜像仓库名称。若仓库包含,默认将镜像仓库名称设为
src/web/Dockerfile,而非通用名称。frontend-ui - 从明确的工作负载配置推断容器端口。优先选择、Web服务器配置或应用启动参数,而非基础镜像的通用默认值。
EXPOSE - 询问OCI仓库信息,而非硬编码。
- 询问AI可观测性设置,而非默认或
true。false - 若AI提示词较长或为多行,不要将其内嵌到资源中。将其建模为,并设置
param agentPrompt string。prompt: agentPrompt - 若AI提示词较短且为单行,可内嵌到资源中,除非用户偏好参数化。
- 优先使用最小化应用脚手架,连接到现有共享资源而非重复创建。
Expected Output Shape
预期输出结构
The generated should usually include:
app.bicep- An application resource.
- Existing shared resources such as PostgreSQL and blob storage, when discovered from the environment definition.
- A new application container resource, usually for simple app workloads.
Applications.Core/containers - A new resource when the code expects an AI agent.
Radius.AI/agents - Connections from the AI agent to PostgreSQL and blob storage when those resources are required.
- A connection from the application container to the AI agent when the container is only a frontend or thin client.
- Parameters for registry details and long free-text values.
See references/app-definition-flow.md for the canonical example and decision rules.
生成的通常应包含:
app.bicep- 一个应用资源。
- 从环境定义中发现的现有共享资源(如PostgreSQL和Blob存储)。
- 一个新的应用容器资源,对于简单应用工作负载通常为。
Applications.Core/containers - 当代码需要AI Agent时,添加新的资源。
Radius.AI/agents - 当PostgreSQL和Blob存储为必需资源时,建立AI Agent与它们的连接。
- 当容器仅为前端或瘦客户端时,建立应用容器与AI Agent的连接。
- 用于仓库详情和长文本值的参数。
有关标准示例和决策规则,请参阅references/app-definition-flow.md。
Customer-Agent Target Profile
客户Agent目标配置文件
When the target repository follows the structure, use these repo-specific rules:
Reshrahim/customer-agent- Environment file: defines the environment and registered recipes.
radius/env.bicep - Shared resources file: defines PostgreSQL and blob storage that should be referenced with
radius/shared-resources.bicepin the generatedexisting.radius/app.bicep - Frontend container: indicates a user-facing container workload; generate an
src/web/Dockerfileresource such asApplications.Core/containersfor it.frontend-ui - Agent runtime code: indicates the repo expects an AI agent plus PostgreSQL and blob storage connections.
src/agent-runtime/app.py - Agent connections: the generated resource must connect to
Radius.AI/agentsandcontoso-dbso the runtime receives both database and knowledge-base/search inputs through the recipe.contoso-knowledge-base - Frontend connections: the generated container should connect only to the AI agent.
frontend-ui - Frontend image name: the generated container image should use as the repository name unless the user overrides it.
frontend-ui - Frontend port: infer the frontend port from and related config files. For customer-agent, use
src/web/Dockerfilebecause the Dockerfile exposes3000and3000listens onsrc/web/nginx.conf.3000 - Do not create a second app-level container for when the
src/agent-runtime/Dockerfilerecipe already encapsulates the agent runtime container.Radius.AI/agents - Default model: use unless the user asks otherwise.
gpt-4.1-mini - Prompt handling: when the user pastes a long or multi-line system prompt, always model it as a rather than inlining it.
param
当目标仓库遵循结构时,使用以下仓库特定规则:
Reshrahim/customer-agent- 环境文件:定义环境和已注册的Recipe。
radius/env.bicep - 共享资源文件:定义PostgreSQL和Blob存储,需在生成的
radius/shared-resources.bicep中使用radius/app.bicep引用。existing - 前端容器:表示面向用户的容器工作负载;为其生成
src/web/Dockerfile资源(如Applications.Core/containers)。frontend-ui - Agent运行时代码:表示仓库需要AI Agent以及PostgreSQL和Blob存储连接。
src/agent-runtime/app.py - Agent连接:生成的资源必须连接到
Radius.AI/agents和contoso-db,以便运行时通过Recipe接收数据库和知识库/搜索输入。contoso-knowledge-base - 前端连接:生成的容器应仅连接到AI Agent。
frontend-ui - 前端镜像名称:生成的容器镜像默认使用作为仓库名称,除非用户覆盖。
frontend-ui - 前端端口:从及相关配置文件推断前端端口。对于customer-agent,默认使用
src/web/Dockerfile,因为Dockerfile暴露了3000端口,且3000监听该端口。src/web/nginx.conf - 不要为创建第二个应用级容器,因为
src/agent-runtime/DockerfileRecipe已封装了Agent运行时容器。Radius.AI/agents - 默认模型:使用,除非用户另有要求。
gpt-4.1-mini - 提示词处理:当用户粘贴长或多行系统提示词时,必须将其建模为参数,而非内嵌。
Part 1: Application Authoring
第一部分:应用编写
Bicep Extension Setup
Bicep扩展设置
Before writing , configure :
app.bicepbicepconfig.jsonjson
{
"extensions": {
"radius": "br:biceptypes.azurecr.io/radius:latest",
"aws": "br:biceptypes.azurecr.io/aws:latest"
},
"experimentalFeaturesEnabled": {
"extensibility": true,
"dynamicTypeLoading": true
}
}If using resource types (from ), add custom extensions:
Radius.*radius-resource-typesjson
{
"extensions": {
"radius": "br:biceptypes.azurecr.io/radius:latest",
"aws": "br:biceptypes.azurecr.io/aws:latest",
"radiusCompute": "radius-compute.tgz",
"radiusData": "radius-data.tgz",
"radiusStorage": "radius-storage.tgz",
"radiusSecurity": "radius-security.tgz",
"radiusAi": "radius-ai.tgz"
},
"experimentalFeaturesEnabled": {
"extensibility": true,
"dynamicTypeLoading": true
}
}Generate custom extensions with:
bash
rad bicep publish-extension --from-file <manifest.yaml> --target <output.tgz>在编写之前,配置:
app.bicepbicepconfig.jsonjson
{
"extensions": {
"radius": "br:biceptypes.azurecr.io/radius:latest",
"aws": "br:biceptypes.azurecr.io/aws:latest"
},
"experimentalFeaturesEnabled": {
"extensibility": true,
"dynamicTypeLoading": true
}
}若使用资源类型(来自),添加自定义扩展:
Radius.*radius-resource-typesjson
{
"extensions": {
"radius": "br:biceptypes.azurecr.io/radius:latest",
"aws": "br:biceptypes.azurecr.io/aws:latest",
"radiusCompute": "radius-compute.tgz",
"radiusData": "radius-data.tgz",
"radiusStorage": "radius-storage.tgz",
"radiusSecurity": "radius-security.tgz",
"radiusAi": "radius-ai.tgz"
},
"experimentalFeaturesEnabled": {
"extensibility": true,
"dynamicTypeLoading": true
}
}使用以下命令生成自定义扩展:
bash
rad bicep publish-extension --from-file <manifest.yaml> --target <output.tgz>Resource Type Namespaces
资源类型命名空间
There are two families of resource types:
存在两类资源类型:
Applications.*
(Built-in)
Applications.*Applications.*
(内置)
Applications.*Built into Radius. is handled directly by the Radius control plane — not recipe-based.
Applications.Core/containers| Type | Description |
|---|---|
| Application grouping |
| Container workloads (directly managed) |
| HTTP ingress gateways |
| Redis (recipe-based) |
| SQL databases (recipe-based) |
内置在Radius中。由Radius控制平面直接处理,不基于Recipe。
Applications.Core/containers| 类型 | 描述 |
|---|---|
| 应用分组 |
| 容器工作负载(直接管理) |
| HTTP入口网关 |
| Redis(基于Recipe) |
| SQL数据库(基于Recipe) |
Radius.*
(from radius-resource-types)
Radius.*Radius.*
(来自radius-resource-types)
Radius.*Community/extensible types. ALL are recipe-based, including .
Radius.Compute/containers| Type | Description |
|---|---|
| Container workloads (recipe-based) |
| Persistent storage volumes |
| HTTP routing (requires Gateway API controller) |
| MySQL databases |
| PostgreSQL databases |
| Blob/object storage |
| Secret stores |
| LLM-powered agent runtimes |
Radius.Data/redisCachesradius-resource-typesCritical difference:is directly managed by Radius.Applications.Core/containersis recipe-based — it needs a registered recipe to deploy.Radius.Compute/containers
社区/可扩展类型。所有类型均基于Recipe,包括。
Radius.Compute/containers| 类型 | 描述 |
|---|---|
| 容器工作负载(基于Recipe) |
| 持久存储卷 |
| HTTP路由(需要Gateway API控制器) |
| MySQL数据库 |
| PostgreSQL数据库 |
| Blob/对象存储 |
| 密钥存储 |
| 大语言模型驱动的Agent运行时 |
Radius.Data/redisCachesradius-resource-types关键区别:由Radius直接管理。Applications.Core/containers基于Recipe,需要已注册的Recipe才能部署。Radius.Compute/containers
Application Structure
应用结构
Using Applications.*
Types (Simpler)
Applications.*使用Applications.*
类型(更简单)
Applications.*bicep
extension radius
param environment string
param application string
resource frontend 'Applications.Core/containers@2023-10-01-preview' = {
name: 'frontend'
properties: {
application: application
container: { // singular "container"
image: 'myregistry/frontend:latest'
ports: {
web: { containerPort: 3000 }
}
}
connections: {
database: { source: db.id }
}
}
}
resource db 'Applications.Datastores/sqlDatabases@2023-10-01-preview' = {
name: 'database'
properties: {
environment: environment
application: application
}
}bicep
extension radius
param environment string
param application string
resource frontend 'Applications.Core/containers@2023-10-01-preview' = {
name: 'frontend'
properties: {
application: application
container: { // 单数"container"
image: 'myregistry/frontend:latest'
ports: {
web: { containerPort: 3000 }
}
}
connections: {
database: { source: db.id }
}
}
}
resource db 'Applications.Datastores/sqlDatabases@2023-10-01-preview' = {
name: 'database'
properties: {
environment: environment
application: application
}
}Using Radius.*
Types (Portable)
Radius.*使用Radius.*
类型(可移植)
Radius.*bicep
extension radius
extension radiusCompute
extension radiusData
param environment string
param application string
resource frontend 'Radius.Compute/containers@2025-08-01-preview' = {
name: 'frontend'
properties: {
environment: environment
application: application
containers: { // plural "containers" — a map!
frontend: {
image: 'myregistry/frontend:latest'
ports: {
web: { containerPort: 3000 }
}
}
}
connections: {
database: { source: db.id }
}
}
}
resource db 'Radius.Data/postgreSqlDatabases@2025-08-01-preview' = {
name: 'database'
properties: {
environment: environment
application: application
size: 'S' // Required if recipe expects it
}
}Schema difference:usesApplications.Core/containers(singular object).containerusesRadius.Compute/containers(plural map where each key is a container name).containers
bicep
extension radius
extension radiusCompute
extension radiusData
param environment string
param application string
resource frontend 'Radius.Compute/containers@2025-08-01-preview' = {
name: 'frontend'
properties: {
environment: environment
application: application
containers: { // 复数"containers" — 一个映射!
frontend: {
image: 'myregistry/frontend:latest'
ports: {
web: { containerPort: 3000 }
}
}
}
connections: {
database: { source: db.id }
}
}
}
resource db 'Radius.Data/postgreSqlDatabases@2025-08-01-preview' = {
name: 'database'
properties: {
environment: environment
application: application
size: 'S' // 若Recipe要求则为必填
}
}Schema区别:使用Applications.Core/containers(单数对象)。container使用Radius.Compute/containers(复数映射,每个键为容器名称)。containers
Connections and Environment Variables
连接与环境变量
Applications.Core/containers
— Individual Env Vars
Applications.Core/containersApplications.Core/containers
— 独立环境变量
Applications.Core/containersCONNECTION_<NAME>_HOST
CONNECTION_<NAME>_PORT
CONNECTION_<NAME>_DATABASE
CONNECTION_<NAME>_USERNAME
CONNECTION_<NAME>_PASSWORDCONNECTION_<NAME>_HOST
CONNECTION_<NAME>_PORT
CONNECTION_<NAME>_DATABASE
CONNECTION_<NAME>_USERNAME
CONNECTION_<NAME>_PASSWORDRadius.Compute/containers
— JSON Properties Blob
Radius.Compute/containersRadius.Compute/containers
— JSON属性Blob
Radius.Compute/containersCONNECTION_<NAME>_PROPERTIES={"host":"...","port":"...","database":"..."}
CONNECTION_<NAME>_ID=<resource-id>
CONNECTION_<NAME>_NAME=<connection-name>
CONNECTION_<NAME>_TYPE=<resource-type>Application code must parse as JSON. Write a helper function that supports both formats:
CONNECTION_<NAME>_PROPERTIESgo
// Go
func getConnProp(connName, prop string) string {
propsJSON := os.Getenv("CONNECTION_" + connName + "_PROPERTIES")
if propsJSON != "" {
var props map[string]interface{}
if err := json.Unmarshal([]byte(propsJSON), &props); err == nil {
if val, ok := props[strings.ToLower(prop)]; ok {
return fmt.Sprintf("%v", val)
}
}
}
return os.Getenv("CONNECTION_" + connName + "_" + prop)
}javascript
// Node.js
function getConnProp(connName, prop) {
const propsJson = process.env[`CONNECTION_${connName}_PROPERTIES`];
if (propsJson) {
try {
const props = JSON.parse(propsJson);
return props[prop.toLowerCase()] || '';
} catch (e) {}
}
return process.env[`CONNECTION_${connName}_${prop}`] || '';
}CONNECTION_<NAME>_PROPERTIES={"host":"...","port":"...","database":"..."}
CONNECTION_<NAME>_ID=<resource-id>
CONNECTION_<NAME>_NAME=<connection-name>
CONNECTION_<NAME>_TYPE=<resource-type>应用代码必须将解析为JSON。编写支持两种格式的辅助函数:
CONNECTION_<NAME>_PROPERTIESgo
// Go
func getConnProp(connName, prop string) string {
propsJSON := os.Getenv("CONNECTION_" + connName + "_PROPERTIES")
if propsJSON != "" {
var props map[string]interface{}
if err := json.Unmarshal([]byte(propsJSON), &props); err == nil {
if val, ok := props[strings.ToLower(prop)]; ok {
return fmt.Sprintf("%v", val)
}
}
}
return os.Getenv("CONNECTION_" + connName + "_" + prop)
}javascript
// Node.js
function getConnProp(connName, prop) {
const propsJson = process.env[`CONNECTION_${connName}_PROPERTIES`];
if (propsJson) {
try {
const props = JSON.parse(propsJson);
return props[prop.toLowerCase()] || '';
} catch (e) {}
}
return process.env[`CONNECTION_${connName}_${prop}`] || '';
}Container Image Requirements
容器镜像要求
- Cloud registry (ACR, ECR, GHCR): Works if cluster has credentials configured
- Local dev with kind: Push to a local OCI registry and use as the image host
host.docker.internal:<port> - : The
imagePullPolicyrecipe may setRadius.Compute/containers— images must be pullable, not just loaded withAlwayskind load
- 云仓库(ACR、ECR、GHCR):若集群已配置凭证则可正常使用
- 使用kind的本地开发:推送到本地OCI仓库,并使用作为镜像地址
host.docker.internal:<port> - :
imagePullPolicy的Recipe可能设置为Radius.Compute/containers,因此镜像必须可拉取,仅使用Always加载镜像无法满足要求kind load
Health Endpoints
健康检查端点
Always add (liveness) and (readiness) endpoints. The readiness probe should check downstream dependencies.
/healthz/readyz始终添加(存活检查)和(就绪检查)端点。就绪检查应验证下游依赖是否可用。
/healthz/readyzPart 2: Environment & Recipe Setup
第二部分:环境与Recipe设置
Initialize Radius
初始化Radius
bash
rad initialize
rad workspace create kubernetes default --group default --environment default
rad environment create myenv --namespace my-namespace # if needed
rad environment switch myenvbash
rad initialize
rad workspace create kubernetes default --group default --environment default
rad environment create myenv --namespace my-namespace # 如有需要
rad environment switch myenvRegister Resource Types
注册资源类型
bash
undefinedbash
undefinedDownload YAML from radius-resource-types, then register
从radius-resource-types下载YAML,然后注册
rad resource-type create Radius.Data/postgreSqlDatabases --from-file postgreSqlDatabases.yaml
rad resource-type show Radius.Data/postgreSqlDatabases # verify
rad resource-type create Radius.Data/postgreSqlDatabases --from-file postgreSqlDatabases.yaml
rad resource-type show Radius.Data/postgreSqlDatabases # 验证
Repeat for other repo-backed types such as:
对其他仓库托管的类型重复此操作,例如:
Radius.Data/mySqlDatabases
Radius.Data/mySqlDatabases
Radius.Storage/blobStorages
Radius.Storage/blobStorages
Radius.Security/secrets
Radius.Security/secrets
Radius.Compute/persistentVolumes
Radius.Compute/persistentVolumes
Radius.Compute/routes
Radius.Compute/routes
Radius.AI/agents
Radius.AI/agents
undefinedundefinedGenerate Bicep Extensions
生成Bicep扩展
bash
rad bicep publish-extension --from-file postgreSqlDatabases.yaml --target radius-data.tgzbash
rad bicep publish-extension --from-file postgreSqlDatabases.yaml --target radius-data.tgzThen add the matching extension key in bicepconfig.json, for example:
然后在bicepconfig.json中添加对应的扩展键,例如:
"radiusData": "radius-data.tgz"
"radiusData": "radius-data.tgz"
"radiusStorage": "radius-storage.tgz"
"radiusStorage": "radius-storage.tgz"
"radiusSecurity": "radius-security.tgz"
"radiusSecurity": "radius-security.tgz"
"radiusAi": "radius-ai.tgz"
"radiusAi": "radius-ai.tgz"
Combine multiple types into one YAML (with `---` separator) to generate a single extension.
可以将多个类型合并到一个YAML文件中(使用`---`分隔),以生成单个扩展。Publish and Register Recipes
发布并注册Recipe
Critical: Recipes registered from local file paths () will NOT work. The Radius control plane runs inside Kubernetes and cannot access the host filesystem. Always publish to an OCI registry./tmp/recipe.bicep
bash
undefined关键注意事项:从本地文件路径(如)注册的Recipe无法正常工作。Radius控制平面运行在Kubernetes内部,无法访问主机文件系统。必须始终发布到OCI仓库。/tmp/recipe.bicep
bash
undefinedPublish to OCI registry
发布到OCI仓库
rad bicep publish --file kubernetes-postgresql.bicep
--target br:myregistry.azurecr.io/recipes/postgresql-kubernetes:latest
--target br:myregistry.azurecr.io/recipes/postgresql-kubernetes:latest
rad bicep publish --file kubernetes-postgresql.bicep
--target br:myregistry.azurecr.io/recipes/postgresql-kubernetes:latest
--target br:myregistry.azurecr.io/recipes/postgresql-kubernetes:latest
For local/insecure registries, add --plain-http
对于本地/非安全仓库,添加--plain-http参数
rad bicep publish --file kubernetes-postgresql.bicep
--target br:localhost:5001/recipes/postgresql-kubernetes:latest --plain-http
--target br:localhost:5001/recipes/postgresql-kubernetes:latest --plain-http
rad bicep publish --file kubernetes-postgresql.bicep
--target br:localhost:5001/recipes/postgresql-kubernetes:latest --plain-http
--target br:localhost:5001/recipes/postgresql-kubernetes:latest --plain-http
Register (use host.docker.internal for in-cluster access)
注册(使用host.docker.internal实现集群内访问)
rad recipe register postgresql
--resource-type Radius.Data/postgreSqlDatabases
--template-kind bicep
--template-path "host.docker.internal:5001/recipes/postgresql-kubernetes:latest"
--plain-http --environment myenv
--resource-type Radius.Data/postgreSqlDatabases
--template-kind bicep
--template-path "host.docker.internal:5001/recipes/postgresql-kubernetes:latest"
--plain-http --environment myenv
undefinedrad recipe register postgresql
--resource-type Radius.Data/postgreSqlDatabases
--template-kind bicep
--template-path "host.docker.internal:5001/recipes/postgresql-kubernetes:latest"
--plain-http --environment myenv
--resource-type Radius.Data/postgreSqlDatabases
--template-kind bicep
--template-path "host.docker.internal:5001/recipes/postgresql-kubernetes:latest"
--plain-http --environment myenv
undefinedRecipe Selection Guide
Recipe选择指南
| Constitution Says | Recipe Platform | Recipe IaC | Example |
|---|---|---|---|
| Azure + Terraform | | | |
| Azure + Bicep | | | |
| AWS + Terraform | | | |
| Kubernetes (local) | | | |
| 平台规范要求 | Recipe平台 | Recipe IaC | 示例 |
|---|---|---|---|
| Azure + Terraform | | | |
| Azure + Bicep | | | |
| AWS + Terraform | | | |
| Kubernetes(本地) | | | |
Local Development with kind
使用kind的本地开发
1. Local OCI Registry
1. 本地OCI仓库
bash
docker run -d -p 5001:5000 --name radius-registry registry:2
curl http://localhost:5001/v2/_catalog # verifybash
docker run -d -p 5001:5000 --name radius-registry registry:2
curl http://localhost:5001/v2/_catalog # 验证2. Host Networking
2. 主机网络
localhosthost.docker.internalK8s Pod内部的无法访问主机。所有仓库和服务URL请使用。
localhosthost.docker.internal3. Insecure Registry for containerd
3. 为containerd配置非安全仓库
bash
NODENAME=$(kubectl get nodes -o jsonpath='{.items[0].metadata.name}')
docker exec $NODENAME mkdir -p /etc/containerd/certs.d/host.docker.internal:5001
docker exec $NODENAME bash -c 'cat > /etc/containerd/certs.d/host.docker.internal:5001/hosts.toml << EOF
[host."http://host.docker.internal:5001"]
capabilities = ["pull", "resolve"]
skip_verify = true
EOF'
docker exec $NODENAME bash -c \
'sed -i "s|config_path = \"\"|config_path = \"/etc/containerd/certs.d\"|" /etc/containerd/config.toml'
docker exec $NODENAME systemctl restart containerdbash
NODENAME=$(kubectl get nodes -o jsonpath='{.items[0].metadata.name}')
docker exec $NODENAME mkdir -p /etc/containerd/certs.d/host.docker.internal:5001
docker exec $NODENAME bash -c 'cat > /etc/containerd/certs.d/host.docker.internal:5001/hosts.toml << EOF
[host."http://host.docker.internal:5001"]
capabilities = ["pull", "resolve"]
skip_verify = true
EOF'
docker exec $NODENAME bash -c \
'sed -i "s|config_path = \"\"|config_path = \"/etc/containerd/certs.d\"|" /etc/containerd/config.toml'
docker exec $NODENAME systemctl restart containerd4. Build and Push Images
4. 构建并推送镜像
bash
docker build -t myapp-backend:latest ./backend
docker tag myapp-backend:latest localhost:5001/myapp-backend:latest
docker push localhost:5001/myapp-backend:latestIn , reference as .
app.bicephost.docker.internal:5001/myapp-backend:latestbash
docker build -t myapp-backend:latest ./backend
docker tag myapp-backend:latest localhost:5001/myapp-backend:latest
docker push localhost:5001/myapp-backend:latest在中,将镜像引用为。
app.bicephost.docker.internal:5001/myapp-backend:latestEnvironment Management Commands
环境管理命令
bash
rad environment list
rad environment show myenv
rad recipe list --environment myenv
rad recipe show postgresql --resource-type Radius.Data/postgreSqlDatabases --environment myenv
rad resource-type list
rad resource-type show Radius.Data/postgreSqlDatabases
rad workspace showbash
rad environment list
rad environment show myenv
rad recipe list --environment myenv
rad recipe show postgresql --resource-type Radius.Data/postgreSqlDatabases --environment myenv
rad resource-type list
rad resource-type show Radius.Data/postgreSqlDatabases
rad workspace showPart 3: Custom Resource Types & Recipes
第三部分:自定义资源类型与Recipe
Resource Type YAML Schema
资源类型YAML Schema
yaml
namespace: Radius.Data
types:
postgreSqlDatabases:
description: |
A portable PostgreSQL database resource.
apiVersions:
'2025-08-01-preview':
schema:
type: object
properties:
environment:
type: string
description: "(Required) The Radius Environment ID."
application:
type: string
description: "(Optional) The Radius Application ID."
size:
type: string
enum: ['S', 'M', 'L']
description: "(Optional) The size of the database."
host:
type: string
description: The hostname.
readOnly: true
port:
type: string
description: The port.
readOnly: true
database:
type: string
description: The database name.
readOnly: true
username:
type: string
description: The username.
readOnly: true
password:
type: string
description: The password.
readOnly: true
required: [environment]Conventions:
- is always required
environment - Input properties are cloud-agnostic, minimal
- Output properties are marked — they become connection env vars
readOnly: true - Combine multiple types in one YAML under the same namespace
yaml
namespace: Radius.Data
types:
postgreSqlDatabases:
description: |
可移植的PostgreSQL数据库资源。
apiVersions:
'2025-08-01-preview':
schema:
type: object
properties:
environment:
type: string
description: "(必填) Radius环境ID。"
application:
type: string
description: "(可选) Radius应用ID。"
size:
type: string
enum: ['S', 'M', 'L']
description: "(可选) 数据库规模。"
host:
type: string
description: 主机名。
readOnly: true
port:
type: string
description: 端口。
readOnly: true
database:
type: string
description: 数据库名称。
readOnly: true
username:
type: string
description: 用户名。
readOnly: true
password:
type: string
description: 密码。
readOnly: true
required: [environment]规范:
- 始终为必填项
environment - 输入属性与云无关,保持最小化
- 输出属性标记为,将成为连接环境变量
readOnly: true - 同一命名空间下的多个类型可合并到一个YAML文件中
Recipe Directory Structure
Recipe目录结构
<resourceType>/
├── README.md
├── <resourceType>.yaml
└── recipes/
├── kubernetes/bicep/kubernetes-<type>.bicep
├── azure-<service>/bicep/azure-<service>.bicep
└── aws-<service>/terraform/main.tf<resourceType>/
├── README.md
├── <resourceType>.yaml
└── recipes/
├── kubernetes/bicep/kubernetes-<type>.bicep
├── azure-<service>/bicep/azure-<service>.bicep
└── aws-<service>/terraform/main.tfRecipe Context Object
Recipe上下文对象
context.resource.id // Full resource ID
context.resource.name // Resource name
context.resource.type // e.g., "Radius.Data/postgreSqlDatabases"
context.resource.properties // Developer-set properties from app.bicep
context.runtime.kubernetes.namespace // Target namespaceImportant: Use(notcontext.resource.properties.*).context.properties.*
context.resource.id // 完整资源ID
context.resource.name // 资源名称
context.resource.type // 例如:"Radius.Data/postgreSqlDatabases"
context.resource.properties // 从app.bicep中设置的开发者属性
context.runtime.kubernetes.namespace // 目标命名空间重要:使用(而非context.resource.properties.*)。context.properties.*
Bicep Recipe Template
Bicep Recipe模板
bicep
param context object
var size = contains(context.resource.properties, 'size') ? context.resource.properties.size : 'S'
var name = context.resource.name
var namespace = context.runtime.kubernetes.namespace
// ... deploy k8s resources ...
output result object = {
properties: {
host: '${name}-svc.${namespace}.svc.cluster.local'
port: '5432'
database: name
username: 'admin'
password: 'generated-password'
}
}bicep
param context object
var size = contains(context.resource.properties, 'size') ? context.resource.properties.size : 'S'
var name = context.resource.name
var namespace = context.runtime.kubernetes.namespace
// ... 部署K8s资源 ...
output result object = {
properties: {
host: '${name}-svc.${namespace}.svc.cluster.local'
port: '5432'
database: name
username: 'admin'
password: 'generated-password'
}
}Terraform Recipe Template
Terraform Recipe模板
hcl
variable "context" {
type = any
}
locals {
size = try(var.context.resource.properties.size, "S")
name = var.context.resource.name
namespace = var.context.runtime.kubernetes.namespace
}
output "result" {
value = {
properties = {
host = "${local.name}-svc.${local.namespace}.svc.cluster.local"
port = "5432"
database = local.name
username = "admin"
password = "generated-password"
}
}
}hcl
variable "context" {
type = any
}
locals {
size = try(var.context.resource.properties.size, "S")
name = var.context.resource.name
namespace = var.context.runtime.kubernetes.namespace
}
output "result" {
value = {
properties = {
host = "${local.name}-svc.${local.namespace}.svc.cluster.local"
port = "5432"
database = local.name
username = "admin"
password = "generated-password"
}
}
}Publishing and Registration
发布与注册
bash
undefinedbash
undefined1. Publish recipe to OCI registry
1. 将Recipe发布到OCI仓库
rad bicep publish --file kubernetes-postgresql.bicep
--target br:myregistry.azurecr.io/recipes/postgresql-kubernetes:latest
--target br:myregistry.azurecr.io/recipes/postgresql-kubernetes:latest
rad bicep publish --file kubernetes-postgresql.bicep
--target br:myregistry.azurecr.io/recipes/postgresql-kubernetes:latest
--target br:myregistry.azurecr.io/recipes/postgresql-kubernetes:latest
2. Register resource type
2. 注册资源类型
rad resource-type create Radius.Data/postgreSqlDatabases --from-file manifest.yaml
rad resource-type create Radius.Data/postgreSqlDatabases --from-file manifest.yaml
3. Register recipe
3. 注册Recipe
rad recipe register postgresql
--resource-type Radius.Data/postgreSqlDatabases
--template-kind bicep
--template-path "myregistry.azurecr.io/recipes/postgresql-kubernetes:latest"
--resource-type Radius.Data/postgreSqlDatabases
--template-kind bicep
--template-path "myregistry.azurecr.io/recipes/postgresql-kubernetes:latest"
rad recipe register postgresql
--resource-type Radius.Data/postgreSqlDatabases
--template-kind bicep
--template-path "myregistry.azurecr.io/recipes/postgresql-kubernetes:latest"
--resource-type Radius.Data/postgreSqlDatabases
--template-kind bicep
--template-path "myregistry.azurecr.io/recipes/postgresql-kubernetes:latest"
4. Generate Bicep extension
4. 生成Bicep扩展
rad bicep publish-extension --from-file manifest.yaml --target radius-data.tgz
rad bicep publish-extension --from-file manifest.yaml --target radius-data.tgz
5. Test
5. 测试
rad run app.bicep
---rad run app.bicep
---Common Pitfalls
常见陷阱
| Problem | Cause | Fix |
|---|---|---|
| Missing | Create it with the Radius extension registry URL |
| Recipe registered from local file path | Publish to OCI registry, re-register |
| | Use |
| containerd defaults to HTTPS | Configure |
| Recipe expects property not set in app.bicep | Add the property or add a safe default in recipe |
| No recipe registered for resource type | |
| Image not accessible from cluster | Push to registry; |
| Using | Parse |
Bicep validation errors on | No Bicep extension generated | |
| Wrong property name for container type | |
| 问题 | 原因 | 解决方法 |
|---|---|---|
| 缺失 | 使用Radius扩展仓库URL创建该文件 |
| Recipe从本地文件路径注册 | 发布到OCI仓库后重新注册 |
| 在K8s Pod中使用了 | 改用 |
| containerd默认要求HTTPS | 在kind节点中配置 |
| Recipe期望的属性未在app.bicep中设置 | 添加该属性,或在Recipe中设置安全默认值 |
| 未为资源类型注册Recipe | 执行 |
| 集群无法访问镜像 | 推送到仓库; |
| 使用了 | 解析 |
| 未生成Bicep扩展 | 执行 |
| 容器类型的属性名称使用错误 | |
References
参考资料
| Topic | Reference | Use for |
|---|---|---|
| Bicep Patterns | references/bicep-patterns.md | Multi-container apps, gateways, parameterization |
| App Definition Flow | references/app-definition-flow.md | Scaffolding |
| Connection Conventions | references/connection-conventions.md | Env var formats, JSON parsing, portable code |
| Resource Type Catalog | references/resource-type-catalog.md | Available types, schemas, properties |
| Local Development | references/local-development.md | kind, local registry, containerd, Dockerfiles |
| Resource Type YAML | references/resource-type-yaml.md | YAML schema definition format |
| Recipe Authoring | references/recipe-authoring.md | Bicep/Terraform recipes, context object |
| Environment Config | references/environment-config.md | Workspaces, environments, namespaces |
| Cloud Providers | references/cloud-providers.md | Azure, AWS credentials for Radius |
| Recipe Structure | references/recipe-structure.md | Directory layout in radius-resource-types |
| Contribution Guide | references/contribution-guide.md | Contributing to radius-resource-types |
| 主题 | 参考链接 | 用途 |
|---|---|---|
| Bicep模式 | references/bicep-patterns.md | 多容器应用、网关、参数化 |
| 应用定义流程 | references/app-definition-flow.md | 从环境和仓库发现搭建 |
| 连接规范 | references/connection-conventions.md | 环境变量格式、JSON解析、可移植代码 |
| 资源类型目录 | references/resource-type-catalog.md | 可用类型、Schema、属性 |
| 本地开发 | references/local-development.md | kind、本地仓库、containerd、Dockerfile |
| 资源类型YAML | references/resource-type-yaml.md | YAML Schema定义格式 |
| Recipe编写 | references/recipe-authoring.md | Bicep/Terraform Recipe、上下文对象 |
| 环境配置 | references/environment-config.md | 工作区、环境、命名空间 |
| 云服务商 | references/cloud-providers.md | Radius的Azure、AWS凭证 |
| Recipe结构 | references/recipe-structure.md | radius-resource-types中的目录布局 |
| 贡献指南 | references/contribution-guide.md | 向radius-resource-types贡献代码 |
Guardrails
约束规则
- Always check the platform constitution before suggesting resource types, recipes, or cloud-specific patterns.
- Use portable resource types () instead of cloud-specific resources unless explicitly needed.
Radius.* - Never hardcode infrastructure details in application definitions — let recipes handle it.
- Always include — required for all Radius resources.
environment - Handle both connection env var formats (JSON and individual vars) for portability.
_PROPERTIES - Set all recipe-expected properties in Bicep (e.g., ), or use safe defaults in recipes.
size - Always configure — the Radius Bicep extension won't resolve without it.
bicepconfig.json - When scaffolding , inspect before asking. Infer shared resources and container workloads from the workspace whenever possible.
app.bicep - When shared resources already exist in the environment, declare them with instead of provisioning duplicates.
existing - When shared resources are declared in workspace files such as or
env.bicep, declare them withshared-resources.bicepin the generatedexistinginstead of duplicating them there.app.bicep - Always ask for the OCI registry host when it cannot be inferred from the repository.
- Always ask before setting boolean AI options such as when there is no clear project default.
enableObservability - Move long or multi-line prompt text into a parameter instead of embedding it directly in the AI agent resource.
- When an app uses an AI agent plus shared data resources, prefer agent-to-resource connections over container-to-resource connections.
- Never register recipes from local file paths — publish to an OCI registry first.
- Use instead of
host.docker.internalfor in-cluster access to host services.localhost - Use when working with insecure (HTTP) registries.
--plain-http - Generate Bicep extensions after registering resource types for IDE validation.
- Keep resource type interfaces cloud-agnostic — cloud details belong in recipes, not schemas.
- Always handle missing optional properties in recipes with safe defaults.
- Use (plural map) for
containersandRadius.Compute(singular) forcontainer.Applications.Core - Test with before deploying to production.
rad run
- 始终先检查平台规范,再推荐资源类型、Recipe或云特定模式。
- 使用可移植资源类型()而非云特定资源,除非明确需要。
Radius.* - 永远不要在应用定义中硬编码基础设施细节,让Recipe处理这些内容。
- 始终包含—— 所有Radius资源都需要该参数。
environment - 同时支持两种连接环境变量格式(JSON和独立变量)以保证可移植性。
_PROPERTIES - 在Bicep中设置所有Recipe期望的属性(如),或在Recipe中使用安全默认值。
size - 始终配置—— 没有它,Radius Bicep扩展无法正常解析。
bicepconfig.json - 搭建时,先检查再询问。尽可能从工作区推断共享资源和容器工作负载。
app.bicep - 当共享资源已在环境中存在时,使用声明,而非重复创建。
existing - 当共享资源在或
env.bicep等工作区文件中已声明时,在生成的shared-resources.bicep中使用app.bicep声明,而非重复创建。existing - 当无法从仓库推断时,始终询问OCI仓库地址。
- 当没有明确的项目默认值时,设置布尔AI选项(如)前必须询问用户。
enableObservability - 将长或多行提示词移至参数中,而非直接内嵌到AI Agent资源。
- 当应用使用AI Agent加共享数据资源时,优先建立Agent到资源的连接,而非容器到资源的连接。
- 永远不要从本地文件路径注册Recipe —— 先发布到OCI仓库。
- 使用而非
host.docker.internal实现集群内对主机服务的访问。localhost - 使用参数 处理非安全(HTTP)仓库。
--plain-http - 注册资源类型后生成Bicep扩展,以支持IDE验证。
- 保持资源类型接口与云无关 —— 云相关细节应放在Recipe中,而非Schema。
- 在Recipe中始终处理缺失的可选属性,使用安全默认值。
- 使用
Radius.Compute(复数映射),containers使用Applications.Core(单数)。container - 部署到生产环境前,使用测试。
rad run