你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

Virtual Machine Run Commands - Get

获取位置中订阅的特定运行命令。

GET https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/runCommands/{commandId}?api-version=2024-07-01

URI 参数

名称 必需 类型 说明
commandId
path True

string

命令 ID。

location
path True

string

查询运行命令的位置。

正则表达式模式: ^[-\w\._]+$

subscriptionId
path True

string

唯一标识 azure 订阅Microsoft的订阅凭据。 订阅 ID 构成了每个服务调用的 URI 的一部分。

api-version
query True

string

客户端 API 版本。

响应

名称 类型 说明
200 OK

RunCommandDocument

还行

Media Types: "application/json", "text/json"

安全性

azure_auth

Azure Active Directory OAuth2 Flow

类型: oauth2
流向: implicit
授权 URL: https://login.microsoftonline.com/common/oauth2/authorize

作用域

名称 说明
user_impersonation 模拟用户帐户

示例

VirtualMachineRunCommandGet

示例请求

GET https://management.azure.com/subscriptions/24fb23e3-6ba3-41f0-9b6e-e41131d5d61e/providers/Microsoft.Compute/locations/SoutheastAsia/runCommands/RunPowerShellScript?api-version=2024-07-01

示例响应

{
  "script": [
    "param(",
    "    [string]$arg1,",
    "    [string]$arg2",
    ")",
    "Write-Host This is a sample script with parameters $arg1 $arg2"
  ],
  "parameters": [
    {
      "name": "arg1",
      "type": "string",
      "defaultValue": "value1"
    },
    {
      "name": "arg2",
      "type": "string",
      "defaultValue": "value2"
    }
  ],
  "$schema": "http://schema.management.azure.com/schemas/2016-11-17/runcommands.json",
  "id": "RunPowerShellScript",
  "osType": "Windows",
  "label": "Executes a PowerShell script",
  "description": "Custom multiline PowerShell script should be defined in script property. Optional parameters can be set in parameters property."
}

定义

名称 说明
OperatingSystemTypes

操作系统类型。

RunCommandDocument

描述 Run Command 的属性。

RunCommandParameterDefinition

描述 run 命令参数的属性。

OperatingSystemTypes

操作系统类型。

名称 类型 说明
Linux

string

Windows

string

RunCommandDocument

描述 Run Command 的属性。

名称 类型 说明
$schema

string

VM 运行命令架构。

description

string

VM 运行命令说明。

id

string

VM 运行命令 ID。

label

string

VM 运行命令标签。

osType

OperatingSystemTypes

操作系统类型。

parameters

RunCommandParameterDefinition[]

脚本使用的参数。

script

string[]

要执行的脚本。

RunCommandParameterDefinition

描述 run 命令参数的属性。

名称 类型 默认值 说明
defaultValue

string

run 命令参数默认值。

name

string

run 命令参数名称。

required

boolean

False

所需的 run 命令参数。

type

string

run 命令参数类型。