Azure Function POST始终返回403. [英] Azure Function POST always return 403.

查看:103
本文介绍了Azure Function POST始终返回403.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好.我是天蓝色函数的新手,但发现了一个我无法解决的小问题.我在互联网上搜索,但没有找到如何执行此操作的示例...

Hello. I am new in azure functions but I found one little big problem which I am not able to solve. I search the internet but I didn't find any example how to do this...

我的情况很简单:

1.一项启用了 2.用AAD登录.

3.从SharePoint Online内容Web部件调用的我的JS方法

3. My JS method which is called from SharePoint Online content webpart

    var serviceURL = "https://xxxxxxxxx.azurewebsites.net/api/Function1";

    $.ajax({
        url: serviceURL,
        type: "POST",
        xhrFields: {
            withCredentials: true
        },
        crossDomain: true,
        success: function (data) {
            alert("Success: " + data);
        },
        error: function (ex) {
            alert("Failure getting user token");
        }
    });

当我将POST更改为GET时,一切正常....当我禁用 使用AAD 的App Service身份验证不起作用.
如何更改我的JS代码,POST将起作用.

When I change the POST to GET everything works fine....When I disabled App Service Authentication everything is working...But POST whit enable App Service Authentication with AAD is not working.
How to change my JS code the POST will work please.

谢谢你

推荐答案

配置了CORS后,您看到的403应该可以解决.您将必须将原始域添加到Function App中的CORS条目中. (例如:http://www.example.com,但您的域)

The 403 that you are seeing should resolve once you have CORS configured. You will have to add the origin domain to the CORS entries in your Function App. (Ex: http://www.example.com, but your domain)


此外,我相信您还会遇到另一个问题,因为Azure Functions的响应中缺少"Access-Control-Allow-Credentials"标头.

Also, I believe you should be seeing another problem due to the absence of the 'Access-Control-Allow-Credentials' header in the response from Azure Functions.

有一个开放的 问题,以及

There is an open issue for this and also a feature request on UserVoice. The GitHub issue also talks about a workaround which involves removing all the CORS entries from the portal and adding this headers yourself.

关于该问题的评论展示了JavaScript函数的解决方案, comment 指的是您必须用于C#函数的.NET API.

This comment on that issue showcases the solution for JavaScript functions and this comment refers to .NET APIs that you will have to use for C# functions.


这篇关于Azure Function POST始终返回403.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆