Skip to content

Latest commit

 

History

History
193 lines (161 loc) · 5.89 KB

File metadata and controls

193 lines (161 loc) · 5.89 KB
title Dapr Components in Azure Container Apps
description Learn more about how Dapr components work on your Azure Container App service to develop applications.
ms.author nigreenf
ms.reviewer hannahhunter
author greenie-msft
ms.service azure-container-apps
ms.subservice dapr
ms.custom build-2023
ms.topic concept-article
ms.date 02/02/2026

Dapr components in Azure Container Apps

Dapr uses a modular design where functionality is delivered as a component. The use of Dapr components is optional and dictated exclusively by the needs of your application.

Dapr components in container apps are environment-level resources that:

  • Can provide a pluggable abstraction model for connecting to supporting external services.
  • Can be shared across container apps or scoped to specific container apps.
  • Can use Dapr secrets to securely retrieve configuration metadata.

In this guide, you learn how to configure Dapr components for your Azure Container Apps services.

Component schema

In the Dapr open-source project, all components conform to the following basic schema.

apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
  name: [COMPONENT-NAME]
  namespace: [COMPONENT-NAMESPACE]
spec:
  type: [COMPONENT-TYPE]
  version: v1
  initTimeout: [TIMEOUT-DURATION]
  ignoreErrors: [BOOLEAN]
  metadata:
    - name: [METADATA-NAME]
      value: [METADATA-VALUE]

In Azure Container Apps, this schema is slightly simplified to support Dapr components and remove unnecessary fields, including apiVersion, kind, and redundant metadata and spec properties.

componentType: [COMPONENT-TYPE]
version: v1
initTimeout: [TIMEOUT-DURATION]
ignoreErrors: [BOOLEAN]
metadata:
  - name: [METADATA-NAME]
    value: [METADATA-VALUE]

Component scopes

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.

componentType: [COMPONENT-TYPE]
version: v1
initTimeout: [TIMEOUT-DURATION]
ignoreErrors: [BOOLEAN]
metadata:
  - name: [METADATA-NAME]
    value: [METADATA-VALUE]
scopes:
  - [APP-ID-1]
  - [APP-ID-2]

Note

Dapr component scopes provide better security measures and correspond to the Dapr application ID of a container app, not the container app name.

Component examples

To create a Dapr component by using 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.

az containerapp env dapr-component set --name <your-environment-name> --resource-group <your-resource-group> --dapr-component-name pubsub --yaml "./pubsub.yaml"
# pubsub.yaml for Azure Service Bus component
componentType: pubsub.azure.servicebus.queue
version: v1
secretStoreComponent: "my-secret-store"
metadata:
  - name: namespaceName
    # Required when using Azure Authentication.
    # Must be a fully-qualified domain name
    value: "[your_servicebus_namespace.servicebus.windows.net]"
  - name: azureTenantId
    value: "[your_tenant_id]"
  - name: azureClientId 
    value: "[your_client_id]"
  - name: azureClientSecret
    secretRef: azClientSecret
scopes:
  - publisher-app
  - subscriber-app

This resource defines a Dapr component called dapr-pubsub by using 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.

resource daprComponent 'daprComponents@2022-03-01' = {
  name: 'dapr-pubsub'
  properties: {
    componentType: 'pubsub.azure.servicebus.queue'
    version: 'v1'
    secretStoreComponent: 'my-secret-store'
    metadata: [
      {
        name: 'namespaceName'
        // Required when using Azure Authentication.
        // Must be a fully-qualified domain name
        value: '[your_servicebus_namespace.servicebus.windows.net]'
        name: 'azureTenantId'
        value: '[your_tenant_id]'
        name: 'azureClientId' 
        value: '[your_client_id]'
        name: 'azureClientSecret'
        secretRef: 'azClientSecret'
      }
    ]
    scopes: [
      'publisher-app'
      'subscriber-app'
    ]
  }
}

This resource defines a Dapr component called dapr-pubsub by using an ARM template.

{
  "resources": [
    {
      "type": "daprComponents",
      "name": "dapr-pubsub",
      "properties": {
        "componentType": "pubsub.azure.servicebus.queue",
        "version": "v1",
        "secretScoreComponent": "my-secret-store",
        "metadata": [
          {
            "name": "namespaceName",
            "value": "[your_servicebus_namespace.servicebus.windows.net]",
            "name": "azureTenantId",
            "value": "[your_tenant_id]",
            "name": "azureClientId",
            "value": "[your_client_id]",
            "name": "azureClientSecret",
            "secretRef": "azClientSecret"
          }
        ],
        "scopes": ["publisher-app", "subscriber-app"]
      }
    }
  ]
}

Next step

[!div class="nextstepaction"] Connect to other Azure or external services via Dapr components