“运行命令操作系统类型‘Linux’”与目标操作系统 Windows 不匹配。”使用 python 发送 API 请求以从 Powershell 脚本运行命令
我正在使用 python requests 库发送 api 请求。
代码如下;
subscription_id =os.environ['AZURE_SUBSCRIPTION_ID']
source="https://management.azure.com"
token_context=access_token()
tokens=json.loads(token_context.text)
token=tokens['access_token']
headers = {'Authorization': 'Bearer ' +token,
'Content-Type': 'application/json'}
data={
"commandId": "RunShellScript",
"script":["urlAdresstoScriptStoredinBlobStorage"]}
api="{}/subscriptions/{}/resourceGroups/{}/providers/Microsoft.Compute/virtualMachines/{}/runCommand?api-version=2021-11-01".format(
source,subscription_id,vmRG,vmName)
response = requests.post(api,json=data,headers=headers)
return response
我得到的错误:
"error": {
"code": "Conflict",
"message": "Run command OS type 'Linux' does not match the target OS Windows."
}
错误的根源是什么以及如何解决它?
任何建议表示赞赏, 谢谢。
I am sending api request using python requests library.
The code as follows;
subscription_id =os.environ['AZURE_SUBSCRIPTION_ID']
source="https://management.azure.com"
token_context=access_token()
tokens=json.loads(token_context.text)
token=tokens['access_token']
headers = {'Authorization': 'Bearer ' +token,
'Content-Type': 'application/json'}
data={
"commandId": "RunShellScript",
"script":["urlAdresstoScriptStoredinBlobStorage"]}
api="{}/subscriptions/{}/resourceGroups/{}/providers/Microsoft.Compute/virtualMachines/{}/runCommand?api-version=2021-11-01".format(
source,subscription_id,vmRG,vmName)
response = requests.post(api,json=data,headers=headers)
return response
The Error I got:
"error": {
"code": "Conflict",
"message": "Run command OS type 'Linux' does not match the target OS Windows."
}
What could be the source of the error and how to solve it?
Any suggestion is appreciated,
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论