What is the correct way to pass full objects to the Azure Function from the client?
I was able to get it to work using the code below, but you can see that I am doing something funky with the incoming FunctionArgument data to get it to work. It has double braces in it even after narrowing it down to the JObject value. If you know of a better way, let me know.
[FunctionName("CreateOrUpdateGuild")] public static async Task<IActionResult> CreateOrUpdateGuild([HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest req, ILogger log) { log.LogInformation("CreateOrUpdateGuild()"); FunctionExecutionContext<dynamic> context = JsonConvert.DeserializeObject<FunctionExecutionContext<dynamic>>(await req.ReadAsStringAsync()); string guildName = string.Empty; try { string json = ((JObject)context.FunctionArgument)["guild"].ToString(); var guild = JsonConvert.DeserializeObject<Guild>(json.Replace("{ {", "").Replace("}}","")); log.LogInformation("NewGuild() - guildName: {guildName}");
on the client I can use this method. I have my own Guild class and it works fine.
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 = "CreateOrUpdateGuild", FunctionParameter = new Dictionary<string, object>() { { "guild", guild } }, GeneratePlayStreamEvent = false //Set this to true if you would like this call to show up in PlayStream }, (ExecuteFunctionResult result) =>