Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add How-To: Portable Resources guide #835

Merged
merged 46 commits into from
Dec 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
3da0726
How-To: Portable Resources
jasonviviano Oct 12, 2023
afd016b
Update references to sample images (#828)
AaronCrawfis Oct 12, 2023
81c7e19
Add how-to guide on local dev recipes (#822)
Reshrahim Oct 12, 2023
4e32c67
Apply suggestions from code review
jasonviviano Oct 12, 2023
fbd943c
Standardize pre-reqs for all how-tos (#836)
Reshrahim Oct 12, 2023
58c48f3
Update instructions for `How To Configure AWS Provider` (#840)
kachawla Oct 13, 2023
51c33c4
Update instructions for edge and binary deployments (#849)
AaronCrawfis Oct 16, 2023
83ed539
Updates in How To for setting Kubernetes metadata (#857)
kachawla Oct 17, 2023
35d7b07
Addressed feedback
jasonviviano Oct 17, 2023
02d41ec
Update docs/content/guides/author-apps/portable-resources/howto-autho…
jasonviviano Oct 17, 2023
526a989
Tutorial: Create a Radius application (#736)
AaronCrawfis Oct 17, 2023
9dff35c
Apply suggestions from code review
jasonviviano Oct 23, 2023
b4804e3
Fixed old reference to dev Recipe name (#863)
jasonviviano Oct 17, 2023
3426526
Adding "Why Radius?" concept doc (#827)
rynowak Oct 17, 2023
253c764
Update rad CLI documentation (#868)
rad-ci-bot Oct 18, 2023
c8da43a
Autogenerate rad CLI reference docs (#872)
rad-ci-bot Oct 18, 2023
2ce4cd0
Autogenerate rad CLI reference docs (#873)
rad-ci-bot Oct 18, 2023
61262ae
Autogenerate rad CLI reference docs (#874)
rad-ci-bot Oct 18, 2023
588d1ab
Upmerge 10-18-2023 (#877)
Reshrahim Oct 18, 2023
6a20912
Add new image shortcode (#888)
AaronCrawfis Oct 19, 2023
f29396b
tutorial for adding radius to existing application (#870)
willtsai Oct 20, 2023
9e737af
Autogenerate rad CLI reference docs (#900)
rad-ci-bot Oct 20, 2023
ae222f6
Add rewrite rule for docs.radapp.dev (#897)
AaronCrawfis Oct 20, 2023
f4f919c
Autogenerate rad CLI reference docs (#876)
rad-ci-bot Oct 21, 2023
cc49dae
Fixed snippet
jasonviviano Oct 23, 2023
c0eec97
Update all image blocks to use new shortcode (#886)
Reshrahim Oct 23, 2023
79c07dc
Changed `azurecr` references to `ghcr` (#893)
jasonviviano Oct 24, 2023
effe404
Apply suggestions from code review
jasonviviano Oct 24, 2023
f391894
Render links in new tab (#909)
Reshrahim Oct 25, 2023
d42cdac
Markdownify content when using edge and latest shortcodes (#899)
Reshrahim Oct 26, 2023
4406e50
Adding Collaboration concepts doc" (#833)
rynowak Oct 30, 2023
b5db73b
Ignore triple-backtick code blocks in spellcheck (#919)
rynowak Oct 31, 2023
53433af
How-To: k8s pod patching (#800)
willtsai Nov 1, 2023
b394b43
Adding suggested changes to snippets
jasonviviano Nov 6, 2023
f8784a4
Added a Recipe snippet section.
jasonviviano Nov 6, 2023
fb91220
Merge branch 'edge' into jasonviviano/how-to-define-portable-resource
jasonviviano Nov 6, 2023
662e8bb
Spellcheck
jasonviviano Nov 7, 2023
70f29b1
Merge branch 'jasonviviano/how-to-define-portable-resource' of https:…
jasonviviano Nov 7, 2023
bb98cd9
Merge branch 'edge' into jasonviviano/how-to-define-portable-resource
jasonviviano Nov 7, 2023
a901187
Merge branch 'edge' into jasonviviano/how-to-define-portable-resource
jasonviviano Nov 27, 2023
0d31fa9
Applied feedback to shorten Recipe section in guide for portable reso…
jasonviviano Nov 27, 2023
69ede39
Merge branch 'edge' into jasonviviano/how-to-define-portable-resource
jasonviviano Nov 29, 2023
36ba281
Applied suggestions from code review
jasonviviano Nov 29, 2023
531686f
Added a new section to step 3 for the portable resource guide.
jasonviviano Nov 30, 2023
9d170e1
Merge branch 'edge' into jasonviviano/how-to-define-portable-resource
AaronCrawfis Dec 1, 2023
fb7d67e
Fix formatting
AaronCrawfis Dec 2, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/config/en-custom.txt
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ radapp
radiuspublic
rbac
rediscaches
RedisCache
readinessProbe
redis
redisCaches
Expand All @@ -311,6 +312,7 @@ resourceGroup
replacePrefix
repo
resourceGroupName
RecipeSpecified
resourceId
resourcegroup
rollout
Expand Down Expand Up @@ -618,6 +620,7 @@ ECS
EFS
EIP
EMR
EMPTYCONTAINER
EMRContainers
EMRServerless
ElastiCache
Expand Down
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" >}})

jasonviviano marked this conversation as resolved.
Show resolved Hide resolved
## Step 1: Add a portable resource

jasonviviano marked this conversation as resolved.
Show resolved Hide resolved
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 %}}
jasonviviano marked this conversation as resolved.
Show resolved Hide resolved

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" >}}

jasonviviano marked this conversation as resolved.
Show resolved Hide resolved
{{% /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 enivronment 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
Loading