I am new to Azure functions, because I have to import external library in my Playfab's CloudScript, and this is the way I can do. So I have some basic question about Azure functions, here is my scene:
1. My game backend send an ExecuteCloudScript request to Playfab, which calls an Azure function deployed.
2. This Azure function I called it "CreateOrderNo", and it makes another http request(use external library) which will return an trade order number and an QRcode after about 200ms. 3. My game backend received this order number and an QRcode, and my game backend begins to query the trade state on this order number through another Azure function called "Notify". 4. Finally, my game backend received the order state like success or failed, and do something else.
Now I have created these two Azure functions, but I don't know whether it is the best way to code, for example, I remove the await keywork in my Azure function and it warns me that this async function doesn't have await operater, and it will run in sync way.
Here is my questions:
1. It seems that this Azure function will be low efficient?
2. or it cannot handle the second request until my first trade number(first request) returns?
3. I am not familliar with concurrency, and I thought I should not worry about these in Azure function , for example, I just make a sync http request in my Azure function and it will be managed by Azure or someone else? But it seems not, so I have to know is it right to call http request in Azure function. here is my code of CreateOrderNo:
public static class CreateOrderNo { [FunctionName("CreateOrderNo")] public static async Task<IActionResult> Run( [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req, ILogger log) { log.LogInformation("C# HTTP trigger function processed a CreateOrderNo."); string steamid = req.Query["steamid"]; string amount = req.Query["amount"]; string subject = req.Query["subject"]; try { // 1. create IAopClient instance IAopClient client = new DefaultAopClient( Config.Gatewayurl, Config.AppId, Config.PrivateKey, "json", "1.0", "RSA2", Config.AlipayPublicKey, "utf-8", false); // 2. create request object AlipayTradePrecreateRequest request = GetRequest(null, 1, "abc"); // 3. execute request and wait for response AlipayTradePrecreateResponse response = client.Execute(request); // client.Execute(request); if (!response.IsError) { Console.WriteLine("success。" + response.QrCode); } else { Console.WriteLine("failed:" + response.Msg + "," + response.SubMsg); } log.LogInformation("response.Body:" + response.Body); log.LogInformation("response.OutTradeNo:" + response.OutTradeNo); log.LogInformation("response.QrCode:" + response.QrCode); var result = new AopDictionary(); result.Add("out_trade_no", response.OutTradeNo); result.Add("qr_code", response.QrCode); log.LogInformation("CreateOrderNo over."); var json_result = JsonConvert.SerializeObject(result); return new OkObjectResult(json_result); } catch (Exception e) { Console.WriteLine("call failed:" + e.Message); throw e; } } Thanks for help.