question

Iain Ross avatar image
Iain Ross asked

Hi, I'm getting this error , Opps Something went wrong: /CloudScript/ExecuteFunction: Cloud script function imrhelloworld returned value that was too large, when calling ExecuteFunction on example Azure Function

unity3dCloudScript
4 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.

Iain Ross avatar image Iain Ross commented ·

I have hacked it to just try and return a string value, I'm also not seeing any Logging coming via the azure portal logstream.

using System.Threading.Tasks;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using PlayFab.Samples;

namespace PlayFabCS2AFSample.HelloWorld
{
    public static class HelloWorld
    {
        [FunctionName("HelloWorld")]
        public static async Task<dynamic> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
            ILogger log)
        {
            await req.ReadAsStringAsync();
           
            var message = "Hello!";
            log.LogInformation("Hello");
           
            //log.LogDebug($"HelloWorld: {new { input = inputValue} }");
            log.LogDebug("HelloWorld");
            return new { messageValue = message };
        }
    }
}


0 Likes 0 ·
Iain Ross avatar image Iain Ross commented ·

csproj is this

Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <AzureFunctionsVersion>v4</AzureFunctionsVersion>
     <DefineConstants>NETCOREAPP3_1</DefineConstants>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.0.1" />
    <PackageReference Include="PlayFabAllSDK" Version="1.108.220118" />
  </ItemGroup>
  <ItemGroup>
    <None Update="host.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <None Update="local.settings.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <CopyToPublishDirectory>Never</CopyToPublishDirectory>
    </None>
  </ItemGroup>
</Project>

0 Likes 0 ·
Iain Ross avatar image Iain Ross commented ·

As you can probably tell I'm very new to PlayFab but it seems to do everything my next project is going to need.

0 Likes 0 ·
Iain Ross avatar image Iain Ross Iain Ross commented ·

I have removed/unregistered the actual function for now until next work on it.

0 Likes 0 ·
Gosen Gao avatar image
Gosen Gao answered

Your code of Azure Function worked fine in my test. If there are no logs in the logstream, there may be something incorrect when registering the function to PlayFab. May I know how you register this function to PlayFab? Since this function requires no parameters, could you please use the function URL directly in the browser to see if you can get the correct result?

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.

Iain Ross avatar image Iain Ross commented ·

Hi, Thanks for quick response, indeed I had regsitered it wrong, a good nights sleep helps too :). I've just noticed I was using the wrong URL, I copied the one without the api/helloworld at the end of it from the VSCode output. All is working as it should :)

0 Likes 0 ·
Iain Ross avatar image
Iain Ross answered

This is the call function,

private void CallCSharpExecuteFunction()
    {
        PlayFabCloudScriptAPI.ExecuteFunction(new ExecuteFunctionRequest()
        {
            Entity = new PlayFab.CloudScriptModels.EntityKey()
            {
                Id = _entityKey.Id, //Get this from when you logged in,
                Type = _entityKey.Type, //Get this from when you logged in
            },
            FunctionName = "imrhelloworld", //This should be the name of your Azure Function that you created.           
           // FunctionParameter = new Dictionary<string, object>() { { "inputValue", "Iain" } }, //This is the data that you would want to pass into your function.
            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($"The {result.FunctionName} function took {result.ExecutionTimeMilliseconds} to complete");
            Debug.Log($"Result: {result.FunctionResult.ToString()}");
        }, (PlayFabError error) =>
        {
            Debug.Log($"Opps Something went wrong: {error.GenerateErrorReport()}");
        });
    }

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.