Dear Team,
Do you know any way to execute the Azure function directly from Unity client (don't use automation rules in Playfab Manager) and pass the parameters such as an email and password to Azure function as inputs?
Thank you so much!
Dear Team,
Do you know any way to execute the Azure function directly from Unity client (don't use automation rules in Playfab Manager) and pass the parameters such as an email and password to Azure function as inputs?
Thank you so much!
This is the solution from Sarah Zhang. Thank you so much!!!
Unity clients can directly send a post request to execute the Azure Functions. You can send a POST request using UnityWebRequest.
Azure Function:
[FunctionName("HttpTriggerCSharp")] public static async Task<dynamic> Run([HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest req, ILogger log) { log.LogInformation("C# HTTP trigger function processed a request."); // do the verifiction and resetting password here return new OkObjectResult("Please pass a name on the query string or in the request body"); } }
Unity code:
using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Networking; public class confirmURL : MonoBehaviour { public void OnClickButton() { StartCoroutine(Post()); } IEnumerator Post() { WWWForm form = new WWWForm(); //add fields here form.AddField("name", "someone"); //Use your Azure Function URL here UnityWebRequest webRequest = UnityWebRequest.Post("http://xxxxxxxxxxxxx/api/HttpTriggerCSharp", form); yield return webRequest.SendWebRequest(); if (webRequest.isHttpError || webRequest.isNetworkError) Debug.Log(webRequest.error); else { Debug.Log(webRequest.downloadHandler.text); } } }
3 People are following this question.