question

shaked avatar image
shaked asked

PlayFab won't wait for Azure function.

This scenario is talking about a creation of a new user.

I am sending a login request from the client in unity. In the automation system I added a rule that would connect the entity created event to an azure function. Once I am in the azure function, I am initializing the player's entity object with some parameters. Back in the client I am waiting till there is a successful login result. Then I try to get the entity object back from the server.

On the legacy cloud script there were no issues achieving this as the login would wait for the cloud script to finish. However with the Azure functions such waiting does not exist, making me experience a race condition where the client can't get the data, even though it is already written in the PlayFab server.

CloudScriptentitiesAuthentication
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

·
Xiao Zha avatar image
Xiao Zha answered

PlayFab Login APIs are not affected by the rules you set, which means it does not wait for Legacy CloudScript or Azure Function to complete before returning a successful login result. The situation where you can obtain Objects may be caused by the execution and response time of the Legacy CloudScript being faster than that of Azure Function. In this case, we recommend adding a delay time after the player logs in before acquiring the object. This ensures that the Azure Function has enough time to process the request and set the Object.

In addition, the entity_created event will be triggered when an entity is created, and when a Group is created will also trigger the event. So, if you want to execute the Azure Function only when a player first added to the title, you may use player_added_title - PlayFab | Microsoft Learn event instead. And you can call GetTitlePlayersFromMasterPlayerAccountIds API in Azure Function with PlayFabId to get the title player id which is the Id of the Entity in the SetObjects API request body.

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.