简体   繁体   English

403 禁止错误:运行 API 请求命令时

[英]403 Forbidden Error: While running the API request command

I'm able to update/create the function key using the API as per document.我可以根据文档使用 API 更新/创建 function 密钥。 https://learn.microsoft.com/en-us/rest/api/appservice/web-apps/create-or-update-function-secret https://learn.microsoft.com/en-us/rest/api/appservice/web-apps/create-or-update-function-secret

My main aim is to update the function key every hour so I'm creating a http trigger (with the above api inside it) and scheduling the trigger.我的主要目标是每小时更新一次 function 密钥,因此我正在创建一个 http 触发器(其中包含上面的 api)并安排触发器。

  1. For testing purpose I stored the url in one parameter.出于测试目的,我将 url 存储在一个参数中。 URL: 'https://management.azure.com/subscriptions/xyz1/resourceGroups/xyz2/providers/Microsoft.Web/sites/func_appname/functions/func_name/keys/poc_testing1?api-version=2021-02-01{"Properties":{"Name": "poc_testing1","Value": "asdsda"}}' URL: 'https://management.azure.com/subscriptions/xyz1/resourceGroups/xyz2/providers/Microsoft.Web/sites/func_appname/functions/func_name/keys/poc_testing1?api-version=2021-02-01{"属性”:{“名称”:“poc_testing1”,“值”:“asdsda”}}'

Note: Value here is updating via random gen lib of python注意:此处的值是通过 python 的随机生成库更新的

  1. Generated a bearer token using the service principal (which I'm already using to connect my stg acc) storing it in auth_token header_auth= {'Authorization': 'Bearer ' + auth_token }使用服务主体(我已经用它来连接我的 stg acc)生成了一个承载令牌,将其存储在 auth_token header_auth= {'Authorization': 'Bearer ' + auth_token }

  2. Now running the below command in python import requests requests.post(url, headers=header_auth) I'm getting 403 forbidden error现在在 python import requests.post(url, headers=header_auth) 中运行以下命令我收到 403 forbidden 错误

I'm thinking that it is not because of the bearer token, Did google the error and it is with the IP address.我在想这不是因为不记名令牌,是否用谷歌搜索错误,它与 IP 地址有关。 Can someone help me out here有人可以帮我吗

  1. Till now I referred the doc from MSFT.直到现在我都提到了 MSFT 的文档。 https://learn.microsoft.com/en-us/rest/api/appservice/web-apps/create-or-update-function-secret https://learn.microsoft.com/en-us/rest/api/appservice/web-apps/create-or-update-function-secret

  2. I was able to create new function key.我能够创建新的 function 密钥。

  3. I'm trying to do the same using python for which I performed the above steps.我正在尝试使用我执行上述步骤的 python 做同样的事情。

  4. Currently ran the above issue steps in my local Visual studio and tried az cli as well but same 403 error.目前在我的本地 Visual Studio 中运行上述问题步骤并尝试了 az cli,但同样出现 403 错误。

Why do you want to update the function key every hour?为什么要每小时更新一次 function 密钥?

If you aim to increased security use AzureAD Auth/OAuth2 rather than the function key.如果您的目标是提高安全性,请使用 AzureAD Auth/OAuth2 而不是 function 密钥。

Regarding the 403 error, please ensure you have assigned proper permissions to the service principal which allow the service principal to modify the azure function.关于 403 错误,请确保您已为服务主体分配适当的权限,允许服务主体修改 azure function。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 访问 Google Chrome 时出现 403 禁止错误 Web 商店 API - Getting 403 Forbidden Error While Accessing Google Chrome Web Store API 与 Firebase 安装服务器通信时出错 API - 403 Forbidden - Error when communicating with the Firebase Installations server API - 403 Forbidden 通过 python 访问 API 得到一个奇怪的错误 403 禁止 - Getting a strange error 403 forbidden for accessing an API through python Gitlab v4 api 403 project.variables.list 禁止错误(get_all=True) - Gitlab v4 api 403 forbidden error for project.variables.list(get_all=True) 403 文件上传时收到禁止的错误 - 403 Forbidden error is received on file upload botocore.exceptions.ClientError:调用 HeadObject 操作时发生错误 (403):在 AWS SageMaker 中使用本地模式时禁止 - botocore.exceptions.ClientError: An error occurred (403) when calling the HeadObject operation: Forbidden while using local mode in AWS SageMaker 打开我的 Cloud Run 服务的 URL 时出现 403“错误:禁止” - 403 "Error: Forbidden" when opening the URL of my Cloud Run service 尝试创建子用户时 sendgrid 错误“403 访问被禁止” - sendgrid error "403 access forbidden" when trying to create sub user AWS EMR jupyter 错误 403 Forbidden (Workspace is not attached to cluster) - AWS EMR jupyter error 403 Forbidden (Workspace is not attached to cluster) 无法使用 HTTP 在本地测试 Sendgrid 错误 403:禁止 - Unable to test Sendgrid locally with HTTP Error 403: Forbidden
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM