question

cartellonegerardo avatar image
cartellonegerardo asked

How to block data operations on player objects until azure function finished?

I have an azure function that does a getObjectAsyn then a setObjectsAsync on the objects of a player, I want other azure functions that want to perform operations on the data of the same player objects to wait until my initial azure function is done before they perform their operations on the objects of that player.

The whole purpose of this is to simply make sure functions don't use data that is in the process of being changed.

for example: let's say I have an object with data = 100

If two azur functions that want to manipulate the data of that object are called nearly at the same time one is going to call, getObjectAsyn and will get data = 100 then the other is going to call getObjectAsyn and the data will also be 100. Let's say my azure functions add 1 to the data.

the first azure function will then finish and call SetObjectsAsync setting the object data value to 100+1=101 and the second azure function will also set the object data to 101 when ideally I would like the value to be 102 at the end.

Thanks for any help.

Player Dataentitiesdata
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

·
Seth Du avatar image
Seth Du answered

PlayFab doesn't provide file lock features, but in terms of Entity Objects, each update will increase the ProfileVersion by 1, hence it is noticeable if it is target version and Azure Function can perform updating or rejecting based on the ProfileVersion.

A queue trigger Azure Function can also be useful to handle this and if advanced features are required, an external database is preferred.

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.