Skip to content

Commit

Permalink
Merge branch 'v0.23' into edge
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronCrawfis committed Aug 17, 2023
2 parents c902970 + e7235aa commit 59c2fb7
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 24 deletions.
4 changes: 4 additions & 0 deletions .github/config/en-custom.txt
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,10 @@ vHost
URI
uri
rabbitMQ
linenos
linenostart
markdownConfig
hl
azureCache
listKeys
primaryKey
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/website.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
GOVER: '^1.17'
TUTORIAL_PATH: './docs/content/user-guides/tutorials/'
CODE_ZIP_PATH: './docs/static/tutorial/'
HUGO_VERSION: 0.117.0
HUGO_ENV: production
SWA_BASE: 'wonderful-plant-020417a1e'
steps:
Expand Down Expand Up @@ -48,7 +49,7 @@ jobs:
- name: Setup Hugo
uses: peaceiris/[email protected]
with:
hugo-version: 0.102.3
hugo-version: ${{ env.HUGO_VERSION }}
extended: true
- name: Setup Docsy
run: |
Expand Down
34 changes: 15 additions & 19 deletions docs/content/getting-started/first-app/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ This guide offers the quickest way to get started using Radius. You'll walk thro
## 1. Have your Kubernetes cluster handy

Radius runs inside [Kubernetes]({{< ref "/operations/platforms/kubernetes" >}}). However you run Kubernetes, get a cluster ready.

> *If you don't have a preferred way to create Kubernetes clusters, you might try using [k3d](https://k3d.io/), which runs a minimal Kubernetes distribution in Docker.*
> *If you don't have a preferred way to create Kubernetes clusters, you could try using [k3d](https://k3d.io/), which runs a minimal Kubernetes distribution in Docker.*
Ensure your cluster is set as your current context:

Expand Down Expand Up @@ -86,13 +85,13 @@ Created ".rad/rad.yaml"

In addition to starting Radius services in your Kubernetes cluster, this initialization command creates a default application (`app.bicep`) as your starting point. It contains a single container definition (`demo`).

{{< rad file="snippets/app.bicep" embed=true >}}
{{< rad file="snippets/app.bicep" embed=true markdownConfig="{linenos=table,linenostart=1}" >}}

> This file will run the `radius.azurecr.io/tutorial/webapp` image. This image is published by the Radius team to a public registry, you do not need to create it.
## 4. Run the app

Use the `rad run` command to run the app in your environment:
Use the below command to run the app in your environment, then access the application by opening [http://localhost:3000](http://localhost:3000) in a browser.

```bash
rad run app.bicep
Expand All @@ -104,8 +103,6 @@ This command:
- Creates a port-forward from localhost to port 3000 inside the container so you can navigate to the app's frontend UI
- Streams container logs to your terminal

Access the application by opening [http://localhost:3000](http://localhost:3000) in a browser:

<img src="./demo-screenshot.png" alt="Screenshot of the demo container" width=400>
<br /><br />
Congrats! You're running your first Radius app.
Expand All @@ -125,36 +122,35 @@ In this step you will:

Open `app.bicep` in your editor and get ready to edit the file.

First add some new code to `app.bicep` by pasting in the content below:

{{< rad file="snippets/app-with-redis-snippets.bicep" embed=true marker="//REDIS" >}}
First add some new code to `app.bicep` by pasting in the content below at the end of the file. This code creates a Redis Cache using a Radius Recipe:

The code you just added creates a Redis Cache resource and specifies that it should be created by a Recipe.
{{< rad file="snippets/app-with-redis-snippets.bicep" embed=true marker="//REDIS" markdownConfig="{linenos=table,linenostart=21}" >}}

Next, add this code to the container definition inside `properties`:
Next, update your container definition to include `connections` inside `properties`. This code creates a connection between the container and the database. Based on this connection, Radius will inject environment variables into the container that inform the container how to connect. You will view these in the next step.

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

The code you just added creates a connection between the container and the database. Based on this connection, Radius will define environment variables in the container that tell the container how to connect. You will view these in the next step.
{{< rad file="snippets/app-with-redis-snippets.bicep" embed=true marker="//CONNECTION" markdownConfig="{linenos=table,hl_lines=[\"13-17\"],linenostart=7}" >}}

Your updated `app.bicep` will look like this:

{{< rad file="snippets/app-with-redis.bicep" embed=true >}}
{{< rad file="snippets/app-with-redis.bicep" embed=true markdownConfig="{linenos=table}" >}}

## 6. Rerun the application with a database

Make sure to save the changes in your `app.bicep` file, then use `rad run` to run the updated application again:
Use the command below to run the updated application again, then open the browser to [http://localhost:3000](http://localhost:3000).

```sh
rad run app.bicep
```

Open the browser to [http://localhost:3000](http://localhost:3000) and you should see that the environment variables have changed. The `demo` container now has connection information for Redis (`CONNECTION_REDIS_HOST`, `CONNECTION_REDIS_PORT`).
You should see that the environment variables have changed. The `demo` container now has connection information for Redis (`CONNECTION_REDIS_HOST`, `CONNECTION_REDIS_PORT`).

<img src="./demo-with-redis-screenshot.png" alt="Screenshot of the demo container" width=400>
<img src="./demo-with-redis-screenshot.png" alt="Screenshot of the demo container" width=500>
<br /><br />

Navigate to the TODO page and test out the application. Using the TODO page will update the saved state in Redis.
Navigate to the TODO List tab and test out the application. Using the TODO page will update the saved state in Redis.

<img src="./demo-with-todolist.png" alt="Screenshot of the todolist" width=500>
<br /><br />

Press CTRL+C when you are finished with the website.

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
Expand Up @@ -4,6 +4,7 @@ import radius as radius
@description('The app ID of your Radius application. Set automatically by the rad CLI.')
param application string

//CONNECTION
resource demo 'Applications.Core/containers@2022-03-15-privatepreview' = {
name: 'demo'
properties: {
Expand All @@ -16,15 +17,14 @@ resource demo 'Applications.Core/containers@2022-03-15-privatepreview' = {
}
}
}
//CONNECTION
connections: {
redis: {
source: db.id
}
}
//CONNECTION
}
}
//CONNECTION

//REDIS
@description('The environment ID of your Radius application. Set automatically by the rad CLI.')
Expand Down
2 changes: 2 additions & 0 deletions docs/content/web.config
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
<mimeMap fileExtension=".bicep" mimeType="text/plain" />
<remove fileExtension=".json" />
<mimeMap fileExtension=".json" mimeType="application/json" />
<remove fileExtension=".yaml" />
<mimeMap fileExtension=".yaml" mimeType="application/yaml" />
</staticContent>
</system.webServer>
</configuration>
6 changes: 4 additions & 2 deletions docs/layouts/shortcodes/rad.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{{ $file := .Get "file" }}
{{ $filePath := (path.Join $.Page.File.Dir $file ) }}
{{ $fileContents := $filePath | readFile }}
{{ $lang := "Bicep" }}
{{ $lang := .Get "lang" | default "bicep" }}
{{ $embed := .Get "embed" | default false }}
{{ $download := .Get "download" | default false }}
{{ $markdownConfig := .Get "markdownConfig" | default "" }}

{{ if $download }}
<a class="btn btn-primary btn-sm" href={{ print $file }} download>Download Bicep file</a>
<br /><br />
Expand All @@ -23,5 +25,5 @@
{{ $fileContents = replaceRE $regex $replaceWith $fileContents}}
{{ end }}
{{ end }}
{{ (print "```" $lang "\n" $fileContents "\n```") | markdownify }}
{{ (print "```" $lang $markdownConfig "\n" $fileContents "\n```") | markdownify }}
{{ end }}

0 comments on commit 59c2fb7

Please sign in to comment.