question

crossdev avatar image
crossdev asked

How to get Entity from AzureFunction called via Scheduled Task

Hi, I'm trying to update inventory items (Rest Api) of players in a specific segment at 00:00 AM everyday. So I decided to use Scheduled Task (Run actions on each player in a segment) to execute Azure Function on each player in the segment, and I need the player's entity to update inventory item amount. In this case, how do I get the player's entity? I don't see it in the ScheduledTaskFunctionExecutionContext. Thanks!

CloudScriptentitiesscheduled tasks
10 |1200

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

1 Answer

·
Neils Shi avatar image
Neils Shi answered

For Scheduled Task, you can use var context=JsonConvert.DeserializeObject<PlayerPlayStreamFunctionExecutionContext>(await req.ReadAsStringAsync()); to get the context and obtain MasterPlayerAccountId via “context.PlayerProfile.PlayerId”. For more info, please refer to PlayFab CloudScript using Azure Functions Context Models - PlayFab | Microsoft Learn. Then you can use GetTitlePlayersFromMasterPlayerAccountIds API to retrieve the entity of the title player account from the master player account id, and now you can call API UpdateInventoryItems with the entity.

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.

crossdev avatar image crossdev commented ·

Works perfectly! Thank you!

0 Likes 0 ·

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.