【Azure Function】Function App门户上的Test/Run返回错误:Failed to fetch

简介: Running your function in portal requires the app to explicitly accept requests from https://portal.azure.cn. This is known as cross-origin resource sharing (CORS).Configure CORS to add https://portal.azure.cn to allowed origins.

问题描述

在Azure Function的Code + Test页面上,点击 Test/Run 按钮无法成功。

 

错误信息:

Error: {"message":"Failed to fetch","stack":"TypeError: Failed to fetch\n    at https://portal.azure.cn/Content/Dynamic/cgORG6hTIVe1.js:113:23007\n    at https://portal.azure.cn/Content/Dynamic/cgORG6hTIVe1.js:113:23228\n    at Ge (https://portal.azure.cn/Content/Dynamic/cgORG6hTIVe1.js:113:7620)\n    at https://portal.azure.cn/Content/Dynamic/cgORG6hTIVe1.js:113:9566\n    at Array.forEach (<anonymous>)\n    at https://portal.azure.cn/Content/Dynamic/cgORG6hTIVe1.js:113:9554\n    at Object.Ge (https://portal.azure.cn/Content/Dynamic/cgORG6hTIVe1.js:113:7620)\n    at M (https://portal.azure.cn/Content/Dynamic/cgORG6hTIVe1.js:59:2016)\n    at P (https://portal.azure.cn/Content/Dynamic/cgORG6hTIVe1.js:59:1847)","isError":true}

错误截图:

 

 

问题解答

从截图和错误信息来看,是因为无法获取到js文件所以报错failed to fetch at https://portal.azure.cn/content/dynamic/sdlblohddxjx.js。并且也显示了CORS 警告消息。

Running your function in portal requires the app to explicitly accept requests from https://portal.azure.cn. This is known as cross-origin resource sharing (CORS).Configure CORS to add https://portal.azure.cn to allowed origins.

所以根据信息提示,进入 API --> CORS 页面,添加 Allowed Origins为 https://portal.azure.cn 即可解决此问题。

 

参考资料

添加 CORS 功能 : https://docs.azure.cn/zh-cn/app-service/app-service-web-tutorial-rest-api#add-cors-functionality

 

 


当在复杂的环境中面临问题,格物之道需:浊而静之徐清,安以动之徐生。 云中,恰是如此!

相关文章
|
2月前
|
C#
【Azure Function】Function App出现System.IO.FileNotFoundException异常
Exception while executing function: xxxxxxx,The type initializer for 'xxxxxx.Storage.Adls2.StoreDataLakeGen2Reading' threw an exception. Could not load file or assembly 'Microsoft.Extensions.Configuration, Version=9.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the
123 64
|
2月前
|
JSON C# 数据格式
【Azure Function】C#独立工作模式下参数类型 ServiceBusReceivedMessage 无法正常工作
Cannot convert input parameter 'message' to type 'Azure.Messaging.ServiceBus.ServiceBusReceivedMessage' from type 'System.String'.
121 73
|
3月前
|
网络协议 容器
【Container App】部署Contianer App 遇见 Failed to deploy new revision: The Ingress's TargetPort or ExposedPort must be specified for TCP apps.
Failed to deploy new revision: The Ingress's TargetPort or ExposedPort must be specified for TCP apps.
81 27
|
2月前
|
Java Windows
【Azure Function】部署Java Function失败:报错deploy [ERROR] Status code 401和警告 'China North 3' may not be a valid region
1:deploy [ERROR] Status code 401, (empty body). 2: China North 3 may not be a valid region,please refer to https://aka.ms/maven_function_configuration#supported-regions for values. 3:  <azure.functions.maven.plugin.version>1.36.0</azure.functions.maven.plugin.version>
53 11
|
5月前
|
Linux Python
【Azure Function】Python Function部署到Azure后报错No module named '_cffi_backend'
ERROR: Error: No module named '_cffi_backend', Cannot find module. Please check the requirements.txt file for the missing module.
133 2
|
4月前
|
中间件 Docker Python
【Azure Function】FTP上传了Python Function文件后,无法在门户页面加载函数的问题
通过FTP上传Python Function至Azure云后,出现函数列表无法加载的问题。经排查,发现是由于`requirements.txt`中的依赖包未被正确安装。解决方法为:在本地安装依赖包到`.python_packages/lib/site-packages`目录,再将该目录内容上传至云上的`wwwroot`目录,并重启应用。最终成功加载函数列表。
|
7月前
【Azure Function】Azure Function中的Timer Trigger无法自动触发问题
【Azure Function】Azure Function中的Timer Trigger无法自动触发问题
|
7月前
|
Python
【Azure Function】发布 Python Function 到 Azure 成功,但是无法显示Function列表
【Azure Function】发布 Python Function 到 Azure 成功,但是无法显示Function列表
|
5月前
|
JavaScript
箭头函数与普通函数(function)的区别
箭头函数是ES6引入的新特性,与传统函数相比,它有更简洁的语法,且没有自己的this、arguments、super或new.target绑定,而是继承自外层作用域。箭头函数不适用于构造函数,不能使用new关键字调用。

热门文章

最新文章