当我运行 azure HTTP Trigger 功能时,我得到 401 未授权 [英] When I am running azure HTTP Trigger function i am getting 401 unauthorized

查看:12
本文介绍了当我运行 azure HTTP Trigger 功能时,我得到 401 未授权的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试运行 Azure HTTP 触发 Azure 函数,但收到 401 Unauthorized.之前对我来说很好用.

I am trying to run Azure HTTP Trigger Azure Function and I am receiving a 401 Unauthorized. It was working fine for me earlier.

当我在同一个函数应用程序下创建新函数并复制相同的代码时,它也运行良好,但是当我尝试运行我创建的函数时,我得到了与我提到的相同的错误.

When I created the new function under the same Function App and copied the same code then also it is running fine but when I am trying to run my created function then I am getting the same error that I mentioned.

我在流媒体服务中看到以下日志.

I'm seeing the following logs in the streaming service.

2018-07-02T07:09:41 欢迎您,您现在已连接到日志流服务.

2018-07-02T07:09:41 Welcome, you are now connected to log-streaming service.

2018-07-02T07:09:48.893 [信息] 执行 HTTP 请求:{"requestId": "53e54698-c46b-4cb6-9ed0-d042eaf9ec71",方法":发布","uri": "/api/Source/MPAA/false"}

2018-07-02T07:09:48.893 [Info] Executing HTTP request: { "requestId": "53e54698-c46b-4cb6-9ed0-d042eaf9ec71", "method": "POST", "uri": "/api/Source/MPAA/false" }

2018-07-02T07:09:48.893 [信息] 执行的 HTTP 请求:{"requestId": "53e54698-c46b-4cb6-9ed0-d042eaf9ec71",方法":发布","uri": "/api/Source/MPAA/false","authorizationLevel": "匿名",状态":未经授权"}

2018-07-02T07:09:48.893 [Info] Executed HTTP request: { "requestId": "53e54698-c46b-4cb6-9ed0-d042eaf9ec71", "method": "POST", "uri": "/api/Source/MPAA/false", "authorizationLevel": "Anonymous", "status": "Unauthorized" }

推荐答案

这就是我根据上面 Nick 正确提供的原因解决问题的方法.如果您不想每次推送代码时都打开 Azure 函数的 GUI,请执行此操作.

This is how I solved the problem based on the cause correctly provided by Nick above. Do this if you don't want to have to open the Azure Function's GUI every time you push your code.

在函数源代码中:

[FunctionName("YourFunctionName")]
public static async Task<IActionResult> Run(
    [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
    ILogger log){

我要做的就是将默认设置 AuthorizationLevel.Function 更改为 AuthorizationLevel.Anonymous.前者只允许从其他Function应用触发,后者允许你从浏览器触发.

What I had to do was to change the default setting AuthorizationLevel.Function into AuthorizationLevel.Anonymous. The former only allows triggering from other Function apps, the later will let you trigger from the browser.

这篇关于当我运行 azure HTTP Trigger 功能时,我得到 401 未授权的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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