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

问题描述

在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

 

 

posted @   路边两盏灯  阅读(5)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
历史上的今天:
2023-02-13 【Azure 事件中心】通过 az rest --method get 如何获得Event Hub Entity 级的统计指标
点击右上角即可分享
微信分享提示