title: Calling Asp.Net Web API endpoint from Azure function
body: <p>I am trying to develop following scenario using Azure functions.</p>
  
  <p>I have developed Asp.Net Web API which handles the Database related operation. Now, I want to implement a scheduler like functionality which will run once a day and will clean up junk data from database. I've created an endpoint for that in my Web API but I want to execute it on regular basis so I think to implement scheduler using Azure function's TimerTrigger function, is there any way to call my web api's endpoint in TimerTrigger function. </p>
  
  <p>How to handle my api's authentication in Azure function?</p>
  
  <p>Thanks</p>
  
  <p><strong>Update:</strong></p>
  
  <p>Based on mikhail's answer, finally I got the token using following code:</p>
  
  <pre><code>var client = new HttpClient();
  client.BaseAddress = new Uri(apirooturl);
  
  var grant_type = "password";
  var username = "username";
  var password = "password";
  
  var formContent = new FormUrlEncodedContent(new[]
  {
      new KeyValuePair&lt;string, string&gt;("grant_type", grant_type),
      new KeyValuePair&lt;string, string&gt;("username", username),
      new KeyValuePair&lt;string, string&gt;("password", password)
  });
  
  var token = client.PostAsync("token", formContent).Result.Content.ReadAsAsync&lt;AuthenticationToken&gt;().Result;
  
  client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(token.token_type, token.access_token);
  
  var response = await client.GetAsync(apiendpoint);
  var content = await response.Content.ReadAsStringAsync();
  </code></pre>