【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

 

 


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

目录
打赏
0
7
7
0
203
分享
相关文章
【Azure Storage Account】利用App Service作为反向代理后续 ---- 隐藏 SAS Token
本文介绍了如何通过App Service作为反向代理,将SAS Token追加到请求URL中,以避免直接在代码或配置文件中存储SAS Token带来的安全性和维护问题。具体步骤包括修改App Service的web.config Rewrite规则,将SAS Token添加到转发的URL中;并在.NET SDK中仅使用不包含SAS Token的Uri进行Blob操作。这样既提高了安全性,也简化了SAS Token的管理。
39 16
【Azure App Service】App Service 是否支持HostName SNI 证书?
App Service 支持 HostName SNI 证书。为自定义域名添加 SSL 证书时,可以选择 SNI SSL 和基于 IP 的 SSL。SNI SSL 允许多个 TLS/SSL 证书保护同一 IP 地址上的多个域,适用于大多数现代浏览器。配置方法是在添加自定义域名后,点击 Add binding 配置 SNI SSL。参考文档:[Azure 官方文档](https://docs.azure.cn/zh-cn/app-service/configure-ssl-bindings#add-the-binding)。
【Azure Storage Account】利用App Service作为反向代理, 并使用.NET Storage Account SDK实现上传/下载操作
本文介绍了如何在Azure上使用App Service作为反向代理,以自定义域名访问Storage Account。主要内容包括: 1. **设置反向代理**:通过配置`applicationhost.xdt`和`web.config`文件,启用IIS代理功能并设置重写规则。 2. **验证访问**:测试原生URL和自定义域名的访问效果,确保两者均可正常访问Storage Account。 3. **.NET SDK连接**:使用共享访问签名(SAS URL)初始化BlobServiceClient对象,实现通过自定义域名访问存储服务。
【Azure Function】FTP上传了Python Function文件后,无法在门户页面加载函数的问题
通过FTP上传Python Function至Azure云后,出现函数列表无法加载的问题。经排查,发现是由于`requirements.txt`中的依赖包未被正确安装。解决方法为:在本地安装依赖包到`.python_packages/lib/site-packages`目录,再将该目录内容上传至云上的`wwwroot`目录,并重启应用。最终成功加载函数列表。
箭头函数与普通函数(function)的区别
箭头函数是ES6引入的新特性,与传统函数相比,它有更简洁的语法,且没有自己的this、arguments、super或new.target绑定,而是继承自外层作用域。箭头函数不适用于构造函数,不能使用new关键字调用。
详解Wireshark LUA插件函数:function p_myproto.dissector(buffer, pinfo, tree)
在 Wireshark 中,LUA 插件通过 `function p_myproto.dissector(buffer, pinfo, tree)` 扩展协议解析能力,解析自定义应用层协议。参数 `buffer` 是 `PacketBuffer` 类型,表示原始数据包内容;`pinfo` 是 `ProtoInfo` 类型,包含数据包元信息(如 IP 地址、协议类型等);`tree` 是
224 1
箭头函数与普通函数(function)的区别
箭头函数是ES6引入的新语法,相比传统函数表达式更简洁,且没有自己的this、arguments、super或new.target绑定,而是继承自外层作用域。这使得箭头函数在处理回调和闭包时更加灵活方便。
|
5月前
|
函数对象包装器function和bind机制
函数对象包装器function和bind机制
38 0
|
7月前
【Azure Durable Function】PowerShell Activity 函数遇见 Newtonsoft.Json.JsonReaderException: The reader's MaxDepth of 64 has been exceeded.
【Azure Durable Function】PowerShell Activity 函数遇见 Newtonsoft.Json.JsonReaderException: The reader's MaxDepth of 64 has been exceeded.
【Azure Function App】如何修改Azure函数应用的默认页面呢?
【Azure Function App】如何修改Azure函数应用的默认页面呢?

热门文章

最新文章

AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等