Reputation: 307
I was not able to call an API from a service hosted on Service Fabric, and configured to use dynamic ports. I referred the docs to setup the internal DNS service and named it as follows in ApplicationManifest.xml
<Service Name="Data" ServiceDnsName="services.data">
I tried calling the API as follows:
using (var client = new HttpClient())
{
var response1 = await client.GetAsync("https://services.data/api/v1/countries"); // throws exception
var response2 = await client.GetAsync("https://services.data:30006/api/v1/countries"); // works
}
But I observe that unless the port value is explicitly provided in the Uri, it didn't work.
Upvotes: 0
Views: 898
Reputation: 11351
The concept of a DNS is translate a human readable string to an IP.
For example:
Given a domain www.mydomain.com
, a DNS call translate it to an IP 192.168.0.1
where your request will be sent.
If you expect the client to connect on any port other than 80(http) you would have to make a request for www.mydomain.com:81
that would be translated to192.168.0.1:81
On service fabric DNS the same logic applies.
Given the service: service1
on application1
.
The DNS entry will be: service1.application1
An IP resolution will redirect to: The node IP
If your service doesn't listen the requests on port 80, the client has to provide the port where your service is listening to.
If you plan to use dynamic assigned ports, I would recommend you using the reverse proxy or using remoting
Upvotes: 3