Share via


Bare Metal Machines - Run Read Commands

Run read-only commands against a bare metal machine.
Run one or more read-only commands on the provided bare metal machine. The URL to storage account with the command execution results and the command exit code can be retrieved from the operation status API once available.

POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkCloud/bareMetalMachines/{bareMetalMachineName}/runReadCommands?api-version=2025-02-01

URI Parameters

Name In Required Type Description
bareMetalMachineName
path True

string

pattern: ^([a-zA-Z0-9][a-zA-Z0-9]{0,62}[a-zA-Z0-9])$

The name of the bare metal machine.

resourceGroupName
path True

string

minLength: 1
maxLength: 90

The name of the resource group. The name is case insensitive.

subscriptionId
path True

string (uuid)

The ID of the target subscription. The value must be an UUID.

api-version
query True

string

minLength: 1

The API version to use for this operation.

Request Body

Name Required Type Description
commands True

BareMetalMachineCommandSpecification[]

The list of read-only commands to be executed directly against the target machine.

limitTimeSeconds True

integer (int64)

minimum: 60
maximum: 14400

The maximum time the commands are allowed to run. If the execution time exceeds the maximum, the script will be stopped, any output produced until then will be captured, and the exit code matching a timeout will be returned (252).

Responses

Name Type Description
202 Accepted

The action has been initiated for the resource.

Headers

Location: string

Other Status Codes

ErrorResponse

Error response describing why the operation failed.

Security

azure_auth

Azure Active Directory OAuth2 Flow.

Type: oauth2
Flow: implicit
Authorization URL: https://login.microsoftonline.com/common/oauth2/authorize

Scopes

Name Description
user_impersonation impersonate your user account

Examples

Run and retrieve output from read only commands on bare metal machine.

Sample request

POST https://management.azure.com/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.NetworkCloud/bareMetalMachines/bareMetalMachineName/runReadCommands?api-version=2025-02-01

{
  "commands": [
    {
      "command": "kubectl get",
      "arguments": [
        "pods",
        "-A"
      ]
    },
    {
      "command": "ping",
      "arguments": [
        "192.168.0.99",
        "-c",
        "3"
      ]
    }
  ],
  "limitTimeSeconds": 60
}

Sample response

Location: https://management.azure.com/subscriptions/123e4567-e89b-12d3-a456-426655440000/providers/Microsoft.NetworkCloud/locations/location/operationStatuses/operationId?api-version=2025-02-01

Definitions

Name Description
BareMetalMachineCommandSpecification

BareMetalMachineCommandSpecification represents the command and optional arguments to exercise against the bare metal machine.

BareMetalMachineRunReadCommandsParameters

BareMetalMachineRunReadCommandsParameters represents the body of request containing list of read-only commands to run on the bare metal machine.

ErrorAdditionalInfo

The resource management error additional info.

ErrorDetail

The error detail.

ErrorResponse

Error response

BareMetalMachineCommandSpecification

BareMetalMachineCommandSpecification represents the command and optional arguments to exercise against the bare metal machine.

Name Type Description
arguments

string[]

The list of string arguments that will be passed to the script in order as separate arguments.

command

string

The command to execute against the bare metal machine.

BareMetalMachineRunReadCommandsParameters

BareMetalMachineRunReadCommandsParameters represents the body of request containing list of read-only commands to run on the bare metal machine.

Name Type Description
commands

BareMetalMachineCommandSpecification[]

The list of read-only commands to be executed directly against the target machine.

limitTimeSeconds

integer (int64)

minimum: 60
maximum: 14400

The maximum time the commands are allowed to run. If the execution time exceeds the maximum, the script will be stopped, any output produced until then will be captured, and the exit code matching a timeout will be returned (252).

ErrorAdditionalInfo

The resource management error additional info.

Name Type Description
info

object

The additional info.

type

string

The additional info type.

ErrorDetail

The error detail.

Name Type Description
additionalInfo

ErrorAdditionalInfo[]

The error additional info.

code

string

The error code.

details

ErrorDetail[]

The error details.

message

string

The error message.

target

string

The error target.

ErrorResponse

Error response

Name Type Description
error

ErrorDetail

The error object.