The documentation you are viewing is for Dapr v1.11 which is an older version of Dapr. For up-to-date documentation, see the latest version.
How-To: Invoke Non-Dapr Endpoints using HTTP
This article demonstrates how to call a non-Dapr endpoint using Dapr over HTTP.
Using Dapr’s service invocation API, you can communicate with endpoints that either use or do not use Dapr. Using Dapr to call endpoints that do not use Dapr not only provides a consistent API, but also the following Dapr service invocation benefits:
- Ability to apply resiliency policies
- Call observability with tracing & metrics
- Security access control through scoping
- Ability to utilize middleware pipeline components
- Service discovery
- Authentication through the use of headers
HTTP service invocation to external services or non-Dapr endpoints
Sometimes you need to call a non-Dapr HTTP endpoint. For example:
- You may choose to only use Dapr in part of your overall application, including brownfield development
- You may not have access to the code to migrate an existing application to use Dapr
- You need to call an external HTTP service.
By defining an
HTTPEndpoint resource, you declaratively define a way to interact with a non-Dapr endpoint. You then use the service invocation URL to invoke non-Dapr endpoints. Alternatively, you can place a non-Dapr Fully Qualified Domain Name (FQDN) endpoint URL directly into the service invocation URL.
Order of precedence between HttpEndpoint, FQDN URL, and appId
When using service invocation, the Dapr runtime follows a precedence order:
- Is this a named
- Is this an FQDN URL with an
- Is this an
Service invocation and non-Dapr HTTP endpoint
The diagram below is an overview of how Dapr’s service invocation works when invoking non-Dapr endpoints.
- Service A makes an HTTP call targeting Service B, a non-Dapr endpoint. The call goes to the local Dapr sidecar.
- Dapr discovers Service B’s location using the
HTTPEndpointor FQDN URL.
- Dapr forwards the message to Service B.
- Service B runs its business logic code.
- Service B sends a response to Service A’s Dapr sidecar.
- Service A receives the response.
Using an HTTPEndpoint resource or FQDN URL for non-Dapr endpoints
There are two ways to invoke a non-Dapr endpoint when communicating either to Dapr applications or non-Dapr applications. A Dapr application can invoke a non-Dapr endpoint by providing one of the following:
HTTPEndpointresource, including defining an
HTTPEndpointresource type. See the HTTPEndpoint reference guide for an example.
For example, with an
HTTPEndpointresource called “palpatine” and a method called “Order66”, this would be:
A FQDN URL to the non-Dapr endpoint.
For example, with an FQDN resource called
https://darthsidious.starwars, this would be:
Using appId when calling Dapr enabled applications
AppIDs are always used to call Dapr applications with the
appID and `my-method``. Read the How-To: Invoke services using HTTP guide for more information. For example:
Community call demo
Watch this video on how to use service invocation to call non-Dapr endpoints.
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.