You can follow this link to get started Azure Function timer trigger.
You have to use HTTPClient
to call Api.
static HttpClient client = new HttpClient();
// Update port # in the following line.
client.BaseAddress = new Uri("http://localhost:64195/");
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/json"));
Product product = null;
HttpResponseMessage response = await client.GetAsync(path);
if (response.IsSuccessStatusCode)
{
product = await response.Content.ReadAsAsync<Product>();
}
return product;
Note: If you have to call lots of API's/endpoints, you may get port exhaustion error. HttpClientFactory
is recommended for that scenario.