I have an Azure Durable Function that sends some HTTP request via VNet. Ones in a while the following method throws a SocketException:
public async Task<(HttpStatusCode statusCode, string Content)> PostAsync(string uri ,string json)
{
if (string.IsNullOrEmpty(uri))
{
throw new ArgumentException("message", nameof(uri));
}
var client = new HttpClient
{
BaseAddress = new Uri(uri)
};
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var content = new StringContent(json, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync("", content);
string responseContent = await response.Content.ReadAsStringAsync();
return (response.StatusCode, responseContent);
}
The requested address is not valid in its context
Is it a problem of VNet or how should I approach this problem?