diff --git a/docs/content/getting-started/quickstarts/quickstart-dapr/_index.md b/docs/content/getting-started/quickstarts/quickstart-dapr/_index.md deleted file mode 100644 index 2229dd74b..000000000 --- a/docs/content/getting-started/quickstarts/quickstart-dapr/_index.md +++ /dev/null @@ -1,72 +0,0 @@ ---- -type: docs -title: "Quickstart: Dapr Microservices" -linkTitle: "Dapr microservices" -description: "Learn Radius by authoring templates and deploying a Dapr application" -weight: 300 -no_list: true -slug: "dapr" -categories: "Quickstart" -tags : ["Dapr"] ---- - -## Overview - -This tutorial will teach you how to deploy a Dapr microservices application using Radius. You will learn: - -- The concepts of the Radius application model -- How [Dapr and Radius]({{< ref dapr-resources >}}) seamlessly work together -- The basic syntax of the [Bicep language]({{< ref bicep >}}) - -No prior knowledge of Dapr, Radius, or Bicep is needed. - -### Quickstart steps - -In this tutorial, you will: - -1. Review and understand the Radius Dapr microservices application -1. Deploy the backend container -1. Deploy and connect a Dapr statestore resource -1. Add a frontend container to submit orders to the backend - -### Radius + Dapr - -Dapr integrates directly with Radius to provide a simple, easy to use, and powerful way to build microservices. Dapr developers can: - -- Model Dapr building blocks as [Radius link resources]({{< ref dapr-schema >}}) -- Automatically generate Dapr component configuration files based on the source resource -- (coming soon) Automatically configure component scoping and other secure configuration based upon connections to the Dapr links - -## Prerequisites - -- [Radius CLI]({{< ref "getting-started" >}}) -- [kubectl CLI](https://kubernetes.io/docs/tasks/tools/) -- [Visual Studio Code](https://code.visualstudio.com/) (recommended) - - The [Radius VSCode extension]({{< ref "getting-started" >}}) provides syntax highlighting, completion, and linting. - - You can also complete this quickstart with any basic text editor. -- [Install Dapr](https://docs.dapr.io/operations/hosting/kubernetes/kubernetes-deploy/) - -### Initialize a Radius environment - -This tutorial can be completed on any platform Radius supports. To get started, create a new environment: - -{{< tabs Kubernetes >}} - -{{% codetab %}} -A Radius environment can be created in any [supported Kubernetes cluster]({{< ref "/operations/platforms/kubernetes#supported-clusters" >}}): - -```sh -rad init -``` - -If you wish to deploy an Azure storage account in an upcoming step follow the instructions to setup an Azure [cloud provider]({{< ref providers >}}). - -{{% /codetab %}} - -{{< /tabs >}} - -## Next step - -Now that you have a Radius environment setup let's take a look at the Dapr microservices application: - -{{< button text="Next: Application overview" page="dapr-microservices-overview.md" >}} diff --git a/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-add-dapr/index.md b/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-add-dapr/index.md deleted file mode 100644 index 995bdc4bd..000000000 --- a/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-add-dapr/index.md +++ /dev/null @@ -1,117 +0,0 @@ ---- -type: docs -title: "Add Dapr sidecars and a Dapr statestore to the app" -linkTitle: "Add Dapr" -slug: "add-dapr" -description: "How to enable Dapr sidecars and connect a Dapr state store to the tutorial application" -weight: 3000 ---- - -Currently, the data you send to `backend` will be stored in memory inside the application. If the website restarts then all of your data will be lost! - -In this step you will learn how to add a state store database and connect to it from the application with Dapr. - -## Add a Dapr extension - -A [Dapr extension]({{< ref dapr-extension >}}) on the `backend` resource can be used to describe the Dapr configuration: - -{{< rad file="snippets/extension.bicep" embed=true marker="//SAMPLE" replace-key-container="//CONTAINER" replace-value-container="container: {...}" >}} - -The `extensions` section is used to configure cross-cutting behaviors of components. Since Dapr is not part of the standard definition of a container, it can be added via a extension. Extensions have a `kind` so that they can be strongly typed. - -## Add Dapr statestore - -Now that the backend is configured with Dapr, we need to define a state store to save information about orders. - -You can choose between a Redis container or Azure Table Storage - -{{< tabs "Redis Container" "Azure Table Storage" >}} - -{{< codetab >}} - -{{< rad file="snippets/statestore.bicep" embed=true marker="//SAMPLE" >}} -{{< /codetab >}} - -{{< codetab >}} -{{< rad file="snippets/statestore-azure.bicep" embed=true marker="//SAMPLE" >}} -{{< /codetab >}} - -{{< /tabs >}} - -## Reference statestore from `backend` - -Radius captures both logical relationships and related operational details. Examples of this include: wiring up connection strings, granting permissions, or restarting components when a dependency changes. - -The [`connections` property]({{< ref "appmodel-concept" >}}) is used to configure relationships between from a service to another resource. - -Add a [`connection`]({{< ref "appmodel-concept" >}}) from `backend` to the `orders` state store. This declares the _intention_ from the `backend` container to communicate with the `statestore` resource - -{{< rad file="snippets/connection.bicep" embed=true marker="//BACKEND" replace-key-container="//CONTAINER" replace-value-container="container: {...}" replace-key-extensions="//EXTENSIONS" replace-value-extensions="extensions: [...]" >}} - -### Injected settings from connections - -Adding a connection to the state store also [configures environment variables]({{< ref "dapr-statestore#provided-data" >}}) inside the the `statestore` component. - -With the connection name of `statestore` and a statestore name of `orders`, Radius will inject information related to the state store using the environment variable `CONNECTION_ORDERS_COMPONENTNAME`. The application code inside `backend` uses this environment variable to access the state store name and avoid hardcoding. - -```js -const stateStoreName = process.env.CONNECTION_ORDERS_COMPONENTNAME; -``` - -## Deploy application with Dapr - -1. Make sure your `dapr.bicep` file matches the full tutorial file: - - - Redis state store: {{< rad file="snippets/dapr.bicep" download=true >}} - - Azure storage state store: {{< rad file="snippets/dapr-azure.bicep" download=true >}} - -1. Now you are ready to re-deploy the application, including the Dapr state store. Switch to the command-line and run: - - ```sh - rad deploy dapr.bicep - ``` - - If you are using the Azure storage Dapr state store starter, this may take a couple minutes as the storage account is deployed. - -1. You can confirm all the resources were deployed by running: - - ```sh - rad resource list containers --application dapr-quickstart - ``` - - Example output: - - ```sh - RESOURCE TYPE - backend applications.core/containers - ``` - - ```sh - rad resource list daprstatestores --application dapr-quickstart - ``` - - Example output: - - ```sh - RESOURCE TYPE - orders applications.link/daprstatestores - ``` - You should see both `backend` and `statestore` components in your `dapr-quickstart` application. - -1. To test out the state store, open a local tunnel on port 3000 again: - - ```sh - rad resource expose containers backend --application dapr-quickstart --port 3000 - ``` - -1. Visit the the URL [http://localhost:3000/order](http://localhost:3000/order) in your browser. You should see the following message: - - ```json - {"message":"no orders yet"} - ``` - - If your message matches, then the container is able to communicate with the state store. - -1. Press CTRL+C to terminate the port-forward. - -
{{< button text="Next: Add an frontend component to the app" page="dapr-microservices-add-ui.md" >}} diff --git a/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-add-dapr/snippets/connection.bicep b/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-add-dapr/snippets/connection.bicep deleted file mode 100644 index b47a14d7c..000000000 --- a/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-add-dapr/snippets/connection.bicep +++ /dev/null @@ -1,58 +0,0 @@ -import radius as radius - -param environment string - -resource app 'Applications.Core/applications@2022-03-15-privatepreview' = { - name: 'dapr-quickstart' - properties: { - environment: environment - } -} - -//BACKEND -resource backend 'Applications.Core/containers@2022-03-15-privatepreview' = { - name: 'backend' - properties: { - application: app.id - //CONTAINER - container: { - image: 'radius.azurecr.io/quickstarts/dapr-backend:latest' - ports: { - orders: { - containerPort: 3000 - } - } - } - //CONTAINER - connections: { - orders: { - source: stateStore.id - } - } - //EXTENSIONS - extensions: [ - { - kind: 'daprSidecar' - appId: 'backend' - appPort: 3000 - } - ] - //EXTENSIONS - } -} -//BACKEND - -resource stateStore 'Applications.Link/daprStateStores@2022-03-15-privatepreview' = { - name: 'orders' - properties: { - environment: environment - application: app.id - resourceProvisioning: 'manual' - type: 'state.redis' - version: 'v1' - metadata: { - redisHost: '' - redisPassword: '' - } - } -} diff --git a/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-add-dapr/snippets/dapr-azure.bicep b/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-add-dapr/snippets/dapr-azure.bicep deleted file mode 100644 index d28dbec0c..000000000 --- a/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-add-dapr/snippets/dapr-azure.bicep +++ /dev/null @@ -1,80 +0,0 @@ -import radius as radius - -@description('The Azure region to deploy Azure resource(s) into. Defaults to the region of the target Azure resource group.') -param location string = resourceGroup().location - -param environment string - -resource app 'Applications.Core/applications@2022-03-15-privatepreview' = { - name: 'dapr-quickstart' - properties: { - environment: environment - } -} - -resource backend 'Applications.Core/containers@2022-03-15-privatepreview' = { - name: 'backend' - properties: { - application: app.id - container: { - image: 'radius.azurecr.io/quickstarts/dapr-backend:latest' - ports: { - web: { - containerPort: 3000 - } - } - } - connections: { - orders: { - source: stateStore.id - } - } - extensions: [ - { - kind: 'daprSidecar' - appId: 'backend' - appPort: 3000 - } - ] - } -} - -resource account 'Microsoft.Storage/storageAccounts@2019-06-01' = { - name: 'dapr${uniqueString(resourceGroup().id)}' - location: location - sku: { - name: 'Standard_LRS' - } - kind: 'StorageV2' - properties: { - accessTier: 'Hot' - } - - resource tableServices 'tableServices' = { - name: 'default' - - resource table 'tables' = { - name: 'dapr' - } - } -} - -resource stateStore 'Applications.Link/daprStateStores@2022-03-15-privatepreview' = { - name: 'orders' - properties: { - environment: environment - application: app.id - resourceProvisioning: 'manual' - resources: [ - { id: account.id } - { id: account::tableServices::table.id } - ] - metadata: { - accountName: account.name - accountKey: account.listKeys().keys[0].value - tableName: account::tableServices::table.name - } - type: 'state.azure.tablestorage' - version: 'v1' - } -} diff --git a/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-add-dapr/snippets/dapr.bicep b/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-add-dapr/snippets/dapr.bicep deleted file mode 100644 index 660a4ef18..000000000 --- a/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-add-dapr/snippets/dapr.bicep +++ /dev/null @@ -1,132 +0,0 @@ -import radius as radius - -@description('Specifies the environment for resources.') -param environment string - -@description('Specifies Kubernetes namespace for redis.') -param namespace string = 'default' - -//////////////////////////////////////////////////////////////////// -// Radius resources -//////////////////////////////////////////////////////////////////// - -resource app 'Applications.Core/applications@2022-03-15-privatepreview' = { - name: 'dapr-quickstart' - properties: { - environment: environment - } -} - -resource backend 'Applications.Core/containers@2022-03-15-privatepreview' = { - name: 'backend' - properties: { - application: app.id - container: { - image: 'radius.azurecr.io/quickstarts/dapr-backend:edge' - ports: { - web: { - containerPort: 3000 - } - } - } - connections: { - orders: { - source: stateStore.id - } - } - extensions: [ - { - kind: 'daprSidecar' - appId: 'backend' - appPort: 3000 - } - ] - } -} - -resource stateStore 'Applications.Link/daprStateStores@2022-03-15-privatepreview' = { - name: 'statestore' - properties: { - environment: environment - application: app.id - resourceProvisioning: 'manual' - type: 'state.redis' - version: 'v1' - metadata: { - redisHost: '${service.metadata.name}.${namespace}.svc.cluster.local:${service.spec.ports[0].port}' - redisPassword: '' - } - } -} - -//////////////////////////////////////////////////////////////////// -// Redis Kubernetes resources -//////////////////////////////////////////////////////////////////// - -import kubernetes as kubernetes{ - kubeConfig: '' - namespace: namespace -} - -resource statefulset 'apps/StatefulSet@v1' = { - metadata: { - name: 'redis' - labels: { - app: 'redis' - } - } - spec: { - replicas: 1 - serviceName: service.metadata.name - selector: { - matchLabels: { - app: 'redis' - } - } - template: { - metadata: { - labels: { - app: 'redis' - } - } - spec: { - automountServiceAccountToken: true - terminationGracePeriodSeconds: 10 - containers: [ - { - name: 'redis' - image: 'redis:6.2' - securityContext: { - allowPrivilegeEscalation: false - } - ports: [ - { - containerPort: 6379 - } - ] - } - ] - } - } - } -} - -resource service 'core/Service@v1' = { - metadata: { - name: 'redis' - labels: { - app: 'redis' - } - } - spec: { - clusterIP: 'None' - ports: [ - { - port: 6379 - } - ] - selector: { - app: 'redis' - } - } -} diff --git a/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-add-dapr/snippets/extension.bicep b/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-add-dapr/snippets/extension.bicep deleted file mode 100644 index b1554ff5d..000000000 --- a/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-add-dapr/snippets/extension.bicep +++ /dev/null @@ -1,36 +0,0 @@ -import radius as radius - -param environment string - -resource app 'Applications.Core/applications@2022-03-15-privatepreview' = { - name: 'dapr-quickstart' - properties: { - environment: environment - } -} - -//SAMPLE -resource backend 'Applications.Core/containers@2022-03-15-privatepreview' = { - name: 'backend' - properties: { - application: app.id - //CONTAINER - container: { - image: 'radius.azurecr.io/quickstarts/dapr-backend:latest' - ports: { - orders: { - containerPort: 3000 - } - } - } - //CONTAINER - extensions: [ - { - kind: 'daprSidecar' - appId: 'backend' - appPort: 3000 - } - ] - } -} -//SAMPLE diff --git a/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-add-dapr/snippets/statestore-azure.bicep b/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-add-dapr/snippets/statestore-azure.bicep deleted file mode 100644 index b054c7ee7..000000000 --- a/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-add-dapr/snippets/statestore-azure.bicep +++ /dev/null @@ -1,55 +0,0 @@ -import radius as radius - -param environment string - -resource app 'Applications.Core/applications@2022-03-15-privatepreview' = { - name: 'dapr-quickstart' - properties: { - environment: environment - } -} - -//SAMPLE -@description('The Azure region to deploy Azure resource(s) into. Defaults to the region of the target Azure resource group.') -param location string = resourceGroup().location - -resource stateStore 'Applications.Link/daprStateStores@2022-03-15-privatepreview' = { - name: 'orders' - properties: { - environment: environment - application: app.id - resourceProvisioning: 'manual' - resources: [ - { id: account.id } - { id: account::tableServices::table.id } - ] - metadata: { - accountName: account.name - accountKey: account.listKeys().keys[0].value - tableName: account::tableServices::table.name - } - type: 'state.azure.tablestorage' - version: 'v1' - } -} - -resource account 'Microsoft.Storage/storageAccounts@2019-06-01' = { - name: 'dapr${uniqueString(resourceGroup().id)}' - location: location - sku: { - name: 'Standard_LRS' - } - kind: 'StorageV2' - properties: { - accessTier: 'Hot' - } - - resource tableServices 'tableServices' = { - name: 'default' - - resource table 'tables' = { - name: 'dapr' - } - } -} -//SAMPLE diff --git a/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-add-dapr/snippets/statestore.bicep b/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-add-dapr/snippets/statestore.bicep deleted file mode 100644 index fdb740bde..000000000 --- a/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-add-dapr/snippets/statestore.bicep +++ /dev/null @@ -1,96 +0,0 @@ -import radius as radius - -param environment string - -resource app 'Applications.Core/applications@2022-03-15-privatepreview' = { - name: 'dapr-quickstart' - properties: { - environment: environment - } -} - -//SAMPLE -param namespace string = 'default' -resource stateStore 'Applications.Link/daprStateStores@2022-03-15-privatepreview' = { - name: 'statestore' - properties: { - environment: environment - application: app.id - resourceProvisioning: 'manual' - type: 'state.redis' - version: 'v1' - metadata: { - redisHost: '${service.metadata.name}.${namespace}.svc.cluster.local:${service.spec.ports[0].port}' - redisPassword: '' - } - } -} - -import kubernetes as kubernetes{ - kubeConfig: '' - namespace: namespace -} - -resource statefulset 'apps/StatefulSet@v1' = { - metadata: { - name: 'redis' - labels: { - app: 'redis' - } - } - spec: { - replicas: 1 - serviceName: service.metadata.name - selector: { - matchLabels: { - app: 'redis' - } - } - template: { - metadata: { - labels: { - app: 'redis' - } - } - spec: { - automountServiceAccountToken: true - terminationGracePeriodSeconds: 10 - containers: [ - { - name: 'redis' - image: 'redis:6.2' - securityContext: { - allowPrivilegeEscalation: false - } - ports: [ - { - containerPort: 6379 - } - ] - } - ] - } - } - } -} - -resource service 'core/Service@v1' = { - metadata: { - name: 'redis' - labels: { - app: 'redis' - } - } - spec: { - clusterIP: 'None' - ports: [ - { - port: 6379 - } - ] - selector: { - app: 'redis' - } - } -} -//SAMPLE diff --git a/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-add-ui/index.md b/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-add-ui/index.md deleted file mode 100644 index 512ab06e1..000000000 --- a/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-add-ui/index.md +++ /dev/null @@ -1,79 +0,0 @@ ---- -type: docs -title: "Add a frontend UI to the app" -linkTitle: "Add frontend" -slug: "add-frontend" -description: "How to add a frontend user interface to the tutorial application" -weight: 4000 ---- - -To complete the application, you'll add another component for the frontend user interface. - -## Add `frontend` container - -Another container resource is used to specify a few properties about the order generator: - -- **container image**: `radius.azurecr.io/quickstarts/dapr-frontend:edge` is a Docker image the container will run. -- **environment variables**: The `CONNECTION_BACKEND_APPID` environment variable will be used to configure the appID of the backend. -- **extensions**: `daprSidecar` configures Dapr on the container, which is used to invoke the backend. - -{{< rad file="snippets/frontend.bicep" marker="//FRONTEND" embed=true >}} - -As before with connections, the `frontend` component is using an environment variable to get information about the the `backend` Dapr route. This avoids hardcoding. - -```C# -var appId = Environment.GetEnvironmentVariable("CONNECTION_BACKEND_APPID"); -services.AddSingleton(DaprClient.CreateInvokeHttpClient(appId)); -``` - -## Add HTTP Route and Gateway - -Additionally, a [Gateway]({{< ref gateway >}}) and an [HttpRoute]({{< ref httproute >}}) are configured to expose the `frontend` container on a public endpoint. - -{{< rad file="snippets/frontend.bicep" marker="//ROUTES" embed=true >}} - -## Deploy application - -1. Make sure your Bicep file matches the full tutorial file: - - - Redis state store: {{< rad file="./snippets/dapr.bicep" download=true >}} - - Azure table storage state store: {{< rad file="./snippets/dapr-azure.bicep" download=true >}} - -1. Switch to the command line and run: - - ```sh - rad deploy dapr.bicep - ``` - - Now that we added a `Gateway` and an `HttpRoute`, a public endpoint will be available to your application automatically ([learn more]({{< ref "gateway#hostname-generation">}})). - - Use `rad app status -a dapr-quickstart` to get the endpoint: - - ```sh - APPLICATION RESOURCES - dapr-quickstart 6 - - GATEWAY ENDPOINT - gateway PUBLIC_ENDPOINT - ``` - - Navigate to the endpoint to view the application: - - Screenshot of frontend application - -You have completed this tutorial! - -## Cleanup - -{{% alert title="Delete your environment" color="warning" %}} -If you're done with testing, you can use the rad CLI to [delete the application]({{< ref rad_application_delete.md >}}). -{{% /alert %}} - -## Next steps - -- If you'd like to try another tutorial with your existing environment, go back to the [Radius quickstarts]({{< ref quickstarts >}}) page. -- Related links for Dapr: - - [Dapr documentation](https://docs.dapr.io/) - - [Dapr quickstarts](https://github.com/dapr/quickstarts/tree/v1.0.0/hello-world) - -
{{< button text="Try another quickstart" page="quickstarts" >}} diff --git a/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-add-ui/snippets/dapr-azure.bicep b/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-add-ui/snippets/dapr-azure.bicep deleted file mode 100644 index ed8155fa3..000000000 --- a/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-add-ui/snippets/dapr-azure.bicep +++ /dev/null @@ -1,125 +0,0 @@ -import radius as radius - -@description('The Azure region to deploy Azure resource(s) into. Defaults to the region of the target Azure resource group.') -param location string = resourceGroup().location - -param environment string - -resource app 'Applications.Core/applications@2022-03-15-privatepreview' = { - name: 'dapr-quickstart' - properties: { - environment: environment - } -} - -resource backend 'Applications.Core/containers@2022-03-15-privatepreview' = { - name: 'backend' - properties: { - application: app.id - container: { - image: 'radius.azurecr.io/quickstarts/dapr-backend:edge' - ports: { - web: { - containerPort: 3000 - } - } - } - connections: { - orders: { - source: stateStore.id - } - } - extensions: [ - { - kind: 'daprSidecar' - appId: 'backend' - appPort: 3000 - } - ] - } -} - -resource frontend 'Applications.Core/containers@2022-03-15-privatepreview' = { - name: 'frontend' - properties: { - application: app.id - container: { - image: 'radius.azurecr.io/quickstarts/dapr-frontend:edge' - env: { - CONNECTION_BACKEND_APPID: 'backend' - } - ports: { - ui: { - containerPort: 80 - provides: frontendRoute.id - } - } - } - extensions: [ - { - kind: 'daprSidecar' - appId: 'frontend' - } - ] - } -} - -resource frontendRoute 'Applications.Core/httpRoutes@2022-03-15-privatepreview' = { - name: 'frontend-route' - properties: { - application: app.id - } -} - -resource gateway 'Applications.Core/gateways@2022-03-15-privatepreview' = { - name: 'gateway' - properties: { - application: app.id - routes: [ - { - path: '/' - destination: frontendRoute.id - } - ] - } -} - -resource account 'Microsoft.Storage/storageAccounts@2019-06-01' = { - name: 'dapr${uniqueString(resourceGroup().id)}' - location: location - sku: { - name: 'Standard_LRS' - } - kind: 'StorageV2' - properties: { - accessTier: 'Hot' - } - - resource tableServices 'tableServices' = { - name: 'default' - - resource table 'tables' = { - name: 'dapr' - } - } -} - -resource stateStore 'Applications.Link/daprStateStores@2022-03-15-privatepreview' = { - name: 'orders' - properties: { - environment: environment - application: app.id - resourceProvisioning: 'manual' - resources: [ - { id: account.id } - { id: account::tableServices::table.id } - ] - metadata: { - accountName: account.name - accountKey: account.listKeys().keys[0].value - tableName: account::tableServices::table.name - } - type: 'state.azure.tablestorage' - version: 'v1' - } -} diff --git a/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-add-ui/snippets/dapr.bicep b/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-add-ui/snippets/dapr.bicep deleted file mode 100644 index e2a3e7fd8..000000000 --- a/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-add-ui/snippets/dapr.bicep +++ /dev/null @@ -1,177 +0,0 @@ -import radius as radius - -@description('Specifies the environment for resources.') -param environment string - -@description('Specifies Kubernetes namespace for redis.') -param namespace string = 'default' - -//////////////////////////////////////////////////////////////////// -// Radius resources -//////////////////////////////////////////////////////////////////// - -resource app 'Applications.Core/applications@2022-03-15-privatepreview' = { - name: 'dapr-quickstart' - properties: { - environment: environment - } -} - -resource backend 'Applications.Core/containers@2022-03-15-privatepreview' = { - name: 'backend' - properties: { - application: app.id - container: { - image: 'radius.azurecr.io/quickstarts/dapr-backend:edge' - ports: { - web: { - containerPort: 3000 - } - } - } - connections: { - orders: { - source: stateStore.id - } - } - extensions: [ - { - kind: 'daprSidecar' - appId: 'backend' - appPort: 3000 - } - ] - } -} - -resource frontend 'Applications.Core/containers@2022-03-15-privatepreview' = { - name: 'frontend' - properties: { - application: app.id - container: { - image: 'radius.azurecr.io/quickstarts/dapr-frontend:edge' - env: { - CONNECTION_BACKEND_APPID: 'backend' - } - ports: { - ui: { - containerPort: 80 - provides: frontendRoute.id - } - } - } - extensions: [ - { - kind: 'daprSidecar' - appId: 'frontend' - } - ] - } -} - -resource frontendRoute 'Applications.Core/httpRoutes@2022-03-15-privatepreview' = { - name: 'frontend-route' - properties: { - application: app.id - } -} - -resource gateway 'Applications.Core/gateways@2022-03-15-privatepreview' = { - name: 'gateway' - properties: { - application: app.id - routes: [ - { - path: '/' - destination: frontendRoute.id - } - ] - } -} - -resource stateStore 'Applications.Link/daprStateStores@2022-03-15-privatepreview' = { - name: 'statestore' - properties: { - environment: environment - application: app.id - resourceProvisioning: 'manual' - type: 'state.redis' - version: 'v1' - metadata: { - redisHost: '${service.metadata.name}.${namespace}.svc.cluster.local:${service.spec.ports[0].port}' - redisPassword: '' - } - } -} - -//////////////////////////////////////////////////////////////////// -// Redis Kubernetes resources -//////////////////////////////////////////////////////////////////// - -import kubernetes as kubernetes { - kubeConfig: '' - namespace: namespace -} - -resource statefulset 'apps/StatefulSet@v1' = { - metadata: { - name: 'redis' - labels: { - app: 'redis' - } - } - spec: { - replicas: 1 - serviceName: service.metadata.name - selector: { - matchLabels: { - app: 'redis' - } - } - template: { - metadata: { - labels: { - app: 'redis' - } - } - spec: { - automountServiceAccountToken: true - terminationGracePeriodSeconds: 10 - containers: [ - { - name: 'redis' - image: 'redis:6.2' - securityContext: { - allowPrivilegeEscalation: false - } - ports: [ - { - containerPort: 6379 - } - ] - } - ] - } - } - } -} - -resource service 'core/Service@v1' = { - metadata: { - name: 'redis' - labels: { - app: 'redis' - } - } - spec: { - clusterIP: 'None' - ports: [ - { - port: 6379 - } - ] - selector: { - app: 'redis' - } - } -} diff --git a/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-add-ui/snippets/frontend.bicep b/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-add-ui/snippets/frontend.bicep deleted file mode 100644 index a577aea30..000000000 --- a/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-add-ui/snippets/frontend.bicep +++ /dev/null @@ -1,182 +0,0 @@ -import radius as radius - -@description('Specifies the environment for resources.') -param environment string - -@description('Specifies Kubernetes namespace for redis.') -param namespace string = 'default' - -//////////////////////////////////////////////////////////////////// -// Radius resources -//////////////////////////////////////////////////////////////////// - -resource app 'Applications.Core/applications@2022-03-15-privatepreview' = { - name: 'dapr-quickstart' - properties: { - environment: environment - } -} - -resource backend 'Applications.Core/containers@2022-03-15-privatepreview' = { - name: 'backend' - properties: { - application: app.id - container: { - image: 'radius.azurecr.io/quickstarts/dapr-backend:edge' - ports: { - web: { - containerPort: 3000 - } - } - } - connections: { - orders: { - source: stateStore.id - } - } - extensions: [ - { - kind: 'daprSidecar' - appId: 'backend' - appPort: 3000 - } - ] - } -} - - -//FRONTEND -resource frontend 'Applications.Core/containers@2022-03-15-privatepreview' = { - name: 'frontend' - properties: { - application: app.id - container: { - image: 'radius.azurecr.io/quickstarts/dapr-frontend:edge' - env: { - CONNECTION_BACKEND_APPID: 'backend' - } - ports: { - ui: { - containerPort: 80 - provides: frontendRoute.id - } - } - } - extensions: [ - { - kind: 'daprSidecar' - appId: 'frontend' - } - ] - } -} -//FRONTEND - -//ROUTES -resource frontendRoute 'Applications.Core/httpRoutes@2022-03-15-privatepreview' = { - name: 'frontend-route' - properties: { - application: app.id - } -} - -resource gateway 'Applications.Core/gateways@2022-03-15-privatepreview' = { - name: 'gateway' - properties: { - application: app.id - routes: [ - { - path: '/' - destination: frontendRoute.id - } - ] - } -} -//ROUTES - -resource stateStore 'Applications.Link/daprStateStores@2022-03-15-privatepreview' = { - name: 'statestore' - properties: { - environment: environment - application: app.id - resourceProvisioning: 'manual' - type: 'state.redis' - version: 'v1' - metadata: { - redisHost: '${service.metadata.name}.${namespace}.svc.cluster.local:${service.spec.ports[0].port}' - redisPassword: '' - } - } -} - -//////////////////////////////////////////////////////////////////// -// Redis Kubernetes resources -//////////////////////////////////////////////////////////////////// - -import kubernetes as kubernetes { - kubeConfig: '' - namespace: namespace -} - -resource statefulset 'apps/StatefulSet@v1' = { - metadata: { - name: 'redis' - labels: { - app: 'redis' - } - } - spec: { - replicas: 1 - serviceName: service.metadata.name - selector: { - matchLabels: { - app: 'redis' - } - } - template: { - metadata: { - labels: { - app: 'redis' - } - } - spec: { - automountServiceAccountToken: true - terminationGracePeriodSeconds: 10 - containers: [ - { - name: 'redis' - image: 'redis:6.2' - securityContext: { - allowPrivilegeEscalation: false - } - ports: [ - { - containerPort: 6379 - } - ] - } - ] - } - } - } -} - -resource service 'core/Service@v1' = { - metadata: { - name: 'redis' - labels: { - app: 'redis' - } - } - spec: { - clusterIP: 'None' - ports: [ - { - port: 6379 - } - ] - selector: { - app: 'redis' - } - } -} diff --git a/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-initial-deployment/index.md b/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-initial-deployment/index.md deleted file mode 100644 index 0c6e872d0..000000000 --- a/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-initial-deployment/index.md +++ /dev/null @@ -1,80 +0,0 @@ ---- -type: docs -title: "Deploy the Dapr microservices tutorial backend" -linkTitle: "Deploy backend" -slug: "deploy-backend" -description: "Deploy the application backend container" -weight: 2000 ---- - -## Create a Bicep file - -Radius uses the [Bicep language]({{< ref bicep-language >}}) as its file-format and structure. In this tutorial you will define an app named `dapr-quickstart` that will describe the container, statestore, and route resources in Bicep. - -Create a new file named `dapr.bicep` and paste the following: - -{{< rad file="snippets/app.bicep" embed=true >}} - -## Add `backend` container - -Next you'll add a `backend` [container]({{< ref container >}}) resource for the website's backend. - -Radius captures the relationships and intentions behind an application, which simplifies deployment and management. The single `backend` resource in your Bicep file will contain everything needed for the website backend to run. - -Your `backend` resource, which has resource type Container, will specify: - -- **container image:** `radius.azurecr.io/quickstarts/dapr-backend:edge`, a Docker image the container will run. This is where your application's backend code lives. -- **ports**: orders will be received on port 3000. - -Update your dapr.bicep file to match the full application definition: - -{{< rad file="snippets/backend.bicep" embed=true >}} - -## Deploy the application - -Now you are ready to deploy the application for the first time. - -1. Deploy to your Radius environment via the rad CLI: - - ```sh - rad deploy dapr.bicep - ``` - - This will deploy the application into your environment and launch the container resource for the backend website. - -1. Confirm that your Radius application was deployed: - - ```sh - rad resource list containers --application dapr-quickstart - ``` - - You should see your `backend` resource. Example output: - - ``` - RESOURCE TYPE - backend Applications.Core/containers - ``` - -1. To test your `dapr-quickstart` application, open a local tunnel to your application: - - ```sh - rad resource expose containers backend --application dapr-quickstart --port 3000 - ``` - - {{% alert title="💡 rad resource expose" color="primary" %}} - The [`rad resource expose`]({{< ref rad_resource_expose.md >}}) command accepts the resource type, the resource name, and flags for application name and port. If you changed any of these values when deploying, update your command to match. - {{% /alert %}} - -1. Visit the URL [http://localhost:3000/order](http://localhost:3000/order) in your browser. For now, you should see a message like: - - ```json - {"message":"The container is running, but Dapr has not been configured."} - ``` - - If the message matches, then it means that the container is running as expected. - -1. When you are done testing press `CTRL+C` to terminate the port-forward. - -## Next step - -
{{< button text="Next: Add a Dapr to the app" page="dapr-microservices-add-dapr" >}} diff --git a/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-initial-deployment/radius-explorer-dapr-microservices.png b/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-initial-deployment/radius-explorer-dapr-microservices.png deleted file mode 100644 index ccd24168c..000000000 Binary files a/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-initial-deployment/radius-explorer-dapr-microservices.png and /dev/null differ diff --git a/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-initial-deployment/snippets/app.bicep b/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-initial-deployment/snippets/app.bicep deleted file mode 100644 index 8282f6c1c..000000000 --- a/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-initial-deployment/snippets/app.bicep +++ /dev/null @@ -1,10 +0,0 @@ -import radius as radius - -param environment string - -resource app 'Applications.Core/applications@2022-03-15-privatepreview' = { - name: 'dapr-quickstart' - properties: { - environment: environment - } -} diff --git a/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-initial-deployment/snippets/backend.bicep b/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-initial-deployment/snippets/backend.bicep deleted file mode 100644 index fb064161f..000000000 --- a/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-initial-deployment/snippets/backend.bicep +++ /dev/null @@ -1,25 +0,0 @@ -import radius as radius - -param environment string - -resource app 'Applications.Core/applications@2022-03-15-privatepreview' = { - name: 'dapr-quickstart' - properties: { - environment: environment - } -} - -resource backend 'Applications.Core/containers@2022-03-15-privatepreview' = { - name: 'backend' - properties: { - application: app.id - container: { - image: 'radius.azurecr.io/quickstarts/dapr-backend:edge' - ports: { - orders: { - containerPort: 3000 - } - } - } - } -} diff --git a/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-overview/backend.png b/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-overview/backend.png deleted file mode 100644 index 7f84e4201..000000000 Binary files a/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-overview/backend.png and /dev/null differ diff --git a/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-overview/frontend.png b/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-overview/frontend.png deleted file mode 100644 index e73abf21e..000000000 Binary files a/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-overview/frontend.png and /dev/null differ diff --git a/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-overview/generator.png b/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-overview/generator.png deleted file mode 100644 index 98a27357a..000000000 Binary files a/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-overview/generator.png and /dev/null differ diff --git a/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-overview/index.md b/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-overview/index.md deleted file mode 100644 index 50fdae63a..000000000 --- a/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-overview/index.md +++ /dev/null @@ -1,66 +0,0 @@ ---- -type: docs -title: "Dapr microservices tutorial app overview" -linkTitle: "App overview" -slug: "overview" -description: "Overview of the Dapr microservices tutorial application" -weight: 1000 ---- - -In this tutorial you will be deploying an online store where you can order items: - -A diagram of the Dapr application - -#### (optional) Download the source code - -You can view and download the source code in the [samples repo](https://github.com/project-radius/samples). - -> For access fill out [this form](https://aka.ms/ProjectRadius/GitHubAccess). - -## Containers - -This Radius application will have two [containers]({{< ref appmodel-concept >}}): - -- A frontend UI for users to place orders. Written with .NET Blazor. -- A backend order processing microservice. Written in Node.JS. - -### `frontend` container - -The user-facing UI app (`frontend`) offers a portal for users to place orders. Upon creating an order, `frontend` uses [Dapr service invocation](https://docs.dapr.io/developing-applications/building-blocks/service-invocation/service-invocation-overview/) to send requests to `nodeapp`. - -The `frontend` container is configured with a [Dapr sidecar extension]({{< ref dapr-extension >}}) to add the sidecar container. - -A diagram of the complete application - -### `backend` container - -The order processing microservice (`backend`) accepts HTTP requests to create or display orders. It accepts HTTP requests on two endpoints: `GET /order` and `POST /neworder`. - -The `backend` container is configured with a [Dapr sidecar extension]({{< ref dapr-extension >}}) to add the sidecar container, along with an app ID to so it can be used with service invocation. - -A diagram of the backend order processing service - - -### Dapr service invocation - -In this quickstart we will be using a [Dapr Service Invocation](https://docs.dapr.io/developing-applications/building-blocks/service-invocation/service-invocation-overview/) for communication from `frontend` to `backend`. - -A diagram of the Dapr service invocation - -## Link - -A [Dapr statestore link]({{< ref dapr-secretstore >}}) is used to model and deploy the Dapr statestore component. - -### `statestore` Dapr state store - -The [Dapr state store]({{< ref dapr-statestore >}}) resource (`statestore`) stores information about orders. It could be any compatible [Dapr state store](https://docs.dapr.io/developing-applications/building-blocks/state-management/state-management-overview/). - -The Dapr component configuration is automatically generated for the statestore based on the resource or values provided in the link definition. - -#### Swappable infrastructure - -In this quickstart you will be able to swap between different Dapr components, such as Azure Table Storage and a Redis container. While the backing infrastructure will change, the container definitions and connections will remain the same. This allows you to easily swap between different backing infrastructure without rewriting your service code or definition. - -A diagram of the Dapr state store - -
{{< button text="Next: Deploy the application backend" page="dapr-microservices-initial-deployment.md" >}} diff --git a/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-overview/invoke.png b/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-overview/invoke.png deleted file mode 100644 index 77f2dc728..000000000 Binary files a/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-overview/invoke.png and /dev/null differ diff --git a/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-overview/overview.png b/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-overview/overview.png deleted file mode 100644 index 50658d463..000000000 Binary files a/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-overview/overview.png and /dev/null differ diff --git a/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-overview/radius-overview.png b/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-overview/radius-overview.png deleted file mode 100644 index 78f1a3d9a..000000000 Binary files a/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-overview/radius-overview.png and /dev/null differ diff --git a/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-overview/statestore.png b/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-overview/statestore.png deleted file mode 100644 index f819e9088..000000000 Binary files a/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-overview/statestore.png and /dev/null differ diff --git a/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-overview/store.png b/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-overview/store.png deleted file mode 100644 index a03887f29..000000000 Binary files a/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-overview/store.png and /dev/null differ diff --git a/docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-add-ui/frontend.png b/docs/content/getting-started/quickstarts/quickstart-dapr/frontend.png similarity index 100% rename from docs/content/getting-started/quickstarts/quickstart-dapr/dapr-microservices-add-ui/frontend.png rename to docs/content/getting-started/quickstarts/quickstart-dapr/frontend.png diff --git a/docs/content/getting-started/quickstarts/quickstart-dapr/index.md b/docs/content/getting-started/quickstarts/quickstart-dapr/index.md new file mode 100644 index 000000000..47a0c0d59 --- /dev/null +++ b/docs/content/getting-started/quickstarts/quickstart-dapr/index.md @@ -0,0 +1,125 @@ +--- +type: docs +title: "Quickstart: Dapr Microservices" +linkTitle: "Dapr microservices" +description: "Learn Radius by authoring templates and deploying a Dapr application" +weight: 300 +slug: "dapr" +categories: "Quickstart" +tags : ["Dapr"] +--- + +This quickstart will teach you: + +- How to use Radius to deploy a Dapr microservices sample application for an online shop +- How [Dapr and Radius]({{< ref dapr-resources >}}) seamlessly work together + +For more details on the app and access to the source code, visit the `quickstarts/dapr` directory in the [samples repo](https://github.com/project-radius/samples). _For access to the project-radius GitHub org, please complete and submit [this form](https://aka.ms/ProjectRadius/GitHubAccess)._ + +## Prerequisites + +- [Kubernetes cluster]({{< ref "supported-clusters" >}}) +- [Radius CLI]({{< ref "getting-started" >}}) +- [Radius environment]({{< ref "operations/environments/overview" >}}) +- [Dapr installed on your Kubernetes cluster](https://docs.dapr.io/operations/hosting/kubernetes/kubernetes-deploy/) +- [Visual Studio Code](https://code.visualstudio.com/) (recommended) + - The [Radius VSCode extension]({{< ref "getting-started" >}}) is highly recommended to provide syntax highlighting, completion, and linting + - Although not recommended, you can also complete this quickstart with any basic text editor + +## Step 1: Define the application, `backend` container, and Dapr state store + +Begin by creating a new file named `dapr.bicep` with a Radius application that consists of a `backend` container and Dapr state store with Redis: + +{{< rad file="snippets/dapr.bicep" embed=true marker="//BACKEND" >}} + +## Step 2: Deploy the `backend` application + +1. Deploy the application's `backend` container and Dapr state store: + + ```sh + rad run dapr.bicep + ``` + +1. You can confirm all the resources were deployed by looking for `dapr`, `backend`, and `statestore` resources in the console logs: + ``` + Deployment Complete + + Resources: + dapr Applications.Core/applications + backend Applications.Core/containers + statestore Applications.Link/daprStateStores + ``` + +1. The `rad run` command automatically sets up port forwarding. Visit the the URL [http://localhost:3000/order](http://localhost:3000/order) in your browser. You should see the following message, which confirms the container is able to communicate with the state store: + + ``` + {"message":"no orders yet"} + ``` + +1. Press CTRL+C to terminate the port-forward. + +1. A [local-dev Recipe]({{< ref "author-apps/recipes" >}}) was run during application deployment to automatically create a lightweight Redis container plus a Dapr component configuration. Confirm that the Dapr Redis statestore was successfully created: + + ```sh + dapr components -k -A + ``` + + You should see the following output: + + ``` + NAMESPACE NAME TYPE VERSION SCOPES CREATED AGE + default-dapr statestore state.redis v1 2023-07-21 16:04.27 21m + ``` + +## Step 3: Define the `frontend` container + +Add a `frontend` [container]({{< ref container >}}) which will serve as the application's user interface. + +{{< rad file="snippets/dapr.bicep" embed=true marker="//FRONTEND" >}} + +## Step 4. Deploy and run the `frontend` application + +1. Use Radius to deploy and run the application with a single command: + + ```sh + rad run dapr.bicep + ``` + +1. Your console should output a series deployment logs, which you may check to confirm the `frontend` container was successfully deployed: + + ``` + Deployment Complete + + Resources: + dapr Applications.Core/applications + backend Applications.Core/containers + frontend Applications.Core/containers + statestore Applications.Link/daprStateStores + ``` + +## Step 5. Test your application + +In your browser, navigate to the endpoint (e.g. [http://localhost:8080](http://localhost:8080)) to view and interact with your application: + + Screenshot of frontend application + +## Cleanup + +1. Press CTRL+C to terminate the `rad run` log console + +1. Run `rad app delete` to cleanup your Radius application, containers, and Dapr statestore. The Recipe resources (_Redis container and Dapr component_) are also automatically cleaned up. + + ```bash + rad app delete -a dapr + ``` + +## Next steps + +- If you'd like to try another tutorial with your existing environment, go back to the [Radius quickstarts]({{< ref quickstarts >}}) page. +- Related links for Dapr: + - [Dapr documentation](https://docs.dapr.io/) + - [Dapr quickstarts](https://github.com/dapr/quickstarts/tree/v1.0.0/hello-world) + +
+ +{{< button text="Try another quickstart" page="quickstarts" >}} \ No newline at end of file diff --git a/docs/content/getting-started/quickstarts/quickstart-dapr/snippets/dapr.bicep b/docs/content/getting-started/quickstarts/quickstart-dapr/snippets/dapr.bicep new file mode 100644 index 000000000..0b8f77cda --- /dev/null +++ b/docs/content/getting-started/quickstarts/quickstart-dapr/snippets/dapr.bicep @@ -0,0 +1,83 @@ +//BACKEND +import radius as radius + +@description('Specifies the environment for resources.') +param environment string + +resource app 'Applications.Core/applications@2022-03-15-privatepreview' = { + name: 'dapr' + properties: { + environment: environment + } +} + +// The backend container that is connected to the Dapr state store +resource backend 'Applications.Core/containers@2022-03-15-privatepreview' = { + name: 'backend' + properties: { + application: app.id + container: { + // This image is where the app's backend code lives + image: 'radius.azurecr.io/quickstarts/dapr-backend:edge' + ports: { + orders: { + containerPort: 3000 + } + } + } + connections: { + orders: { + source: stateStore.id + } + } + extensions: [ + { + kind: 'daprSidecar' + appId: 'backend' + appPort: 3000 + } + ] + } +} + +// The Dapr state store that is connected to the backend container +resource stateStore 'Applications.Link/daprStateStores@2022-03-15-privatepreview' = { + name: 'statestore' + properties: { + // Provision Redis Dapr state store automatically via the default Radius Recipe + environment: environment + application: app.id + } +} +//BACKEND + +//FRONTEND +// The frontend container that serves the application UI +resource frontend 'Applications.Core/containers@2022-03-15-privatepreview' = { + name: 'frontend' + properties: { + application: app.id + container: { + // This image is where the app's frontend code lives + image: 'radius.azurecr.io/quickstarts/dapr-frontend:edge' + env: { + // An environment variable to tell the frontend container where to find the backend + CONNECTION_BACKEND_APPID: 'backend' + } + // The frontend container exposes port 8080, which is used to serve the UI + ports: { + ui: { + containerPort: 8080 + } + } + } + // The extension to configure Dapr on the container, which is used to invoke the backend + extensions: [ + { + kind: 'daprSidecar' + appId: 'frontend' + } + ] + } +} +//FRONTEND