question

jpgordon00 avatar image
jpgordon00 asked

Cloudscript Function Cannot Invoke from Client

I have a basic Cloudscript Function that works when called in PlayFab, but the FunctionResult is always null ( and total API calls issued to be 0). Again, the script works when being called in PlayFab or from PlayStream, just not with client code.

"TestFunc" Azure Function:

[FunctionName("TestFunc")]
        public static async Task<dynamic> TestFunc(
            [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequestMessage req, ILogger log)
        {
            return new {DayOfWeek = true};
        }

Result from PlayFab:

256dec1eeaaa6fe5a2b52eae14e8cae7.png

The client code works if the script invoked is a Cloudscript Revision. Yes, I double-checked that I invoked the correct function name.

Client Code:

PlayFabClientAPI.ExecuteCloudScript(new ExecuteCloudScriptRequest {
                    FunctionName = PollUpdateScriptName, GeneratePlayStreamEvent = false
                }, OnUpdateCloudResult, OnError);

The callback 'OnUpdateCloudResult' is invoked, with its ExecuteCloudScriptResult parameter containing a null FunctionResult and 0 APIRequestsIssued.

Why does the function execute everywhere except when my C# invokes it directly?

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.

jpgordon00 avatar image jpgordon00 commented ·

To be clear: The function executes properly in PlayFab. The function does not execute properly containing the correct result when called from C# client code.

0 Likes 0 ·

1 Answer

·
Sarah Zhang avatar image
Sarah Zhang answered

Do you mean you used API ExecuteCloudScript to invoke the Azure Functions? If so, we need to clarify that this API only applies to CloudScript. As this documentation Using and Calling CloudScript using Azure Functions from your PlayFab Title said, you can use this API ExecuteFunction to call the Azure Functions.

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.

jpgordon00 avatar image jpgordon00 commented ·

That turned out to be the root cause for my issue. I guess the difference wasn't clear to me - thank you for the help!

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.