Machine Run Commands - List
The operation to get all the run commands of a non-Azure machine.
GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/runCommands?api-version=2024-07-31-preview
GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/runCommands?$expand={$expand}&api-version=2024-07-31-preview
URI Parameters
Name | In | Required | Type | Description |
---|---|---|---|---|
machine
|
path | True |
string |
The name of the hybrid machine. Regex pattern: |
resource
|
path | True |
string |
The name of the resource group. The name is case insensitive. |
subscription
|
path | True |
string |
The ID of the target subscription. |
api-version
|
query | True |
string |
The API version to use for this operation. |
$expand
|
query |
string |
The expand expression to apply on the operation. |
Responses
Name | Type | Description |
---|---|---|
200 OK |
OK |
|
Other Status Codes |
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
GET all Machine Run Commands
Sample request
GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.HybridCompute/machines/myMachine/runCommands?api-version=2024-07-31-preview
Sample response
{
"value": [
{
"id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.HybridCompute/Machines/myMachine/runcommands/myRunCommand_1",
"name": "myRunCommand_1",
"location": "eastus2",
"type": "Microsoft.HybridCompute/machines/runcommands",
"properties": {
"source": {
"script": "Write-Host Hello World!"
},
"parameters": [
{
"name": "param1",
"value": "value1"
},
{
"name": "param2",
"value": "value2"
}
],
"protectedParameters": [],
"asyncExecution": false,
"runAsUser": "user1",
"timeoutInSeconds": 3600,
"provisioningState": "Succeeded",
"instanceView": {
"executionState": "Succeeded",
"executionMessage": "",
"exitCode": 0,
"output": "Hello World",
"error": "",
"startTime": "2023-06-15T20:48:41.4641785+00:00",
"endTime": "2023-06-15T20:48:41.4641785+00:00"
}
}
},
{
"id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.HybridCompute/Machines/myMachine/runcommands/myRunCommand_2",
"name": "myRunCommand_2",
"location": "eastus2",
"type": "Microsoft.HybridCompute/machines/runcommands",
"properties": {
"source": {
"script": "Get-Process | Where-Object { $_.CPU -gt 10000 }"
},
"parameters": [],
"protectedParameters": [],
"asyncExecution": false,
"runAsUser": "userA",
"timeoutInSeconds": 100,
"provisioningState": "Succeeded",
"instanceView": {
"executionState": "Succeeded",
"executionMessage": "",
"exitCode": 0,
"output": "<some output>",
"error": "",
"startTime": "2023-06-15T20:48:41.4641785+00:00",
"endTime": "2023-06-15T20:48:41.4641785+00:00"
}
}
}
]
}
Definitions
Name | Description |
---|---|
created |
The type of identity that created the resource. |
Error |
The resource management error additional info. |
Error |
The error detail. |
Error |
Error response |
Execution |
Script execution status. |
Extensions |
Instance view status. |
Extensions |
The level code. |
Machine |
Describes a Run Command |
Machine |
The instance view of a machine run command. |
Machine |
Describes the script sources for run command. Use only one of script, scriptUri, commandId. |
Machine |
Describes the Run Commands List Result. |
Run |
Describes the properties of a run command parameter. |
Run |
Contains clientId or objectId (use only one, not both) of a user-assigned managed identity that has access to storage blob used in Run Command. Use an empty RunCommandManagedIdentity object in case of system-assigned identity. Make sure the Azure storage blob exists in case of scriptUri, and managed identity has been given access to blob's container with 'Storage Blob Data Reader' role assignment with scriptUri blob and 'Storage Blob Data Contributor' for Append blobs(outputBlobUri, errorBlobUri). In case of user assigned identity, make sure you add it under VM's identity. For more info on managed identity and Run Command, refer https://aka.ms/ManagedIdentity and https://aka.ms/RunCommandManaged. |
system |
Metadata pertaining to creation and last modification of the resource. |
createdByType
The type of identity that created the resource.
Name | Type | Description |
---|---|---|
Application |
string |
|
Key |
string |
|
ManagedIdentity |
string |
|
User |
string |
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 |
The error additional info. |
|
code |
string |
The error code. |
details |
The error details. |
|
message |
string |
The error message. |
target |
string |
The error target. |
ErrorResponse
Error response
Name | Type | Description |
---|---|---|
error |
The error object. |
ExecutionState
Script execution status.
Name | Type | Description |
---|---|---|
Canceled |
string |
|
Failed |
string |
|
Pending |
string |
|
Running |
string |
|
Succeeded |
string |
|
TimedOut |
string |
|
Unknown |
string |
ExtensionsResourceStatus
Instance view status.
Name | Type | Description |
---|---|---|
code |
string |
The status code. |
displayStatus |
string |
The short localizable label for the status. |
level |
The level code. |
|
message |
string |
The detailed status message, including for alerts and error messages. |
time |
string |
The time of the status. |
ExtensionsStatusLevelTypes
The level code.
Name | Type | Description |
---|---|---|
Error |
string |
|
Info |
string |
|
Warning |
string |
MachineRunCommand
Describes a Run Command
Name | Type | Default value | Description |
---|---|---|---|
id |
string |
Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" |
|
location |
string |
The geo-location where the resource lives |
|
name |
string |
The name of the resource |
|
properties.asyncExecution |
boolean |
False |
Optional. If set to true, provisioning will complete as soon as script starts and will not wait for script to complete. |
properties.errorBlobManagedIdentity |
User-assigned managed identity that has access to errorBlobUri storage blob. Use an empty object in case of system-assigned identity. Make sure managed identity has been given access to blob's container with 'Storage Blob Data Contributor' role assignment. In case of user-assigned identity, make sure you add it under VM's identity. For more info on managed identity and Run Command, refer https://aka.ms/ManagedIdentity and https://aka.ms/RunCommandManaged |
||
properties.errorBlobUri |
string |
Specifies the Azure storage blob where script error stream will be uploaded. Use a SAS URI with read, append, create, write access OR use managed identity to provide the VM access to the blob. Refer errorBlobManagedIdentity parameter. |
|
properties.instanceView |
The machine run command instance view. |
||
properties.outputBlobManagedIdentity |
User-assigned managed identity that has access to outputBlobUri storage blob. Use an empty object in case of system-assigned identity. Make sure managed identity has been given access to blob's container with 'Storage Blob Data Contributor' role assignment. In case of user-assigned identity, make sure you add it under VM's identity. For more info on managed identity and Run Command, refer https://aka.ms/ManagedIdentity and https://aka.ms/RunCommandManaged |
||
properties.outputBlobUri |
string |
Specifies the Azure storage blob where script output stream will be uploaded. Use a SAS URI with read, append, create, write access OR use managed identity to provide the VM access to the blob. Refer outputBlobManagedIdentity parameter. |
|
properties.parameters |
The parameters used by the script. |
||
properties.protectedParameters |
The parameters used by the script. |
||
properties.provisioningState |
string |
The provisioning state, which only appears in the response. |
|
properties.runAsPassword |
string |
Specifies the user account password on the machine when executing the run command. |
|
properties.runAsUser |
string |
Specifies the user account on the machine when executing the run command. |
|
properties.source |
The source of the run command script. |
||
properties.timeoutInSeconds |
integer |
The timeout in seconds to execute the run command. |
|
systemData |
Azure Resource Manager metadata containing createdBy and modifiedBy information. |
||
tags |
object |
Resource tags. |
|
type |
string |
The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" |
MachineRunCommandInstanceView
The instance view of a machine run command.
Name | Type | Description |
---|---|---|
endTime |
string |
Script end time. |
error |
string |
Script error stream. |
executionMessage |
string |
Communicate script configuration errors or execution messages. |
executionState |
Script execution status. |
|
exitCode |
integer |
Exit code returned from script execution. |
output |
string |
Script output stream. |
startTime |
string |
Script start time. |
statuses |
The status information. |
MachineRunCommandScriptSource
Describes the script sources for run command. Use only one of script, scriptUri, commandId.
Name | Type | Description |
---|---|---|
commandId |
string |
Specifies the commandId of predefined built-in script. |
script |
string |
Specifies the script content to be executed on the machine. |
scriptUri |
string |
Specifies the script download location. It can be either SAS URI of an Azure storage blob with read access or public URI. |
scriptUriManagedIdentity |
User-assigned managed identity that has access to scriptUri in case of Azure storage blob. Use an empty object in case of system-assigned identity. Make sure the Azure storage blob exists, and managed identity has been given access to blob's container with 'Storage Blob Data Reader' role assignment. In case of user-assigned identity, make sure you add it under VM's identity. For more info on managed identity and Run Command, refer https://aka.ms/ManagedIdentity and https://aka.ms/RunCommandManaged. |
MachineRunCommandsListResult
Describes the Run Commands List Result.
Name | Type | Description |
---|---|---|
nextLink |
string |
The uri to fetch the next page of run commands. Call ListNext() with this to fetch the next page of run commands. |
value |
The list of run commands |
RunCommandInputParameter
Describes the properties of a run command parameter.
Name | Type | Description |
---|---|---|
name |
string |
The run command parameter name. |
value |
string |
The run command parameter value. |
RunCommandManagedIdentity
Contains clientId or objectId (use only one, not both) of a user-assigned managed identity that has access to storage blob used in Run Command. Use an empty RunCommandManagedIdentity object in case of system-assigned identity. Make sure the Azure storage blob exists in case of scriptUri, and managed identity has been given access to blob's container with 'Storage Blob Data Reader' role assignment with scriptUri blob and 'Storage Blob Data Contributor' for Append blobs(outputBlobUri, errorBlobUri). In case of user assigned identity, make sure you add it under VM's identity. For more info on managed identity and Run Command, refer https://aka.ms/ManagedIdentity and https://aka.ms/RunCommandManaged.
Name | Type | Description |
---|---|---|
clientId |
string |
Client Id (GUID value) of the user-assigned managed identity. ObjectId should not be used if this is provided. |
objectId |
string |
Object Id (GUID value) of the user-assigned managed identity. ClientId should not be used if this is provided. |
systemData
Metadata pertaining to creation and last modification of the resource.
Name | Type | Description |
---|---|---|
createdAt |
string |
The timestamp of resource creation (UTC). |
createdBy |
string |
The identity that created the resource. |
createdByType |
The type of identity that created the resource. |
|
lastModifiedAt |
string |
The timestamp of resource last modification (UTC) |
lastModifiedBy |
string |
The identity that last modified the resource. |
lastModifiedByType |
The type of identity that last modified the resource. |