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

查看:162
本文介绍了当我运行azure HTTP触发功能时,我得到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.

当我在相同的Function App下创建新函数并复制相同的代码时,它也运行良好,但是当我尝试运行自己创建的函数时,却遇到了我提到的相同错误.

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 [Info]执行HTTP请求:{ "requestId":"53e54698-c46b-4cb6-9ed0-d042eaf9ec71", "method":"POST", "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 [Info]执行的HTTP请求:{ "requestId":"53e54698-c46b-4cb6-9ed0-d042eaf9ec71", "method":"POST", "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 Function的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.前者仅允许从其他Funtion应用触发,而后者则允许您从浏览器触发.

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

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

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