Azure API运行命令-接受202响应 [英] Azure API Run Command - Accepted 202 response
问题描述
我正在尝试使用Microsoft Azure Rest API运行命令:
I am trying to use the Microsoft Azure Rest API Run Command:
https://docs .microsoft.com/en-us/rest/api/compute/virtual%20machines%20run%20commands/runcommand
我最终想传递一个相当复杂的PowerShell脚本,但是我正在尝试一个简单的"ipconfig"命令来测试连接,但是除了HTTP 202响应外,我什么也得不到,该响应不返回json响应数据(根据API) ).
I eventually want to pass a fairly complex PowerShell script but I am trying a simple "ipconfig" command to test the connection but I cannot get anything but a HTTP 202 response which returns no json response data (this is as per the API).
登录和OAuth步骤正常工作,我可以成功获取需要相同授权范围的VM和其他服务管理数据.
The login and OAuth steps work correctly and I can successfully GET VM and other service management data which require the same authorization scope.
有没有人成功使用过此API,以及为什么我只能得到202响应的任何想法?
Has anyone successfully used this API and any ideas why I am only getting a 202 response?
推荐答案
这很正常,当得到202
响应时,您需要调用另一个api来检查结果.
It is normal, when got 202
response, you need to call another api to check the result.
在您的情况下,您将获得如下所示的响应标头,只需调用location
中的api(还需要授权承载令牌)即可.
In your case, you will get a response header like below, just call the api in the location
(also need the Authorization Bearer token).
我在邮递员中测试了它,效果很好.
I test it in the postman, it works fine.
有关更多详细信息,您可以参考此文档-跟踪异步Azure操作,并查看此
For more details, you could refer to this doc - Track asynchronous Azure operations, and see this sample.
这篇关于Azure API运行命令-接受202响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!