in order to use HTTPClient and post to a web service from my azure function app Cosmos DB trigger V1 I had to make the Function async which it is not by default,
Changing
public static class Function1
{
[FunctionName("Function1")]
public static void RunAsync([CosmosDBTrigger(
To
public static class Function1
{
[FunctionName("Function1")]
public static async void RunAsync([CosmosDBTrigger(
Please note the async part in the second Function trigger definition
I need this because later on in the function I am using http client as follows and it must use await
HttpResponseMessage response = await httpClient.PostAsync("https://XXXXX", new StringContent(transaction.ToString(), System.Text.Encoding.UTF8, "application/json"));
Am I breaking the trigger by making it async or this is an accepted and supported change?
If not how can I change the use of my httpCLient to work within the trigger Function App?
NOTE: the code works as expected I am just worried it works by mistake so to day.