mwillows avatar image
mwillows asked

Azure Function works in Unity Editor, but not on device (Android)

So I've implemented several functions on Azure and they all work great in the editor, however when I call them from an acoutl Android device, I get a the follwing -
Network Error: Invalid Input Parameters System.Collections.Generic.Dictionary'2[System.String.SystemCollections.Generic.List'1[System.string]]

Looking at the Azure log stream I can see the calls I make from the editor, but I don't see any calls from the device, leading me to think its some sort of serialization issue early in the process? I'm using scripts taken largely from the Tic-Tac-Toe azure function playfab unity demo.

This is my ExecuteAzureFunction script, its pretty basic with a little extra debugging in there to help me track things on the device. Everything looks correct in all the logs, except that I get the Invalid Input Parameter. The parameter I'm passing is a simple struct that has a string and an in, in the logs and in the error pop-up it looks to serialize correctly. My next step is to take the tic-tac-toe demo and build and push to device to see if it has the same error, but that's a pain, so checking here first. Thanks.

public void ExecuteAzureFunction(string functionName, object Parameter, Action<ExecuteFunctionResult> callback, int attmpts = 0, bool playStream = false)
        string paraJson = JsonUtility.ToJson(Parameter);
        Debug.Log("Executing: " + functionName + " with: " + paraJson);

        PlayFabCloudScriptAPI.ExecuteFunction(new ExecuteFunctionRequest()
            Entity = new PlayFab.CloudScriptModels.EntityKey()
                Id = ServiceLocator.Instance.GetInstanceOfType<AuthenticationManager>().m_EntityID, //Get this from when you logged in,
                Type = ServiceLocator.Instance.GetInstanceOfType<AuthenticationManager>().m_EntityType, //Get this from when you logged in
            FunctionName = functionName, 
            FunctionParameter = Parameter, 
            GeneratePlayStreamEvent = playStream 
        (PlayFabError error) =>
            if (Is_Debug_Mode_Active)
                string paraJsonError = JsonUtility.ToJson(Parameter);
                string msg = "Network Error:\n" + functionName + "\n" + paraJsonError + "\n " + error.ErrorMessage + "\n" + error.ErrorDetails;

                Debug.LogError(msg + "Name: " + functionName);
            //callback.Invoke(null, "Server Script Error", Parameter);
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

I don’t see which line the error prompts. According to the error message, it is possible that the deserialization process goes wrong. I am not sure how you handle the success callback result, but please try to use PlayFab_Serializer to deserialize strings if the data is a json object:

var serializer = PluginManager.GetPlugin<ISerializerPlugin>(PluginContract.PlayFab_Serializer);); 

Feel free to let me know if there are any other questions.

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.