I created several Microservices in C# that are running on docker in windows, I need to call Microservice from another Microservice so I used this way to call:
[HttpGet("GetOrder/{Object_ID}")]
public Order GetOrder (int id)
{
string Baseurl = "http://189.29.0.100/";
…..
using (var client = new HttpClient())
{
//Passing service base url
client.BaseAddress = new Uri(Baseurl);
client.DefaultRequestHeaders.Clear();
//Define request data format
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
//Sending request to find web api REST service resource GetAllEmployees using HttpClient
borrowerData = await client.GetStringAsync("api/order/" + Id.ToString());
}
…
}
I used the fix IP in Composed file as follows:
orderservice:
environment:
- ASPNETCORE_ENVIRONMENT=Development
ports:
- "80"
networks:
default:
ipv4_address: 189.29.0.100
The problem is when we deploy this project in VM, how to make it work with these Ips?