Skip to content

Commit

Permalink
Merge branch 'edge' into jasonviviano/kubernetes-incremental-guide
Browse files Browse the repository at this point in the history
  • Loading branch information
willtsai authored Dec 6, 2023
2 parents e7f4027 + 325d757 commit 766f343
Show file tree
Hide file tree
Showing 7 changed files with 155 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .github/config/en-custom.txt
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ radapp
radiuspublic
rbac
rediscaches
RedisCache
readinessProbe
redis
redisCaches
Expand All @@ -317,6 +318,7 @@ resourceGroup
replacePrefix
repo
resourceGroupName
RecipeSpecified
resourceId
resourcegroup
rollout
Expand Down Expand Up @@ -624,6 +626,7 @@ ECS
EFS
EIP
EMR
EMPTYCONTAINER
EMRContainers
EMRServerless
ElastiCache
Expand Down Expand Up @@ -1213,3 +1216,4 @@ KubernetesMetadataExtensionLabels
outputResources
SecretStore
plainHTTP
azd
4 changes: 4 additions & 0 deletions docs/content/concepts/faq/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,7 @@ While there isn't direct support for targeting Azure Arc for Radius containers t
[Azure Container Apps](https://azure.microsoft.com/products/container-apps/) is a service that allows developers to deploy containerized applications to Azure without managing any infrastructure.

While Radius only supports Kubernetes today, it is architected to support other hosting platforms in the future, including serverless platforms such as Azure Container Apps. Serverless support is on our roadmap.

### How does Radius compare to Azure Developer CLI (azd)?

The [Azure Developer CLI](https://learn.microsoft.com/en-us/azure/developer/azure-developer-cli/) is an open-source tool that provides developer-friendly commands to simplify the process of building, deploying, and managing Azure resources. While both azd and Radius are geared towards the development and deployment workflows, the most apparent difference is that azd can be only be used to manage Azure resources, whereas Radius supports multiple cloud providers. Radius also introduces a way to model (and not just deploy) entire applications and automate these through [Recipes]({{< ref "guides/recipes/overview">}}), which allows for complete [separation of concerns]({{< ref "collaboration-concept" >}}) between operators and developers. With azd, even though developers may leverage CLI templates to deploy infrastructure, they still need to understand the underlying infrastructure and how to connect to it.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
type: docs
title: "How-To: Author portable resources"
linkTitle: "Author portable resources"
description: "Learn how to author portable resources in Radius"
weight: 200
categories: "How-To"
tags: ["portability"]
---

This guide will teach you how to author a portable resource for your [Radius Application]({{< ref "/guides/author-apps/application/overview" >}}).

## Prerequisites

Before you get started, you'll need to make sure you have the following tools and resources:

- [rad CLI]({{< ref "installation#step-1-install-the-rad-cli" >}})
- [Radius environment]({{< ref "installation#step-3-initialize-radius" >}})
- [Radius Bicep VSCode extension]({{< ref "installation#step-2-install-the-vs-code-extension" >}})

## Step 1: Add a portable resource

Portable resources provide **abstraction** and **portability** to Radius Applications. Radius currently offers options to manually provision the resources or automatically provision them via Recipes:

{{< tabs Recipe Manual >}}

{{% codetab %}}

Recipes handle infrastructure provisioning for you. You can use a Recipe to provision a Redis cache, using your environment's default Recipe.

Create a file named `app.bicep` and paste the following:

{{< rad file="snippets/app-redis-recipe.bicep" embed=true marker="//RECIPE" >}}

To learn more about Recipes visit the [Recipes overview page]({{< ref "/guides/recipes/overview" >}}).

{{% /codetab %}}

{{% codetab %}}

You can also manually manage your infrastructure and use a portable resource to abstract the details. Create a file named `app.bicep` and paste the following:

{{< rad file="snippets/app-redis-manual.bicep" embed=true marker="//MANUAL" >}}

{{% /codetab %}}

{{< /tabs >}}

## Step 2: Add a container

In your Bicep file `app.bicep`, add a container resource that will connect to the Redis cache. Note the connection to the Redis cache automatically injects connection-related environment variables into the container. Optionally, you can also manually access properties and set environment variables based on your portable resource values.

{{< rad file="snippets/app-redis-manual.bicep" embed=true marker="//CONTAINER" >}}

## Step 3: Deploy the app

1. Run your application in your environment:

```bash
rad run ./app.bicep -a demo
```

1. Visit [localhost:3000](http://localhost:3000) in your browser. You should see the following page, now showing injected environment variables:

{{< image src="demo-with-redis-screenshot.png" alt="Screenshot of the demo app with all environment variables" width=1000px >}}

## Cleanup

Run `rad app delete` to cleanup your Radius application, container, and Redis cache:

```bash
rad app delete -a demo
```

## Further reading

- [Portable resource overview]({{< ref "/guides/author-apps/portable-resources/overview" >}})
- [Radius Application overview]({{< ref "/guides/author-apps/application/overview" >}})
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
//MANUAL
import radius as radius

@description('Specifies the environment for resources.')
param environment string

@description('Specifies the application for resources.')
param application string

resource redis 'Applications.Datastores/redisCaches@2023-10-01-preview' = {
name: 'myredis'
properties: {
environment: environment
application: application
resourceProvisioning: 'manual'
username: 'myusername'
host: 'mycache.contoso.com'
port: 8080
secrets: {
password: '******'
}
}
}
//MANUAL

//CONTAINER
resource container 'Applications.Core/containers@2023-10-01-preview' = {
name: 'demo'
properties: {
application: application
container: {
image: 'ghcr.io/radius-project/samples/demo:latest'
env: {
// Manually access Redis connection information
REDIS_CONNECTION: redis.connectionString()
}
ports: {
web: {
containerPort: 3000
}
}
}
connections: {
// Automatically inject connection details
redis: {
source: redis.id
}
}
}
}
//CONTAINER
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//RECIPE
import radius as radius

@description('Specifies the environment for resources.')
param environment string

@description('Specifies the application for resources.')
param application string

resource redis 'Applications.Datastores/redisCaches@2023-10-01-preview'= {
name: 'myredis'
properties: {
environment: environment
application: application
}
}
//RECIPE
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ type: docs
title: "Overview: Portable Resources"
linkTitle: "Overview"
description: "Add portable resources to your Radius Application for infrastructure portability"
weight: 600
weight: 100
categories: "Overview"
tags: ["portability"]
---
Expand Down

0 comments on commit 766f343

Please sign in to comment.