question

robertgrospitch avatar image
robertgrospitch asked

Calling JS Azure Function With C# Within Unity

Hello All,

I normally use C# for all my coding, however, this one aspect of my game required a JS Azure function to be written.

I have many C# Azure Functions from within unity in the past, however, with this JS Azure function working I would like to call it from my C# script.

 PlayFabCloudScriptAPI.ExecuteFunction(new ExecuteFunctionRequest()
        {
            Entity = new PlayFab.CloudScriptModels.EntityKey()
            {
                Id = PlayFabSettings.staticPlayer.EntityId, //Get this from when you logged in,
                Type = PlayFabSettings.staticPlayer.EntityType, //Get this from when you logged in
            },
            FunctionName = "EOSJS-HTTPTrigger", //This should be the name of your Azure Function that you created.
            FunctionParameter = new Dictionary<string, string>() { { "name", "test"} },
            GeneratePlayStreamEvent = false //Set this to true if you would like this call to show up in PlayStream
        }, (ExecuteFunctionResult result) =>
        {
            if (result.FunctionResultTooLarge ?? false)
            {
                Debug.Log("This can happen if you exceed the limit that can be returned from an Azure Function, See PlayFab Limits Page for details.");
                return;
            }
            Debug.Log(result.FunctionResult.ToString());
        }, (PlayFabError error) =>
        {
            Debug.Log($"Opps Something went wrong: {error.GenerateErrorReport()}");
        });

When this is called it gives a 404 error saying that it could not be found. Do I need to call it differently than I normally would with it being a JS Azure function? It is an HTTP Trigger.

Thank you,

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

Azure Function can be created in any language you decide and so does the PlayFab API call. Using PlayFab C# SDK to call a JS Azure Function won't have any issues.

Does the 404-error indicate that it cannot find the Azure Function name? Have you register the function in Game Manager?

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.