question

szcuipeng avatar image
szcuipeng asked

please help me about local debug cloudscript using azure function.

5860-function.txt

i following the article: https://learn.microsoft.com/en-us/gaming/playfab/features/automation/cloudscript-af/local-debugging-for-cloudscript-using-azure-functions

the function.txt is my full source code, i am using vs code.

i called LoginWithServerCustomIdAsync then ExecuteFunction in server side, but i got an error:

Must call Client Login or GetEntityToken before calling this method

PlayFabServerInstanceAPI does not have a function called ExecuteFunction or ExecuteFunction Async

only PlayFabServerAPI have it

where i put playfab.local.settings.json ? i put it to temp dir and vscode project dir, i do not know where is the execute path of my local server.

and do it need deploy the azure function app before i start local debug ?

any advice will be appreciated!

Player DataCloudScriptTitle Data
function.txt (1.7 KiB)
10 |1200

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

Xiao Zha avatar image
Xiao Zha answered

Why do you call LoginWithServerCustomId and then ExecuteFunction API in AzureFunction? The LoginWithServerCustomId API is used to implement custom authentication system on an external server backend. And the ExecuteFunction API is used to execute server-side code, typically you need to call the ExecuteFunction API on the client side.

Also, playfab.local.settings.json, as the docs say, you can add this to the temp directory on your matchine or game project directory (not the AzureFunction project directory).

2 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.

szcuipeng avatar image szcuipeng commented ·

https://learn.microsoft.com/en-us/gaming/playfab/features/automation/cloudscript-af/local-debugging-for-cloudscript-using-azure-functions

the doc say:

To get the local implementation of ExecuteFunction set up in your C# Azure Functions app, add the ExecuteFunction.cs file to your local Azure Functions app.

0 Likes 0 ·
Xiao Zha avatar image Xiao Zha szcuipeng commented ·

The ExecuteFunction.cs is the local implementation of the ExecuteFunction API call, It simulates the behavior of how PlayFab process the ExecuteFunction API call on the server side locally, by reading in parameters specified, passing the right context for the local Azure Functions app to execute, waiting for its response and returning it back. So, you need to add the ExecuteFunction.cs in you Azure Function project and call ExecuteFunction API on game client side to execute the function code.

0 Likes 0 ·
szcuipeng avatar image
szcuipeng answered

first step: you must know how to normal debug Azure function locally, see normal.png 5932-normal.png

step 2: https://learn.microsoft.com/en-us/gaming/playfab/features/automation/cloudscript-af/local-debugging-for-cloudscript-using-azure-functions

step 3: 5933-maincs.txt

Treat here as a client

call: PlayFabServerAPI.LoginWithServerCustomIdAsync

then call: PlayFabServerAPI.GetEntityTokenAsync

then call your own Azure Function, here is TestInternal.


normal.png (29.6 KiB)
maincs.txt (2.3 KiB)
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.