Microsoft.Extensions.ServiceDiscovery.Dns
8.0.2
Prefix Reserved
See the version list below for details.
dotnet add package Microsoft.Extensions.ServiceDiscovery.Dns --version 8.0.2
NuGet\Install-Package Microsoft.Extensions.ServiceDiscovery.Dns -Version 8.0.2
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery.Dns" Version="8.0.2" />
paket add Microsoft.Extensions.ServiceDiscovery.Dns --version 8.0.2
#r "nuget: Microsoft.Extensions.ServiceDiscovery.Dns, 8.0.2"
// Install Microsoft.Extensions.ServiceDiscovery.Dns as a Cake Addin #addin nuget:?package=Microsoft.Extensions.ServiceDiscovery.Dns&version=8.0.2 // Install Microsoft.Extensions.ServiceDiscovery.Dns as a Cake Tool #tool nuget:?package=Microsoft.Extensions.ServiceDiscovery.Dns&version=8.0.2
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/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 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. |
-
net8.0
- DnsClient (>= 1.7.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 8.0.1)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.1)
- Microsoft.Extensions.Options (>= 8.0.2)
- Microsoft.Extensions.Primitives (>= 8.0.0)
- Microsoft.Extensions.ServiceDiscovery (>= 8.0.2)
- Microsoft.Extensions.ServiceDiscovery.Abstractions (>= 8.0.2)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Microsoft.Extensions.ServiceDiscovery.Dns:
Package | Downloads |
---|---|
ServiceDiscovery.NET
Extensible service discovery for .NET |
GitHub repositories (1)
Showing the top 1 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
|
Version | Downloads | Last updated |
---|---|---|
9.0.0-rc.1.24511.1 | 265 | 10/15/2024 |
8.2.2 | 682 | 10/24/2024 |
8.2.1 | 3,397 | 9/26/2024 |
8.2.0 | 3,432 | 8/29/2024 |
8.1.0 | 2,716 | 7/23/2024 |
8.0.2 | 1,352 | 6/28/2024 |
8.0.1 | 7,795 | 5/21/2024 |
8.0.0 | 319 | 5/21/2024 |
8.0.0-preview.7.24251.11 | 176 | 5/7/2024 |
8.0.0-preview.6.24214.1 | 445 | 4/23/2024 |
8.0.0-preview.5.24201.12 | 1,684 | 4/9/2024 |
8.0.0-preview.4.24156.9 | 504 | 3/12/2024 |
8.0.0-preview.3.24105.21 | 2,351 | 2/13/2024 |
8.0.0-preview.2.23619.3 | 1,421 | 12/20/2023 |
8.0.0-preview.1.23557.2 | 1,620 | 11/14/2023 |