question

Ben Vissotzky avatar image
Ben Vissotzky asked

Scheduled task failing 100% of the time, but azure function returns a 200 response.

The task fails, but the work gets done. Misleading results that could hide actually problems.

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Citrus Yan avatar image Citrus Yan commented ·

May I know your title id, and the name of the task that fails?

0 Likes 0 ·
Ben Vissotzky avatar image
Ben Vissotzky answered

B0C4B, CollectPlayerSegmentTotals. I recal someone else from PlayFab saying that the function endpoints go dormant if they haven't been activated for sometime. Perhaps that is the issue

9 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Citrus Yan avatar image Citrus Yan commented ·

Cold starting Azure Functions do have some issues, please see detailed discussions here:

https://community.playfab.com/questions/39111/azure-functions-timeout-in-cold-start.html

And, took a look at your title, looks like you are trying to use a Scheduled Task to call a Azure Function which gets the count of players in a segment and updates it to Title data every hour on the hour, and the task says "failed" however the Azure Function do get executed successfully and title data updated, is that right?

Could you please share the detailed configuration of the task?

0 Likes 0 ·
Ben Vissotzky avatar image Ben Vissotzky Citrus Yan commented ·

What other configuration do you mean? Essentially we have a defined number of segments that we need player counts for. This allows us to make a percentile ranking of a players position in a leaderboard since that isn't supported by leaderboards yet. Those counts are then stored in Title Data to be retrievable by client usage.

0 Likes 0 ·
Citrus Yan avatar image Citrus Yan Ben Vissotzky commented ·

I mean details of the configuration in the "Edit Scheduled Task" panel:

And, could you please answer my first question in the previous comment?

0 Likes 0 ·
1.png (6.2 KiB)
Show more comments
Ben Vissotzky avatar image
Ben Vissotzky answered
public async Task CollectPlayerSegmentCountStatistics()
		{
			var vdsConfig = await TitleDataRepository.GetTitleData<VdsAccessConfiguration>(PlayFabAdminController.VdsAccessConfigKey);
			if (vdsConfig == null)
			{
				throw new VdsException("Vds config not found");
			}


			var segment = await PlayFabAdminAPI.GetAllSegmentsAsync(new GetAllSegmentsRequest());
			var characterPlayerCount = new CharacterPlayerCount();
			foreach (var characterMap in vdsConfig.CharacterMappings)
			{
				var statMapping = characterMap.Value.Statistics.First(stat => stat.TrackedStatistic.Equals(TrackedStatistics.Score.ToString()));
				var segmentId = segment.Result.Segments.FirstOrDefault(seg => seg.Name.Equals(statMapping.SegmentName)).Id;
				var request = new GetPlayersInSegmentRequest()
				{
					MaxBatchSize = 1,
					SegmentId = segmentId
				};


				var segmentResponse = await PlayFabAdminAPI.GetPlayersInSegmentAsync(request);
				if (segmentResponse.Error == null && segmentResponse.Result != null)
				{
					characterPlayerCount.Add(characterMap.Key, segmentResponse.Result.ProfilesInSegment);
				}
			}


			var titleResponse = await TitleDataRepository.SetTitleData(LeaderboardPlayerCountKey, characterPlayerCount);
			if (titleResponse.Error != null)
			{
				throw new VdsException($"PlayFab Error, title data not set. Error: {titleResponse.Error.ErrorMessage}");
			}
		}

No significant change was made. Fromt he timestamp of the run on 8-31 I suspect that was a manual run I did while testing that had passed. The recurring tasks never pass. And again, from azure portal I can see that the function is returning a 200 response.

I created a new task with similar configuration and playfab also says that fails(with 200 from azure)

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.