Skip to content

Commit 7f1ccf0

Browse files
Merge pull request #260661 from hhunter-ms/hh-190024
[Dapr/ACA] Dapr integration/overview doc rehaul
2 parents 49dba9f + 5d9bbc2 commit 7f1ccf0

11 files changed

+411
-350
lines changed

articles/container-apps/TOC.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,16 @@
213213
items:
214214
- name: Overview
215215
href: dapr-overview.md
216-
- name: Connect to Azure services via Dapr components
217-
href: dapr-component-connection.md
216+
- name: Get started
217+
items:
218+
- name: Connect to Azure services via Dapr components
219+
href: dapr-component-connection.md
220+
- name: Enable Dapr
221+
href: enable-dapr.md
218222
- name: Configure
219223
items:
224+
- name: Dapr components
225+
href: dapr-components.md
220226
- name: Dapr component resiliency (preview)
221227
href: dapr-component-resiliency.md
222228
- name: Scale Dapr apps with KEDA using Bicep

articles/container-apps/dapr-component-connection.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ms.author: hannahhunter
66
ms.reviewer: nickgreenf
77
ms.service: container-apps
88
ms.topic: how-to
9-
ms.date: 07/06/2023
9+
ms.date: 12/20/2023
1010
ms.custom: template-tutorial, service-connector, build-2023, engagement
1111
---
1212

@@ -99,9 +99,11 @@ You can then check the YAML/Bicep artifact into a repo and recreate it outside o
9999

100100
:::image type="content" source="media/dapr-component-connection/manage-dapr-component.png" alt-text="Screenshot of the Azure platform showing existing Dapr Components.":::
101101

102+
## Next steps
102103

104+
[Enable Dapr on your container apps.](./enable-dapr.md)
103105

104-
## Next steps
106+
## Related links
105107

106108
Learn more about:
107109
- [Using Dapr with Azure Container Apps](./dapr-overview.md)
Lines changed: 262 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,262 @@
1+
---
2+
title: Dapr components in Azure Container Apps
3+
description: Learn more about how Dapr components work on your Azure Container App service to develop applications.
4+
ms.author: hannahhunter
5+
author: hhunter-ms
6+
ms.service: container-apps
7+
ms.custom: event-tier1-build-2022, ignite-2022, build-2023
8+
ms.topic: conceptual
9+
ms.date: 12/18/2023
10+
---
11+
12+
# Dapr components in Azure Container Apps
13+
14+
Dapr uses a modular design where functionality is delivered as a [component][dapr-component]. The use of Dapr components is optional and dictated exclusively by the needs of your application.
15+
16+
Dapr components in container apps are environment-level resources that:
17+
18+
- Can provide a pluggable abstraction model for connecting to supporting external services.
19+
- Can be shared across container apps or scoped to specific container apps.
20+
- Can use Dapr secrets to securely retrieve configuration metadata.
21+
22+
In this guide, you learn how to configure Dapr components for your Azure Container Apps services.
23+
24+
## Component schema
25+
26+
In the Dapr open-source project, all components conform to the following basic [schema][dapr-component-spec].
27+
28+
```yaml
29+
apiVersion: dapr.io/v1alpha1
30+
kind: Component
31+
metadata:
32+
name: [COMPONENT-NAME]
33+
namespace: [COMPONENT-NAMESPACE]
34+
spec:
35+
type: [COMPONENT-TYPE]
36+
version: v1
37+
initTimeout: [TIMEOUT-DURATION]
38+
ignoreErrors: [BOOLEAN]
39+
metadata:
40+
- name: [METADATA-NAME]
41+
value: [METADATA-VALUE]
42+
```
43+
44+
In Azure Container Apps, the above schema is slightly simplified to support Dapr components and remove unnecessary fields, including `apiVersion`, `kind`, and redundant metadata and spec properties.
45+
46+
```yaml
47+
componentType: [COMPONENT-TYPE]
48+
version: v1
49+
initTimeout: [TIMEOUT-DURATION]
50+
ignoreErrors: [BOOLEAN]
51+
metadata:
52+
- name: [METADATA-NAME]
53+
value: [METADATA-VALUE]
54+
```
55+
56+
## Component scopes
57+
58+
By default, all Dapr-enabled container apps within the same environment load the full set of deployed components. To ensure only the appropriate container apps load components at runtime, application scopes should be used. In the following example, the component is only loaded by the two Dapr-enabled container apps with Dapr application IDs `APP-ID-1` and `APP-ID-2`:
59+
60+
```yaml
61+
componentType: [COMPONENT-TYPE]
62+
version: v1
63+
initTimeout: [TIMEOUT-DURATION]
64+
ignoreErrors: [BOOLEAN]
65+
metadata:
66+
- name: [METADATA-NAME]
67+
value: [METADATA-VALUE]
68+
scopes:
69+
- [APP-ID-1]
70+
- [APP-ID-2]
71+
```
72+
73+
> [!NOTE]
74+
> Dapr component scopes correspond to the Dapr application ID of a container app, not the container app name.
75+
76+
## Connecting to external services via Dapr
77+
78+
There are a few approaches supported in container apps to securely establish connections to external services for Dapr components.
79+
80+
1. [Using managed identity](#using-managed-identity)
81+
1. Using a Dapr secret store component reference by creating either:
82+
- [An Azure Key Vault secret store](#azure-key-vault-secret-stores), which uses managed identity, or
83+
- [Platform-Managed Kubernetes secrets](#platform-managed-kubernetes-secrets)
84+
85+
### Using managed identity
86+
87+
For Azure-hosted services, Dapr can use [the managed identity of the scoped container apps][aca-managed-id] to authenticate to the backend service provider. When using managed identity, you don't need to include secret information in a component manifest. Using managed identity is preferred as it eliminates storage of sensitive input in components and doesn't require managing a secret store.
88+
89+
> [!NOTE]
90+
> The `azureClientId` metadata field (the client ID of the managed identity) is **required** for any component authenticating with user-assigned managed identity.
91+
92+
### Using a Dapr secret store component reference
93+
94+
When you create Dapr components for non-Entra ID enabled services, certain metadata fields require sensitive input values. The recommended approach for retrieving these secrets is to reference an existing Dapr secret store component that securely accesses secret information.
95+
96+
To set up a reference:
97+
98+
1. [Create a Dapr secret store component using the Azure Container Apps schema.](#creating-a-dapr-secret-store-component) The component type for all supported Dapr secret stores begins with `secretstores.`.
99+
1. [Create extra components (as needed) which reference the Dapr secret store component](#referencing-dapr-secret-store-components) you created to retrieve the sensitive metadata input.
100+
101+
#### Creating a Dapr secret store component
102+
103+
When creating a secret store component in Azure Container Apps, you can provide sensitive information in the metadata section in either of the following ways:
104+
105+
- [For an **Azure Key Vault secret store**,](#using-managed-identity) use managed identity to establish the connection.
106+
- [For **non-Azure secret stores**,](#platform-managed-kubernetes-secrets) use platform-managed Kubernetes secrets that are defined directly as part of the component manifest.
107+
108+
##### Azure Key Vault secret stores
109+
110+
The following component showcases the simplest possible secret store configuration using an Azure Key Vault secret store. In this example, publisher and subscriber applications are configured to both have a system or user-assigned managed identity with appropriate permissions on the Azure Key Vault instance.
111+
112+
```yaml
113+
componentType: secretstores.azure.keyvault
114+
version: v1
115+
metadata:
116+
- name: vaultName
117+
value: [your_keyvault_name]
118+
- name: azureEnvironment
119+
value: "AZUREPUBLICCLOUD"
120+
- name: azureClientId # Only required for authenticating user-assigned managed identity
121+
value: [your_managed_identity_client_id]
122+
scopes:
123+
- publisher-app
124+
- subscriber-app
125+
```
126+
127+
##### Platform-managed Kubernetes secrets
128+
129+
Kubernetes secrets, Local environment variables, and Local file Dapr secret stores aren't supported in Azure Container Apps. As an alternative for the upstream Dapr default Kubernetes secret store, Azure Container Apps provides a platform-managed approach for creating and leveraging Kubernetes secrets.
130+
131+
This component configuration defines the sensitive value as a secret parameter that can be referenced from the metadata section. This approach can be used to connect to non-Azure services or in dev/test scenarios for quickly deploying components via the CLI without setting up a secret store or managed identity.
132+
133+
```yaml
134+
componentType: secretstores.azure.keyvault
135+
version: v1
136+
metadata:
137+
- name: vaultName
138+
value: [your_keyvault_name]
139+
- name: azureEnvironment
140+
value: "AZUREPUBLICCLOUD"
141+
- name: azureTenantId
142+
value: "[your_tenant_id]"
143+
- name: azureClientId
144+
value: "[your_client_id]"
145+
- name: azureClientSecret
146+
secretRef: azClientSecret
147+
secrets:
148+
- name: azClientSecret
149+
value: "[your_client_secret]"
150+
scopes:
151+
- publisher-app
152+
- subscriber-app
153+
```
154+
155+
#### Referencing Dapr secret store components
156+
157+
Once you [create a Dapr secret store using one of the previous approaches](#creating-a-dapr-secret-store-component), you can reference that secret store from other Dapr components in the same environment. In the following example, the `secretStoreComponent` field is populated with the name of the secret store specified in the previous examples, where the `sb-root-connectionstring` is stored.
158+
159+
```yaml
160+
componentType: pubsub.azure.servicebus.queue
161+
version: v1
162+
secretStoreComponent: "my-secret-store"
163+
metadata:
164+
- name: connectionString
165+
secretRef: sb-root-connectionstring
166+
scopes:
167+
- publisher-app
168+
- subscriber-app
169+
```
170+
171+
## Component examples
172+
173+
# [YAML](#tab/yaml)
174+
175+
To create a Dapr component via the Container Apps CLI, you can use a container apps YAML manifest. When configuring multiple components, you must create and apply a separate YAML file for each component.
176+
177+
```azurecli
178+
az containerapp env dapr-component set --name ENVIRONMENT_NAME --resource-group RESOURCE_GROUP_NAME --dapr-component-name pubsub --yaml "./pubsub.yaml"
179+
```
180+
181+
```yaml
182+
# pubsub.yaml for Azure Service Bus component
183+
componentType: pubsub.azure.servicebus.queue
184+
version: v1
185+
secretStoreComponent: "my-secret-store"
186+
metadata:
187+
- name: connectionString
188+
secretRef: sb-root-connectionstring
189+
scopes:
190+
- publisher-app
191+
- subscriber-app
192+
```
193+
194+
# [Bicep](#tab/bicep)
195+
196+
This resource defines a Dapr component called `dapr-pubsub` via Bicep. The Dapr component is defined as a child resource of the Container Apps environment. To define multiple components, you can add a `daprComponent` resource for each.
197+
198+
```bicep
199+
resource daprComponent 'daprComponents@2022-03-01' = {
200+
name: 'dapr-pubsub'
201+
properties: {
202+
componentType: 'pubsub.azure.servicebus.queue'
203+
version: 'v1'
204+
secretStoreComponent: 'my-secret-store'
205+
metadata: [
206+
{
207+
name: 'connectionString'
208+
secretRef: 'sb-root-connectionstring'
209+
}
210+
]
211+
scopes: [
212+
'publisher-app'
213+
'subscriber-app'
214+
]
215+
}
216+
}
217+
```
218+
219+
# [ARM](#tab/arm)
220+
221+
This resource defines a Dapr component called `dapr-pubsub` via ARM.
222+
223+
```json
224+
{
225+
"resources": [
226+
{
227+
"type": "daprComponents",
228+
"name": "dapr-pubsub",
229+
"properties": {
230+
"componentType": "pubsub.azure.servicebus.queue",
231+
"version": "v1",
232+
"secretScoreComponent": "my-secret-store",
233+
"metadata": [
234+
{
235+
"name": "connectionString",
236+
"secretRef": "sb-root-connectionstring"
237+
}
238+
],
239+
"scopes": ["publisher-app", "subscriber-app"]
240+
}
241+
}
242+
]
243+
}
244+
```
245+
246+
---
247+
248+
## Next steps
249+
250+
[Learn how to set Dapr component resiliency.][dapr-resiliency]
251+
252+
<!-- Links Internal -->
253+
254+
[dapr-component-connection]: ./dapr-component-connection.md
255+
[dapr-keda]: ./dapr-keda-scaling.md
256+
[aca-managed-id]: ./managed-identity.md
257+
[dapr-resiliency]: ./dapr-component-resiliency.md
258+
259+
<!-- Links External -->
260+
261+
[dapr-component]: https://docs.dapr.io/concepts/components-concept/
262+
[dapr-component-spec]: https://docs.dapr.io/reference/resource-specs/

0 commit comments

Comments
 (0)