संपादित करें

इसके माध्यम से साझा किया गया


Connect to Azure services via Dapr components in the Azure portal

You can easily connect Dapr APIs to backing Azure services using a combination of Service Connector and Dapr. This feature creates Dapr components on your behalf with valid metadata and authenticated identity to access the Azure service.

In this guide, you'll connect Dapr Pub/Sub API to an Azure Service Bus by:

  • Select pub/sub as the API
  • Specify Azure Service Bus as the service and required properties like namespace, queue name, and identity
  • Use your Azure Service Bus pub/sub component!

Prerequisites

Create a Dapr component

Start by navigating to the Dapr component creation feature.

  1. In the Azure portal, navigate to your Container Apps environment.

  2. In the left-side menu, under Settings, select Dapr components.

  3. From the top menu, select Add > Azure component to open the Add Dapr Component configuration pane.

    Screenshot of selecting Azure Component from the drop down menu.

    Note

    Currently, creating Dapr components using Service Connector in the Azure portal only works with Azure services (Azure Service Bus, Azure Cosmos DB, etc.). To create non-Azure Dapr components (Redis), use the manual component creation option.

Provide required metadata

For the component creation tool to map to the required component metadata, you need to provide the required metadata from predefined dropdowns in the Basics tab.

For example, for a pub/sub Azure Service Bus component, you'll start with the following fields:

Field Example Description
Component name mycomponent Enter a name for your Dapr component. The name must match the component referenced in your application code.
Building block Pub/sub Select the building block/API for your component from the drop-down.
Component type Service Bus Select a component type from the drop-down.

The component creation pane populates with different fields depending on the building block and component type you select. For example, the following table and image demonstrate the fields associated with an Azure Service Bus pub/sub component type, but the fields you see may vary.

Field Example Description
Subscription My subscription Select your Azure subscription
Namespace mynamespace Select the Service Bus namespace
Authentication User assigned managed identity Select the subscription that contains the component you're looking for. Recommended: User assigned managed identity.
User assigned managed identity testidentity Select an existing identity from the drop-down. If you don’t already have one, you can create a new managed identity client ID.

Screenshot of the Azure platform showing the Basics tab of adding a Dapr Pub/sub component.

What happened?

Now that you've filled out these required fields, they'll automatically map to the required component metadata. In this Service Bus example, the only required metadata is the connection string. The component creation tool takes the information you provided and maps the input to create a connection string in the component YAML file.

Provide optional metadata

While the component creation tool automatically populates all required metadata for the component, you can also customize the component by adding optional metadata.

  1. Select Next : Metadata + Scopes.

  2. Under Metadata, select Add to select extra, optional metadata for your Dapr component from a drop-down of supported fields.

  3. Under Scopes, select Add or type in the app IDs for the container apps that you want to load this component.

    • By default, when the scope is unspecified, Dapr applies the component to all app IDs.
  4. Select Review + Create to review the component values.

  5. Select Create.

Save the component YAML

Once the component has been added to the Container Apps environment, the portal displays the YAML (or Bicep) for the component.

  1. Copy and save the YAML file for future use.

  2. Select Done to exit the configuration pane.

You can then check the YAML/Bicep artifact into a repo and recreate it outside of the portal experience.

Note

When using Managed Identity, the selected identification is assigned to all containers apps in scope and target services.

Manage Dapr components

  1. In your Container Apps environment, go to Settings > Dapr components.

  2. The Dapr components that are tied to your Container Apps environment are listed on this page. Review the list and select the Delete icon to delete a component, or select a component's name to review or edit its details.

    Screenshot of the Azure platform showing existing Dapr Components.

Next steps

Enable Dapr on your container apps.

Learn more about: