javascript - async function in an Azure Function - Stack Overflow

I am getting an error with this javascript function definition in Azure. I am defining this within an A

I am getting an error with this javascript function definition in Azure. I am defining this within an Azure function for use by the exported function.

async function getData() {
    var data = await postRequest();
    return data;
};

Below is the error I am getting in the console. Is async await syntax not supported in Azure functions?

If yes, how would I implement an async call (such as a REST call made with node-rest-client).

2018-01-05T10:50:55.448 Function started (Id=a4995e6f-141a-46bb-becf-
468f49f7505d)
2018-01-05T10:50:55.565 Exception while executing function: 
Functions.MyFunctionName. mscorlib: One or more errors occurred. 
D:\home\site\wwwroot\MyFunctionName\index.js:90
async function getData() {
      ^^^^^^^^

SyntaxError: Unexpected token function
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._pile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at eval (eval at pileFunc (D:\Program Files (x86)\SiteExtensions\Functions\1.0.11388\bin\edge\double_edge.js:34:28), <anonymous>:1:80).
2018-01-05T10:50:55.673 Function pleted (Failure, Id=a4995e6f-141a-46bb-becf-468f49f7505d, Duration=221ms)

I am getting an error with this javascript function definition in Azure. I am defining this within an Azure function for use by the exported function.

async function getData() {
    var data = await postRequest();
    return data;
};

Below is the error I am getting in the console. Is async await syntax not supported in Azure functions?

If yes, how would I implement an async call (such as a REST call made with node-rest-client).

2018-01-05T10:50:55.448 Function started (Id=a4995e6f-141a-46bb-becf-
468f49f7505d)
2018-01-05T10:50:55.565 Exception while executing function: 
Functions.MyFunctionName. mscorlib: One or more errors occurred. 
D:\home\site\wwwroot\MyFunctionName\index.js:90
async function getData() {
      ^^^^^^^^

SyntaxError: Unexpected token function
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._pile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at eval (eval at pileFunc (D:\Program Files (x86)\SiteExtensions\Functions\1.0.11388\bin\edge\double_edge.js:34:28), <anonymous>:1:80).
2018-01-05T10:50:55.673 Function pleted (Failure, Id=a4995e6f-141a-46bb-becf-468f49f7505d, Duration=221ms)
Share Improve this question edited Jan 23, 2019 at 15:52 RobC 25.1k21 gold badges84 silver badges86 bronze badges asked Jan 5, 2018 at 11:07 Pradipe YoggiPradipe Yoggi 631 silver badge4 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

For javascript async syntax support you need to install the latest version of the cli along side with node v8.x

npm i -g azure-functions-core-tools@core

Additionally you'll need to enable the beta runtime on azure so it also works when deploying.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745062642a4609059.html

相关推荐

  • javascript - async function in an Azure Function - Stack Overflow

    I am getting an error with this javascript function definition in Azure. I am defining this within an A

    19小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信