Being honest I'm new to Azure Functions and really basic at C#, I've been looking for answers at some posts here but I'm they didn't work for me or I didn't understand them.
I have a self-triggered function that is doing a API call to Power BI. I want to 'await' until this call finish, but once I start running the function, it just finish without logging some result.
public async static void Run(TimerInfo myTimer, TraceWriter log){
log.Info($"C# Timer trigger function executed at: {DateTime.Now}");
var credentials = new TokenCredentials(AZ_ACCESS_KEY, AZ_APP_ID);
var PBIClient = new PowerBIClient(credentials);
var report = await getReport(PBIClient);
log.Info($"Response {report}");
}
public static async Task<Microsoft.PowerBI.Api.V2.Models.Report> getReport(PowerBIClient PBIClient){
var myTask = Task.Run(() =>
PBIClient.Reports.GetReport(REPORT_ID)
);
var x = await myTask;
return x;
}
Now I have no idea why the function is finishing successfully without logging anything, even if somehow the response returns nothing the function might log Response
isn't it?
These are the logging results:
2020-02-07T20:20:53.354 [Info] Function started (Id=20ccb5b0-abf2-4957-aeb6-b9f26747c1f0)
2020-02-07T20:20:53.604 [Info] C# Timer trigger function executed at: 2/7/2020 8:20:53 PM
2020-02-07T20:20:53.684 [Info] Function completed (Success, Id=20ccb5b0-abf2-4957-aeb6-b9f26747c1f0, Duration=317ms)
See? It seems that the function is not respecting the await, but I don't know what I'm doing wrong. Thanks,