Skip to content

Commit 319a46e

Browse files
Merge pull request #266097 from ryanwinterms/main
Refactor Dapr AIO component documentation
2 parents dbf2550 + b809246 commit 319a46e

File tree

4 files changed

+218
-182
lines changed

4 files changed

+218
-182
lines changed
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
---
2+
title: Deploy Dapr pluggable components
3+
titleSuffix: Azure IoT MQ
4+
description: Deploy Dapr and the IoT MQ pluggable components to a cluster.
5+
author: timlt
6+
ms.author: timlt
7+
ms.subservice: mq
8+
ms.topic: how-to
9+
ms.custom:
10+
ms.date: 1/31/2024
11+
---
12+
13+
# Deploy Dapr pluggable components
14+
15+
[!INCLUDE [public-preview-note](../includes/public-preview-note.md)]
16+
17+
The Distributed Application Runtime (Dapr) is a portable, serverless, event-driven runtime that simplifies the process of building distributed applications. Dapr lets you build stateful or stateless apps without worrying about how the building blocks function. Dapr provides several [building blocks](https://docs.dapr.io/developing-applications/building-blocks/): pub/sub, state management, service invocation, actors, and more.
18+
19+
Azure IoT MQ Preview supports two of these building blocks, powered by [Azure IoT MQ MQTT broker](../manage-mqtt-connectivity/overview-iot-mq.md):
20+
21+
- Publish and subscribe
22+
- State management
23+
24+
To use the IoT MQ Dapr pluggable components, define the component spec for each of the APIs and then [register this to the cluster](https://docs.dapr.io/operations/components/pluggable-components-registration/). The Dapr components listen to a Unix domain socket placed on the shared volume. The Dapr runtime connects with each socket and discovers all services from a given building block API that the component implements.
25+
26+
## Install Dapr runtime
27+
28+
To install the Dapr runtime, use the following Helm command:
29+
30+
> [!NOTE]
31+
> If you completed the provided Azure IoT Operations Preview [quickstart](../get-started/quickstart-deploy.md), you already installed the Dapr runtime and the following steps are not required.
32+
33+
```bash
34+
helm repo add dapr https://dapr.github.io/helm-charts/
35+
helm repo update
36+
helm upgrade --install dapr dapr/dapr --version=1.11 --namespace dapr-system --create-namespace --wait
37+
```
38+
39+
> [!IMPORTANT]
40+
> **Dapr v1.12** is currently not supported.
41+
42+
## Register MQ pluggable components
43+
44+
To register MQ's pluggable pub/sub and state management components, create the component manifest yaml, and apply it to your cluster.
45+
46+
To create the yaml file, use the following component definitions:
47+
48+
> [!div class="mx-tdBreakAll"]
49+
> | Component | Description |
50+
> |-|-|
51+
> | `metadata.name` | The component name is important and is how a Dapr application references the component. |
52+
> | `spec.type` | [The type of the component](https://docs.dapr.io/operations/components/pluggable-components-registration/#define-the-component), which must be declared exactly as shown. It tells Dapr what kind of component (`pubsub` or `state`) it is and which Unix socket to use. |
53+
> | `spec.metadata.url` | The URL tells the component where the local MQ endpoint is. Defaults to `8883` is MQ's default MQTT port with TLS enabled. |
54+
> | `spec.metadata.satTokenPath` | The Service Account Token is used to authenticate the Dapr components with the MQTT broker |
55+
> | `spec.metadata.tlsEnabled` | Define if TLS is used by the MQTT broker. Defaults to `true` |
56+
> | `spec.metadata.caCertPath` | The certificate chain path for validating the broker, required if `tlsEnabled` is `true` |
57+
> | `spec.metadata.logLevel` | The logging level of the component. 'Debug', 'Info', 'Warn' and 'Error' |
58+
59+
1. Save the following yaml, which contains the component definitions, to a file named `components.yaml`:
60+
61+
```yml
62+
# Pub/sub component
63+
apiVersion: dapr.io/v1alpha1
64+
kind: Component
65+
metadata:
66+
name: aio-mq-pubsub
67+
namespace: azure-iot-operations
68+
spec:
69+
type: pubsub.aio-mq-pubsub-pluggable # DO NOT CHANGE
70+
version: v1
71+
metadata:
72+
- name: url
73+
value: "aio-mq-dmqtt-frontend:8883"
74+
- name: satTokenPath
75+
value: "/var/run/secrets/tokens/mqtt-client-token"
76+
- name: tlsEnabled
77+
value: true
78+
- name: caCertPath
79+
value: "/var/run/certs/aio-mq-ca-cert/ca.crt"
80+
- name: logLevel
81+
value: "Info"
82+
---
83+
# State Management component
84+
apiVersion: dapr.io/v1alpha1
85+
kind: Component
86+
metadata:
87+
name: aio-mq-statestore
88+
namespace: azure-iot-operations
89+
spec:
90+
type: state.aio-mq-statestore-pluggable # DO NOT CHANGE
91+
version: v1
92+
metadata:
93+
- name: url
94+
value: "aio-mq-dmqtt-frontend:8883"
95+
- name: satTokenPath
96+
value: "/var/run/secrets/tokens/mqtt-client-token"
97+
- name: tlsEnabled
98+
value: true
99+
- name: caCertPath
100+
value: "/var/run/certs/aio-mq-ca-cert/ca.crt"
101+
- name: logLevel
102+
value: "Info"
103+
```
104+
105+
1. Apply the component yaml to your cluster by running the following command:
106+
107+
```bash
108+
kubectl apply -f components.yaml
109+
```
110+
111+
Verify the following output:
112+
113+
```output
114+
component.dapr.io/aio-mq-pubsub created
115+
component.dapr.io/aio-mq-statestore created
116+
```
117+
118+
## Create authorization policy for IoT MQ
119+
120+
To configure authorization policies to Azure IoT MQ, first you create a [BrokerAuthorization](../manage-mqtt-connectivity/howto-configure-authorization.md) resource.
121+
122+
> [!NOTE]
123+
> If Broker Authorization is not enabled on this cluster, you can skip this section as the applications will have access to all MQTT topics, including those needed to access the IoT MQ State Store.
124+
125+
1. Save the following yaml, which contains a BrokerAuthorization definition, to a file named `aio-dapr-authz.yaml`:
126+
127+
```yml
128+
apiVersion: mq.iotoperations.azure.com/v1beta1
129+
kind: BrokerAuthorization
130+
metadata:
131+
name: my-dapr-authz-policies
132+
namespace: azure-iot-operations
133+
spec:
134+
listenerRef:
135+
- my-listener # change to match your listener name as needed
136+
authorizationPolicies:
137+
enableCache: false
138+
rules:
139+
- principals:
140+
attributes:
141+
- group: dapr-workload # match to the attribute annotated to the service account
142+
brokerResources:
143+
- method: Connect
144+
- method: Publish
145+
topics:
146+
- "$services/statestore/#"
147+
- method: Subscribe
148+
topics:
149+
- "clients/{principal.clientId}/services/statestore/#"
150+
```
151+
152+
1. Apply the BrokerAuthorizaion definition to the cluster:
153+
154+
```bash
155+
kubectl apply -f aio-dapr-authz.yaml
156+
```
157+
158+
## Next steps
159+
160+
Now that you have deployed the Dapr components, you can [Use Dapr to develop distributed applications](howto-develop-dapr-apps.md).

articles/iot-operations/develop/howto-develop-dapr-apps.md

Lines changed: 23 additions & 158 deletions
Original file line numberDiff line numberDiff line change
@@ -10,162 +10,19 @@ ms.custom:
1010
- ignite-2023
1111
ms.date: 11/14/2023
1212

13-
# CustomerIntent: As an developer, I want to understand how to use Dapr to develop distributed apps that talk with Azure IoT MQ.
13+
# CustomerIntent: As a developer, I want to understand how to use Dapr to develop distributed apps that talk with Azure IoT MQ.
1414
---
1515

1616
# Use Dapr to develop distributed application workloads
1717

1818
[!INCLUDE [public-preview-note](../includes/public-preview-note.md)]
1919

20-
The Distributed Application Runtime (Dapr) is a portable, serverless, event-driven runtime that simplifies the process of building distributed application. Dapr enables developers to build stateful or stateless apps without worrying about how the building blocks function. Dapr provides several [building blocks](https://docs.dapr.io/developing-applications/building-blocks/): state management, service invocation, actors, pub/sub, and more. Azure IoT MQ Preview supports two of these building blocks:
20+
To use the IoT MQ Dapr pluggable components, deploy both the pub/sub and state store components in your application deployment along with your Dapr application. This guide shows you how to deploy an application using the Dapr SDK and IoT MQ pluggable components.
2121

22-
- Publish and Subscribe, powered by [Azure IoT MQ MQTT broker](../manage-mqtt-connectivity/overview-iot-mq.md)
23-
- State Management
22+
## Prerequisites
2423

25-
To use Dapr pluggable components, define all the components, then add pluggable component containers to your [deployments](https://docs.dapr.io/operations/components/pluggable-components-registration/). The Dapr component listens to a Unix Domain Socket placed on the shared volume, and Dapr runtime connects with each socket and discovers all services from a given building block API that the component implements. Each deployment must have its own pluggable component defined. This guide shows you how to deploy an application using the Dapr SDK and IoT MQ pluggable components.
26-
27-
## Install Dapr runtime
28-
29-
To install the Dapr runtime, use the following Helm command. If you completed the provided Azure IoT Operations Preview [quickstart](../get-started/quickstart-deploy.md), you already installed the runtime.
30-
31-
```bash
32-
helm repo add dapr https://dapr.github.io/helm-charts/
33-
helm repo update
34-
helm upgrade --install dapr dapr/dapr --version=1.11 --namespace dapr-system --create-namespace --wait
35-
```
36-
37-
> [!IMPORTANT]
38-
> **Dapr v1.12** is currently not supported.
39-
40-
## Register MQ's pluggable components
41-
42-
To register MQ's pluggable Pub/sub and State Management components, create the component manifest yaml, and apply it to your cluster.
43-
44-
To create the yaml file, use the following component definitions:
45-
46-
> [!div class="mx-tdBreakAll"]
47-
> | Component | Description |
48-
> |-|-|
49-
> | `metadata.name` | The component name is important and is how a Dapr application references the component. |
50-
> | `spec.type` | [The type of the component](https://docs.dapr.io/operations/components/pluggable-components-registration/#define-the-component), which must be declared exactly as shown. It tells Dapr what kind of component (`pubsub` or `state`) it is and which Unix socket to use. |
51-
> | `spec.metadata.url` | The URL tells the component where the local MQ endpoint is. Defaults to `8883` is MQ's default MQTT port with TLS enabled. |
52-
> | `spec.metadata.satTokenPath` | The Service Account Token is used to authenticate the Dapr components with the MQTT broker |
53-
> | `spec.metadata.tlsEnabled` | Define if TLS is used by the MQTT broker. Defaults to `true` |
54-
> | `spec.metadata.caCertPath` | The certificate chain path for validating the broker, required if `tlsEnabled` is `true` |
55-
> | `spec.metadata.logLevel` | The logging level of the component. 'Debug', 'Info', 'Warn' and 'Error' |
56-
57-
1. Save the following yaml, which contains the component definitions, to a file named `components.yaml`:
58-
59-
```yml
60-
# Pub/sub component
61-
apiVersion: dapr.io/v1alpha1
62-
kind: Component
63-
metadata:
64-
name: aio-mq-pubsub
65-
namespace: azure-iot-operations
66-
spec:
67-
type: pubsub.aio-mq-pubsub-pluggable # DO NOT CHANGE
68-
version: v1
69-
metadata:
70-
- name: url
71-
value: "aio-mq-dmqtt-frontend:8883"
72-
- name: satTokenPath
73-
value: "/var/run/secrets/tokens/mqtt-client-token"
74-
- name: tlsEnabled
75-
value: true
76-
- name: caCertPath
77-
value: "/var/run/certs/aio-mq-ca-cert/ca.crt"
78-
- name: logLevel
79-
value: "Info"
80-
---
81-
# State Management component
82-
apiVersion: dapr.io/v1alpha1
83-
kind: Component
84-
metadata:
85-
name: aio-mq-statestore
86-
namespace: azure-iot-operations
87-
spec:
88-
type: state.aio-mq-statestore-pluggable # DO NOT CHANGE
89-
version: v1
90-
metadata:
91-
- name: url
92-
value: "aio-mq-dmqtt-frontend:8883"
93-
- name: satTokenPath
94-
value: "/var/run/secrets/tokens/mqtt-client-token"
95-
- name: tlsEnabled
96-
value: true
97-
- name: caCertPath
98-
value: "/var/run/certs/aio-mq-ca-cert/ca.crt"
99-
- name: logLevel
100-
value: "Info"
101-
```
102-
103-
1. Apply the component yaml to your cluster by running the following command:
104-
105-
```bash
106-
kubectl apply -f components.yaml
107-
```
108-
109-
Verify the following output:
110-
111-
```output
112-
component.dapr.io/aio-mq-pubsub created
113-
component.dapr.io/aio-mq-statestore created
114-
```
115-
116-
## Set up authorization policy between the application and MQ
117-
118-
To configure authorization policies to Azure IoT MQ, first you create a [BrokerAuthorization resource](../manage-mqtt-connectivity/howto-configure-authorization.md).
119-
120-
> [!NOTE]
121-
> If Broker Authorization is not enabled on this cluster, you can skip this section as the applications will have access to all MQTT topics.
122-
123-
1. Annotate the service account `mqtt-client` with an [authorization attribute](../manage-mqtt-connectivity/howto-configure-authentication.md#create-a-service-account):
124-
125-
```bash
126-
kubectl annotate serviceaccount mqtt-client aio-mq-broker-auth/group=dapr-workload -n azure-iot-operations
127-
```
128-
129-
1. Save the following yaml, which contains the BrokerAuthorization definition, to a file named `aio-mq-authz.yaml`.
130-
131-
Use the following definitions:
132-
133-
> [!div class="mx-tdBreakAll"]
134-
> | Item | Description |
135-
> |-|-|
136-
> | `dapr-workload` | The Dapr application authorization attribute assigned to the service account |
137-
> | `topics` | Describe the topics required to communicate with the MQ State Store |
138-
139-
```yml
140-
apiVersion: mq.iotoperations.azure.com/v1beta1
141-
kind: BrokerAuthorization
142-
metadata:
143-
name: my-authz-policies
144-
namespace: azure-iot-operations
145-
spec:
146-
listenerRef:
147-
- my-listener # change to match your listener name as needed
148-
authorizationPolicies:
149-
enableCache: false
150-
rules:
151-
- principals:
152-
attributes:
153-
- group: dapr-workload
154-
brokerResources:
155-
- method: Connect
156-
- method: Publish
157-
topics:
158-
- "$services/statestore/#"
159-
- method: Subscribe
160-
topics:
161-
- "clients/{principal.clientId}/services/statestore/#"
162-
```
163-
164-
1. Apply the BrokerAuthorizaion definition to the cluster:
165-
166-
```bash
167-
kubectl apply -f aio-mq-authz.yaml
168-
```
24+
* Azure IoT Operations deployed - [Deploy Azure IoT Operations](../get-started/quickstart-deploy.md)
25+
* IoT MQ Dapr Components deployed - [Deploy IoT MQ Dapr Components](./howto-deploy-dapr.md)
16926

17027
## Creating a Dapr application
17128

@@ -194,11 +51,9 @@ After you finish writing the Dapr application, build the container:
19451

19552
## Deploy a Dapr application
19653

197-
To deploy the Dapr application to your cluster, you can use either a Kubernetes [Pod](https://kubernetes.io/docs/concepts/workloads/pods/) or [Deployment](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/)
54+
The following [Deployment](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/) definition defines the different volumes required to deploy the application along with the required containers.
19855

199-
The following Pod definition defines the different volumes required to deploy the application along with the required containers.
200-
201-
To start, you create a yaml file that uses the following definitions:
56+
To start, create a yaml file with the following definitions:
20257

20358
> | Component | Description |
20459
> |-|-|
@@ -210,6 +65,14 @@ To start, you create a yaml file that uses the following definitions:
21065
1. Save the following yaml to a file named `dapr-app.yaml`:
21166

21267
```yml
68+
apiVersion: v1
69+
kind: ServiceAccount
70+
metadata:
71+
name: dapr-client
72+
namespace: azure-iot-operations
73+
annotations:
74+
aio-mq-broker-auth/group: dapr-workload
75+
---
21376
apiVersion: apps/v1
21477
kind: Deployment
21578
metadata:
@@ -231,6 +94,8 @@ To start, you create a yaml file that uses the following definitions:
23194
dapr.io/app-port: "6001"
23295
dapr.io/app-protocol: "grpc"
23396
spec:
97+
serviceAccountName: dapr-client
98+
23499
volumes:
235100
- name: dapr-unix-domain-socket
236101
emptyDir: {}
@@ -250,11 +115,11 @@ To start, you create a yaml file that uses the following definitions:
250115
name: aio-ca-trust-bundle-test-only
251116
252117
containers:
253-
# Container for the dapr quickstart application
118+
# Container for the Dapr application
254119
- name: mq-dapr-app
255-
image: <YOUR DAPR APPLICATION>
120+
image: <YOUR_DAPR_APPLICATION>
256121
257-
# Container for the Pub/sub component
122+
# Container for the Dapr Pub/sub component
258123
- name: aio-mq-pubsub-pluggable
259124
image: ghcr.io/azure/iot-mq-dapr-components/pubsub:latest
260125
volumeMounts:
@@ -265,7 +130,7 @@ To start, you create a yaml file that uses the following definitions:
265130
- name: aio-ca-trust-bundle
266131
mountPath: /var/run/certs/aio-mq-ca-cert/
267132
268-
# Container for the State Management component
133+
# Container for the Dapr State store component
269134
- name: aio-mq-statestore-pluggable
270135
image: ghcr.io/azure/iot-mq-dapr-components/statestore:latest
271136
volumeMounts:
@@ -303,6 +168,6 @@ Run the following command to view the logs:
303168
kubectl logs dapr-workload daprd
304169
```
305170
306-
## Related content
171+
## Next steps
307172
308-
- [Develop highly available applications](concept-about-distributed-apps.md)
173+
Now that you know how to develop a Dapr application, you can run through the tutorial to [Build an event-driven app with Dapr](tutorial-event-driven-with-dapr.md).

0 commit comments

Comments
 (0)