Skip to content

Commit 9e4f713

Browse files
Merge pull request #229365 from hhunter-ms/hh-65635
[Dapr/AKS] Dapr Workflow using the extension
2 parents a057fc3 + e5b9f0a commit 9e4f713

File tree

3 files changed

+226
-12
lines changed

3 files changed

+226
-12
lines changed

articles/aks/TOC.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,8 @@
544544
href: dapr-settings.md
545545
- name: Migrate from Dapr OSS to the Dapr extension
546546
href: dapr-migration.md
547+
- name: Deploy and run workflows with the Dapr extension
548+
href: dapr-workflow.md
547549
- name: Troubleshoot the Dapr extension
548550
href: dapr-troubleshooting.md
549551
- name: Use GitOps

articles/aks/dapr-workflow.md

Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
---
2+
title: Deploy and run workflows with the Dapr extension for Azure Kubernetes Service (AKS)
3+
description: Learn how to deploy and run Dapr Workflow on your Azure Kubernetes Service (AKS) clusters via the Dapr extension.
4+
author: hhunter-ms
5+
ms.author: hannahhunter
6+
ms.reviewer: nuversky
7+
ms.service: azure-kubernetes-service
8+
ms.topic: article
9+
ms.date: 04/05/2023
10+
ms.custom: devx-track-azurecli
11+
---
12+
13+
# Deploy and run workflows with the Dapr extension for Azure Kubernetes Service (AKS)
14+
15+
With Dapr Workflow, you can easily orchestrate messaging, state management, and failure-handling logic across various microservices. Dapr Workflow can help you create long-running, fault-tolerant, and stateful applications.
16+
17+
In this guide, you use the [provided order processing workflow example][dapr-workflow-sample] to:
18+
19+
> [!div class="checklist"]
20+
> - Create an Azure Container Registry and an AKS cluster for this sample.
21+
> - Install the Dapr extension on your AKS cluster.
22+
> - Deploy the sample application to AKS.
23+
> - Start and query workflow instances using HTTP API calls.
24+
25+
The workflow example is an ASP.NET Core project with:
26+
- A [`Program.cs` file][dapr-program] that contains the setup of the app, including the registration of the workflow and workflow activities.
27+
- Workflow definitions found in the [`Workflows` directory][dapr-workflow-dir].
28+
- Workflow activity definitions found in the [`Activities` directory][dapr-activities-dir].
29+
30+
> [!NOTE]
31+
> Dapr Workflow is currently an [alpha][dapr-workflow-alpha] feature and is on a self-service, opt-in basis. Alpha Dapr APIs and components are provided "as is" and "as available," and are continually evolving as they move toward stable status. Alpha APIs and components are not covered by customer support.
32+
33+
## Prerequisites
34+
35+
- An [Azure subscription](https://azure.microsoft.com/free/?WT.mc_id=A261C142F) with Owner or Admin role.
36+
- The latest version of the [Azure CLI][install-cli]
37+
- Latest [Docker][docker]
38+
- Latest [Helm][helm]
39+
40+
## Set up the environment
41+
42+
### Clone the sample project
43+
44+
Clone the example workflow application.
45+
46+
```sh
47+
git clone https://github.com/Azure/dapr-workflows-aks-sample.git
48+
```
49+
50+
Navigate to the sample's root directory.
51+
52+
```sh
53+
cd dapr-workflows-aks-sample
54+
```
55+
56+
### Create a Kubernetes cluster
57+
58+
Create a resource group to hold the AKS cluster.
59+
60+
```sh
61+
az group create --name myResourceGroup --location eastus
62+
```
63+
64+
Create an AKS cluster.
65+
66+
```sh
67+
az aks create --resource-group myResourceGroup --name myAKSCluster --node-count 2 --generate-ssh-keys
68+
```
69+
70+
[Make sure `kubectl` is installed and pointed to your AKS cluster.][kubectl] If you use [the Azure Cloud Shell][az-cloud-shell], `kubectl` is already installed.
71+
72+
For more information, see the [Deploy an AKS cluster][cluster] tutorial.
73+
74+
## Deploy the application to AKS
75+
76+
### Install Dapr on your AKS cluster
77+
78+
Install the Dapr extension on your AKS cluster. Before you start, make sure you've:
79+
- [Installed or updated the `k8s-extension`][k8s-ext].
80+
- [Registered the `Microsoft.KubernetesConfiguration` service provider][k8s-sp]
81+
82+
```sh
83+
az k8s-extension create --cluster-type managedClusters --cluster-name myAKSCluster --resource-group myResourceGroup --name dapr --extension-type Microsoft.Dapr
84+
```
85+
86+
Verify Dapr has been installed by running the following command:
87+
88+
```sh
89+
kubectl get pods -A
90+
```
91+
92+
### Deploy the Redis Actor state store component
93+
94+
Navigate to the `Deploy` directory in your forked version of the sample:
95+
96+
```sh
97+
cd Deploy
98+
```
99+
100+
Deploy the Redis component:
101+
102+
```sh
103+
helm repo add bitnami https://charts.bitnami.com/bitnami
104+
helm install redis bitnami/redis
105+
kubectl apply -f redis.yaml
106+
```
107+
108+
### Run the application
109+
110+
Once you've deployed Redis, deploy the application to AKS:
111+
112+
```sh
113+
kubectl apply -f deployment.yaml
114+
```
115+
116+
Expose the Dapr sidecar and the sample app:
117+
118+
```sh
119+
kubectl apply -f service.yaml
120+
export APP_URL=$(kubectl get svc/workflows-sample -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
121+
export DAPR_URL=$(kubectl get svc/workflows-sample-dapr -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
122+
```
123+
124+
Verify that the above commands were exported:
125+
126+
```sh
127+
echo $APP_URL
128+
echo $DAPR_URL
129+
```
130+
131+
## Start the workflow
132+
133+
Now that the application and Dapr have been deployed to the AKS cluster, you can now start and query workflow instances. Begin by making an API call to the sample app to restock items in the inventory:
134+
135+
```sh
136+
curl -X GET $APP_URL/stock/restock
137+
```
138+
139+
Start the workflow:
140+
141+
```sh
142+
curl -X POST $DAPR_URL/v1.0-alpha1/workflows/dapr/OrderProcessingWorkflow/1234/start \
143+
-H "Content-Type: application/json" \
144+
-d '{ "input" : {"Name": "Paperclips", "TotalCost": 99.95, "Quantity": 1}}'
145+
```
146+
147+
Expected output:
148+
149+
```json
150+
{"instance_id":"1234"}
151+
```
152+
153+
Check the workflow status:
154+
155+
```sh
156+
curl -X GET $DAPR_URL/v1.0-alpha1/workflows/dapr/OrderProcessingWorkflow/1234
157+
```
158+
159+
Expected output:
160+
161+
```json
162+
{
163+
"WFInfo":
164+
{
165+
"instance_id":"1234"
166+
},
167+
"start_time":"2023-03-03T19:19:16Z",
168+
"metadata":
169+
{
170+
"dapr.workflow.custom_status":"",
171+
"dapr.workflow.input":"{\"Name\":\"Paperclips\",\"Quantity\":1,\"TotalCost\":99.95}",
172+
"dapr.workflow.last_updated":"2023-03-03T19:19:33Z",
173+
"dapr.workflow.name":"OrderProcessingWorkflow",
174+
"dapr.workflow.output":"{\"Processed\":true}",
175+
"dapr.workflow.runtime_status":"COMPLETED"
176+
}
177+
}
178+
```
179+
180+
Notice that the workflow status is marked as completed.
181+
182+
## Next steps
183+
184+
[Learn how to add configuration settings to the Dapr extension on your AKS cluster][dapr-config].
185+
186+
<!-- Links Internal -->
187+
[deploy-cluster]: ./tutorial-kubernetes-deploy-cluster.md
188+
[install-cli]: /cli/azure/install-azure-cli
189+
[k8s-ext]: ./dapr.md#set-up-the-azure-cli-extension-for-cluster-extensions
190+
[cluster]: ./tutorial-kubernetes-deploy-cluster.md
191+
[k8s-sp]: ./dapr.md#register-the-kubernetesconfiguration-service-provider
192+
[dapr-config]: ./dapr-settings.md
193+
[az-cloud-shell]: ./learn/quick-kubernetes-deploy-powershell.md#azure-cloud-shell
194+
[kubectl]: ./tutorial-kubernetes-deploy-cluster.md#connect-to-cluster-using-kubectl
195+
196+
<!-- Links External -->
197+
[dapr-workflow-sample]: https://github.com/Azure/dapr-workflows-aks-sample
198+
[dapr-program]: https://github.com/Azure/dapr-workflows-aks-sample/blob/main/Program.cs
199+
[dapr-workflow-dir]: https://github.com/Azure/dapr-workflows-aks-sample/tree/main/Workflows
200+
[dapr-activities-dir]: https://github.com/Azure/dapr-workflows-aks-sample/tree/main/Activities
201+
[dapr-workflow-alpha]: https://docs.dapr.io/operations/support/support-preview-features/#current-preview-features
202+
[deployment-yaml]: https://github.com/Azure/dapr-workflows-aks-sample/blob/main/Deploy/deployment.yaml
203+
[docker]: https://docs.docker.com/get-docker/
204+
[helm]: https://helm.sh/docs/intro/install/

articles/aks/dapr.md

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,36 @@ author: greenie-msft
55
ms.author: nigreenf
66
ms.service: azure-kubernetes-service
77
ms.topic: article
8-
ms.date: 01/06/2023
8+
ms.date: 03/06/2023
99
ms.custom: devx-track-azurecli, ignite-fall-2021, event-tier1-build-2022, references_regions
1010
---
1111

1212
# Dapr extension for Azure Kubernetes Service (AKS) and Arc-enabled Kubernetes
1313

14-
[Dapr](https://dapr.io/) is a portable, event-driven runtime that simplifies building resilient, stateless, and stateful applications that run on the cloud and edge and embrace the diversity of languages and developer frameworks. Applying the benefits of a sidecar architecture, Dapr helps you tackle the challenges that come with building microservices and keeps your code platform agnostic. In particular, it helps solve problems around services:
14+
As a portable, event-driven runtime, [Dapr](https://dapr.io/) simplifies building resilient, stateless, and stateful applications that run on the cloud and edge and embrace the diversity of languages and developer frameworks. With its sidecar architecture, Dapr helps you tackle the challenges that come with building microservices and keeps your code platform agnostic. In particular, it helps solve problems around services:
1515
- Calling other services reliably and securely
1616
- Building event-driven apps with pub-sub
1717
- Building applications that are portable across multiple cloud services and hosts (for example, Kubernetes vs. a VM)
1818

19-
[By using the Dapr extension to provision Dapr on your AKS or Arc-enabled Kubernetes cluster](../azure-arc/kubernetes/conceptual-extensions.md), you eliminate the overhead of downloading Dapr tooling and manually installing and managing the runtime on your AKS cluster. Additionally, the extension offers support for all [native Dapr configuration capabilities][dapr-configuration-options] through simple command-line arguments.
19+
[Using the Dapr extension to provision Dapr on your AKS or Arc-enabled Kubernetes cluster](../azure-arc/kubernetes/conceptual-extensions.md) eliminates the overhead of:
20+
- Downloading Dapr tooling
21+
- Manually installing and managing the runtime on your AKS cluster
22+
23+
Additionally, the extension offers support for all [native Dapr configuration capabilities][dapr-configuration-options] through simple command-line arguments.
2024

2125
> [!NOTE]
2226
> If you plan on installing Dapr in a Kubernetes production environment, see the [Dapr guidelines for production usage][kubernetes-production] documentation page.
2327
2428
## How it works
2529

26-
The Dapr extension uses the Azure CLI to provision the Dapr control plane on your AKS or Arc-enabled Kubernetes cluster. This will create:
30+
The Dapr extension uses the Azure CLI to provision the Dapr control plane on your AKS or Arc-enabled Kubernetes cluster, creating the following Dapr services:
2731

28-
- **dapr-operator**: Manages component updates and Kubernetes services endpoints for Dapr (state stores, pub/subs, etc.)
29-
- **dapr-sidecar-injector**: Injects Dapr into annotated deployment pods and adds the environment variables `DAPR_HTTP_PORT` and `DAPR_GRPC_PORT` to enable user-defined applications to easily communicate with Dapr without hard-coding Dapr port values.
30-
- **dapr-placement**: Used for actors only. Creates mapping tables that map actor instances to pods
31-
- **dapr-sentry**: Manages mTLS between services and acts as a certificate authority. For more information, read the [security overview][dapr-security].
32+
| Dapr service | Description |
33+
| ------------ | ----------- |
34+
| `dapr-operator` | Manages component updates and Kubernetes services endpoints for Dapr (state stores, pub/subs, etc.) |
35+
| `dapr-sidecar-injector` | Injects Dapr into annotated deployment pods and adds the environment variables `DAPR_HTTP_PORT` and `DAPR_GRPC_PORT` to enable user-defined applications to easily communicate with Dapr without hard-coding Dapr port values. |
36+
| `dapr-placement` | Used for actors only. Creates mapping tables that map actor instances to pods. |
37+
| `dapr-sentry` | Manages mTLS between services and acts as a certificate authority. For more information, read the [security overview][dapr-security]. |
3238

3339
Once Dapr is installed on your cluster, you can begin to develop using the Dapr building block APIs by [adding a few annotations][dapr-deployment-annotations] to your deployments. For a more in-depth overview of the building block APIs and how to best use them, see the [Dapr building blocks overview][building-blocks-concepts].
3440

@@ -107,7 +113,7 @@ Global Azure cloud is supported with Arc support on the following regions:
107113

108114
### Set up the Azure CLI extension for cluster extensions
109115

110-
You'll need the `k8s-extension` Azure CLI extension. Install by running the following commands:
116+
Install the `k8s-extension` Azure CLI extension by running the following commands:
111117

112118
```azurecli-interactive
113119
az extension add --name k8s-extension
@@ -121,7 +127,7 @@ az extension update --name k8s-extension
121127

122128
### Register the `KubernetesConfiguration` service provider
123129

124-
If you have not previously used cluster extensions, you may need to register the service provider with your subscription. You can check the status of the provider registration using the [az provider list][az-provider-list] command, as shown in the following example:
130+
If you haven't previously used cluster extensions, you may need to register the service provider with your subscription. You can check the status of the provider registration using the [az provider list][az-provider-list] command, as shown in the following example:
125131

126132
```azurecli-interactive
127133
az provider list --query "[?contains(namespace,'Microsoft.KubernetesConfiguration')]" -o table
@@ -185,7 +191,7 @@ For example:
185191
> [!NOTE]
186192
> Dapr is supported with a rolling window, including only the current and previous versions. It is your operational responsibility to remain up to date with these supported versions. If you have an older version of Dapr, you may have to do intermediate upgrades to get to a supported version.
187193
188-
The same command-line argument is used for installing a specific version of Dapr or rolling back to a previous version. Set `--auto-upgrade-minor-version` to `false` and `--version` to the version of Dapr you wish to install. If the `version` parameter is omitted, the extension will install the latest version of Dapr. For example, to use Dapr X.X.X:
194+
The same command-line argument is used for installing a specific version of Dapr or rolling back to a previous version. Set `--auto-upgrade-minor-version` to `false` and `--version` to the version of Dapr you wish to install. If the `version` parameter is omitted, the extension installs the latest version of Dapr. For example, to use Dapr X.X.X:
189195

190196
```azurecli
191197
az k8s-extension create --cluster-type managedClusters \
@@ -215,8 +221,9 @@ az k8s-extension delete --resource-group myResourceGroup --cluster-name myAKSClu
215221

216222
## Next Steps
217223

218-
- Learn more about [additional settings and preferences you can set on the Dapr extension][dapr-settings].
224+
- Learn more about [extra settings and preferences you can set on the Dapr extension][dapr-settings].
219225
- Once you have successfully provisioned Dapr in your AKS cluster, try deploying a [sample application][sample-application].
226+
- Try out [Dapr Workflow on your Dapr extension for AKS][dapr-workflow]
220227

221228
<!-- LINKS INTERNAL -->
222229
[deploy-cluster]: ./tutorial-kubernetes-deploy-cluster.md
@@ -230,6 +237,7 @@ az k8s-extension delete --resource-group myResourceGroup --cluster-name myAKSClu
230237
[install-cli]: /cli/azure/install-azure-cli
231238
[dapr-migration]: ./dapr-migration.md
232239
[dapr-settings]: ./dapr-settings.md
240+
[dapr-workflow]: ./dapr-workflow.md
233241

234242
<!-- LINKS EXTERNAL -->
235243
[kubernetes-production]: https://docs.dapr.io/operations/hosting/kubernetes/kubernetes-production

0 commit comments

Comments
 (0)