Microsoft.Extensions.ServiceDiscovery.Dns
10.7.0
Prefix Reserved
dotnet add package Microsoft.Extensions.ServiceDiscovery.Dns --version 10.7.0
NuGet\Install-Package Microsoft.Extensions.ServiceDiscovery.Dns -Version 10.7.0
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery.Dns" Version="10.7.0" />
<PackageVersion Include="Microsoft.Extensions.ServiceDiscovery.Dns" Version="10.7.0" />
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery.Dns" />
paket add Microsoft.Extensions.ServiceDiscovery.Dns --version 10.7.0
#r "nuget: Microsoft.Extensions.ServiceDiscovery.Dns, 10.7.0"
#:package Microsoft.Extensions.ServiceDiscovery.Dns@10.7.0
#addin nuget:?package=Microsoft.Extensions.ServiceDiscovery.Dns&version=10.7.0
#tool nuget:?package=Microsoft.Extensions.ServiceDiscovery.Dns&version=10.7.0
Microsoft.Extensions.ServiceDiscovery.Dns
This library provides support for resolving service endpoints using DNS (Domain Name System). It provides two service endpoint providers:
DNS, which resolves endpoints using DNS
A/AAAArecord queries. This means that it can resolve names to IP addresses, but cannot resolve port numbers endpoints. As such, port numbers are assumed to be the default for the protocol (for example, 80 for HTTP and 433 for HTTPS). The benefit of using the DNS provider is that for cases where these default ports are appropriate, clients can spread their requests across hosts. For more information, see Load-balancing with endpoint selectors.DNS SRV, which resolves service names using DNS SRV record queries. This allows it to resolve both IP addresses and port numbers. This is useful for environments which support DNS SRV queries, such as Kubernetes (when configured accordingly).
Resolving service endpoints with DNS
The DNS service endpoint provider resolves endpoints using DNS A/AAAA record queries. This means that it can resolve names to IP addresses, but cannot resolve port numbers endpoints. As such, port numbers are assumed to be the default for the protocol (for example, 80 for HTTP and 433 for HTTPS). The benefit of using the DNS service endpoint provider is that for cases where these default ports are appropriate, clients can spread their requests across hosts. For more information, see Load-balancing with endpoint selectors.
To configure the DNS service endpoint provider in your application, add the DNS service endpoint provider to your host builder's service collection using the AddDnsServiceEndpointProvider method. service discovery as follows:
builder.Services.AddServiceDiscoveryCore();
builder.Services.AddDnsServiceEndpointProvider();
Resolving service endpoints in Kubernetes with DNS SRV
When deploying to Kubernetes, the DNS SRV service endpoint provider can be used to resolve endpoints. For example, the following resource definition will result in a DNS SRV record being created for an endpoint named "default" and an endpoint named "dashboard", both on the service named "basket".
apiVersion: v1
kind: Service
metadata:
name: basket
spec:
selector:
name: basket-service
clusterIP: None
ports:
- name: default
port: 8080
- name: dashboard
port: 8888
To configure a service to resolve the "dashboard" endpoint on the "basket" service, add the DNS SRV service endpoint provider to the host builder as follows:
builder.Services.AddServiceDiscoveryCore();
builder.Services.AddDnsSrvServiceEndpointProvider();
The special port name "default" is used to specify the default endpoint, resolved using the URI http://basket.
As in the previous example, add service discovery to an HttpClient for the basket service:
builder.Services.AddHttpClient<BasketServiceClient>(
static client => client.BaseAddress = new("http://basket/"));
Similarly, the "dashboard" endpoint can be targeted as follows:
builder.Services.AddHttpClient<BasketServiceDashboardClient>(
static client => client.BaseAddress = new("http://_dashboard.basket/"));
Feedback & contributing
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- DnsClient (>= 1.8.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.9)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.9)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.9)
- Microsoft.Extensions.Options (>= 10.0.9)
- Microsoft.Extensions.Primitives (>= 10.0.9)
- Microsoft.Extensions.ServiceDiscovery (>= 10.7.0)
- Microsoft.Extensions.ServiceDiscovery.Abstractions (>= 10.7.0)
-
net8.0
- DnsClient (>= 1.8.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 8.0.2)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.3)
- Microsoft.Extensions.Options (>= 8.0.2)
- Microsoft.Extensions.Primitives (>= 8.0.0)
- Microsoft.Extensions.ServiceDiscovery (>= 10.7.0)
- Microsoft.Extensions.ServiceDiscovery.Abstractions (>= 10.7.0)
-
net9.0
- DnsClient (>= 1.8.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 9.0.17)
- Microsoft.Extensions.Configuration.Binder (>= 9.0.17)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.17)
- Microsoft.Extensions.Options (>= 9.0.17)
- Microsoft.Extensions.Primitives (>= 9.0.17)
- Microsoft.Extensions.ServiceDiscovery (>= 10.7.0)
- Microsoft.Extensions.ServiceDiscovery.Abstractions (>= 10.7.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Microsoft.Extensions.ServiceDiscovery.Dns:
| Package | Downloads |
|---|---|
|
ServiceDiscovery.NET
Extensible service discovery for .NET |
|
|
Qiqiko.Shared.Hosting.Gateways
Package Description |
GitHub repositories (5)
Showing the top 5 popular GitHub repositories that depend on Microsoft.Extensions.ServiceDiscovery.Dns:
| Repository | Stars |
|---|---|
|
abpframework/eShopOnAbp
Reference microservice solution built with the ABP Framework and .NET, runs on Kubernetes with Helm configuration, includes API Gateways, Angular and ASP.NET Core MVC applications, PostgreSQL and MongoDB databases
|
|
|
thangchung/practical-dotnet-aspire
The practical .NET Aspire builds on the coffeeshop app business domain
|
|
|
ProfessionalCSharp/ProfessionalCSharp2021
Source code for Professional C# and .NET 2021 Edition (with updates for C# 11 and .NET 7)
|
|
|
aws/integrations-on-dotnet-aspire-for-aws
This repositry contains the integrations with .NET Aspire for AWS.
|
|
|
anuviswan/LearningPoint
A repository for learning different technologies, frameworks, features......
|
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 10.7.0 | 369 | 6/9/2026 | |
| 10.6.0 | 4,976 | 5/12/2026 | |
| 10.5.0 | 12,452 | 4/15/2026 | |
| 10.4.0 | 12,004 | 3/10/2026 | |
| 10.3.0 | 11,446 | 2/10/2026 | |
| 10.2.0 | 9,351 | 1/13/2026 | |
| 10.1.0 | 15,149 | 12/9/2025 | |
| 10.0.0 | 19,395 | 11/11/2025 | |
| 9.5.2 | 22,407 | 10/23/2025 | |
| 9.5.1 | 17,938 | 10/3/2025 | |
| 9.5.0 | 4,900 | 9/25/2025 | |
| 9.4.2 | 10,455 | 9/2/2025 | |
| 9.4.1 | 6,789 | 8/12/2025 | |
| 9.4.0 | 6,959 | 7/29/2025 | |
| 9.3.1 | 35,806 | 6/10/2025 | |
| 9.3.0 | 10,083 | 5/19/2025 | |
| 9.2.1 | 7,727 | 4/24/2025 | |
| 9.2.0 | 4,690 | 4/10/2025 | |
| 9.1.0 | 14,272 | 2/25/2025 | |
| 9.0.0 | 46,795 | 11/12/2024 |