无法在Azure Functions Linux消费计划上编辑CORS

Pro*_*Man 5 azure azure-functions

我已经在Python中实现了Azure功能,该功能仅适用于Azure Linux服务器。使用Visual Studio Code,我设法在本地运行这些功能,并使用邮递员执行了测试,这些请求成功完成了。我还使用Visual Studio Code将功能部署到Azure,并再次使用Postman测试了公共REST API主机,并且该主机正常工作。

问题是通过我的Web应用程序调用了此API,该应用程序返回了CORS错误。我知道这很正常,因为我没有通过Azure面板在CORS中设置允许所有(*)属性。基本上,因为CORS被阻止:

在此处输入图片说明

当我单击时,出现以下警告:

This feature is not supported for Linux apps on a Consumption plan
Run Code Online (Sandbox Code Playgroud)

我试过将标头添加到我的python函数中,例如:

 headers  = {
        "Access-Control-Allow-Origin": "*",
        "Access-Control-Allow-Methods": "GET, POST, OPTIONS"
    }
Run Code Online (Sandbox Code Playgroud)

然后在响应中:

return func.HttpResponse(f"{result}",headers=headers)
Run Code Online (Sandbox Code Playgroud)

但是仍然收到CORS错误。

Saj*_*ran 3

尝试使用Azure CLI启用 CORS ,

az functionapp cors add --allowed-origins
                        [--ids]
                        [--name]
                        [--resource-group]
                        [--slot]
                        [--subscription]
Run Code Online (Sandbox Code Playgroud)