【问题标题】:Python Azure Function http triger from HTML file来自 HTML 文件的 Python Azure 函数 http 触发器
【发布时间】:2020-10-13 08:23:47
【问题描述】:

我按照此链接 How to upload a file in html page, using http trigger in azure functions using python? 上的描述构建了一些 html 文件,该文件能够向基于 python 的 azure 函数发送请求。但是,此解决方案使用了静态 Web 应用程序。

我更喜欢直接从本地 html 文件触发该功能,而不是托管网页。这样做时,我在 Chrome 中收到以下错误:

Access to XMLHttpRequest at 'https://FunctionName.azurewebsites.net/api/function' from origin 'null'
has been blocked by CORS policy: Response to preflight request doesn't pass access control check:
No 'Access-Control-Allow-Origin' header is present on the requested resource.

有没有办法做到这一点?我使用的代码与上面的链接相同。

【问题讨论】:

    标签: azure azure-web-app-service azure-functions


    【解决方案1】:

    您可以尝试禁用带有特定参数的 Chrome 的 CORS 检查,如下所示:

    chrome.exe --args --disable-web-security --user-data-dir --disable-site-isolation-trials
    

    【讨论】:

    • 感谢您的回答。这是唯一可能的解决方案吗?
    • 我猜其他解决方案需要 Web 服务器(本地 Web 服务器、Azure Blob 存储、Functions 等)。
    • 有没有办法直接从 blob 存储上的容器调用 html 文件?这个例子不起作用:build5nines.com/static-website-hosting-in-azure-storage
    • 编辑:实际上,只要我将容器公开,它就可以工作......为什么它在私有时不起作用......
    • 私有容器需要 SAS 令牌。如果您要在 Azure 存储上尝试页面托管,您可以选择 $web 容器中的静态网站托管,如下所示:docs.microsoft.com/en-us/azure/storage/blobs/…
    猜你喜欢
    • 1970-01-01
    • 2021-11-30
    • 1970-01-01
    • 2018-04-02
    • 2021-05-19
    • 2021-01-25
    • 1970-01-01
    • 2020-07-03
    • 1970-01-01
    相关资源
    最近更新 更多