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 }; } } }
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>
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?
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()}"); }); }
9 People are following this question.