Hello,
I have an azure function call: WatchAdsProcesstor
I can this function normally from Unity Client both locally or ater deployed to Azure Function.
However, When I set the function in Automation=>Reward Ad.
I got this error from Log on Azure
`2020-11-08T09:46:54.629 [Error] Executed 'WatchAdsProcessor' (Failed, Id=c5608617-7178-4bd2-8dc7-f7d0122574f4, Duration=60ms)Object reference not set to an instance of an object.`
Here is the details of the code.
public static async Task<dynamic> WatchAdsProcessor( [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequestMessage req, ILogger log) { /* Create the function execution's context through the request */ var context = await FunctionContext<dynamic>.Create(req); var serverApi = new PlayFabServerInstanceAPI(context.ApiSettings, context.AuthenticationContext); var getUserDataResult = await serverApi.GetUserDataAsync(new GetUserDataRequest { Keys = new List<string> {PlayerDataKey.BasicPlayerDataKey}, PlayFabId = context.MasterPlayerId }); // var content = JSON.parse(playerData.Data["BasicPlayerData"].Value); var playerData = Newtonsoft.Json.JsonConvert.DeserializeObject<PlayerData>(getUserDataResult.Result .Data[PlayerDataKey.BasicPlayerDataKey].Value); var serverTimeResult = await serverApi.GetTimeAsync(new GetTimeRequest()); playerData.AdInTheDay += 1; playerData.LastAdPlayedTime = serverTimeResult.Result.Time; var adsDataResult = await serverApi.GetTitleDataAsync(new GetTitleDataRequest { Keys = new List<string> {"VideosData"} }); VideosData adsData = Newtonsoft.Json.JsonConvert.DeserializeObject<VideosData>(adsDataResult.Result.Data["VideosData"]); int extraDiamond = 0; if (playerData.AdInTheDay >= adsData.MaxAdPerDay) { return new {messageValue = "Over Watched"}; } var updateUserDataResult = await serverApi.UpdateUserDataAsync(new UpdateUserDataRequest { Data = new Dictionary<string, string> { {PlayerDataKey.BasicPlayerDataKey, Newtonsoft.Json.JsonConvert.SerializeObject(playerData)}}, PlayFabId = context.MasterPlayerId }); if (playerData.AdInTheDay < adsData.VideoAds.Count) { extraDiamond = adsData.VideoAds[playerData.AdInTheDay].DiamondsToReward; } if (extraDiamond > 0) { var updateCurrencyResult = await serverApi.AddUserVirtualCurrencyAsync(new AddUserVirtualCurrencyRequest { PlayFabId = context.MasterPlayerId, Amount = extraDiamond, VirtualCurrency = "DI" }); } return new {messageValue = ""}; }
Could somebody help here?
Also, Do you know how to show debug log with Azure Function. I have added some log however , It didn't show up in the console