{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/microsoft-azure-arc/json-schema/microsoft-azure-arc-machine-run-command-schema.json",
  "title": "MachineRunCommand",
  "description": "Describes a Run Command",
  "x-generated": "2026-11-12",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/microsoft-azure-arc-machineruncommands-api-openapi.yml#/components/schemas/MachineRunCommand",
  "type": "object",
  "properties": {
    "properties": {
      "$ref": "#/$defs/MachineRunCommandProperties",
      "description": "Describes Run Command Properties",
      "x-ms-client-flatten": true
    }
  },
  "allOf": [
    {
      "$ref": "#/$defs/TrackedResource"
    }
  ],
  "$defs": {
    "ExecutionState": {
      "type": "string",
      "description": "Script execution status.",
      "enum": [
        "Unknown",
        "Pending",
        "Running",
        "Failed",
        "Succeeded",
        "TimedOut",
        "Canceled"
      ],
      "x-ms-enum": {
        "name": "ExecutionState",
        "modelAsString": true,
        "values": [
          {
            "name": "Unknown",
            "value": "Unknown",
            "description": "Unknown"
          },
          {
            "name": "Pending",
            "value": "Pending",
            "description": "Pending"
          },
          {
            "name": "Running",
            "value": "Running",
            "description": "Running"
          },
          {
            "name": "Failed",
            "value": "Failed",
            "description": "Failed"
          },
          {
            "name": "Succeeded",
            "value": "Succeeded",
            "description": "Succeeded"
          },
          {
            "name": "TimedOut",
            "value": "TimedOut",
            "description": "TimedOut"
          },
          {
            "name": "Canceled",
            "value": "Canceled",
            "description": "Canceled"
          }
        ]
      }
    },
    "ExtensionsResourceStatus": {
      "type": "object",
      "description": "Instance view status.",
      "properties": {
        "code": {
          "type": "string",
          "description": "The status code."
        },
        "level": {
          "$ref": "#/$defs/ExtensionsStatusLevelTypes",
          "description": "The level code."
        },
        "displayStatus": {
          "type": "string",
          "description": "The short localizable label for the status."
        },
        "message": {
          "type": "string",
          "description": "The detailed status message, including for alerts and error messages."
        },
        "time": {
          "type": "string",
          "format": "date-time",
          "description": "The time of the status."
        }
      }
    },
    "ExtensionsStatusLevelTypes": {
      "type": "string",
      "description": "The level code.",
      "enum": [
        "Info",
        "Warning",
        "Error"
      ],
      "x-ms-enum": {
        "name": "ExtensionsStatusLevelTypes",
        "modelAsString": false,
        "values": [
          {
            "name": "Info",
            "value": "Info",
            "description": "Info"
          },
          {
            "name": "Warning",
            "value": "Warning",
            "description": "Warning"
          },
          {
            "name": "Error",
            "value": "Error",
            "description": "Error"
          }
        ]
      }
    },
    "MachineRunCommandInstanceView": {
      "type": "object",
      "description": "The instance view of a machine run command.",
      "properties": {
        "executionState": {
          "$ref": "#/$defs/ExecutionState",
          "description": "Script execution status."
        },
        "executionMessage": {
          "type": "string",
          "description": "Communicate script configuration errors or execution messages."
        },
        "exitCode": {
          "type": "integer",
          "format": "int32",
          "description": "Exit code returned from script execution."
        },
        "output": {
          "type": "string",
          "description": "Script output stream."
        },
        "error": {
          "type": "string",
          "description": "Script error stream."
        },
        "startTime": {
          "type": "string",
          "format": "date-time",
          "description": "Script start time."
        },
        "endTime": {
          "type": "string",
          "format": "date-time",
          "description": "Script end time."
        },
        "statuses": {
          "type": "array",
          "description": "The  status information.",
          "items": {
            "$ref": "#/$defs/ExtensionsResourceStatus"
          },
          "x-ms-identifiers": []
        }
      }
    },
    "MachineRunCommandProperties": {
      "type": "object",
      "description": "Describes the properties of a run command.",
      "properties": {
        "source": {
          "$ref": "#/$defs/MachineRunCommandScriptSource",
          "description": "The source of the run command script."
        },
        "parameters": {
          "type": "array",
          "description": "The parameters used by the script.",
          "items": {
            "$ref": "#/$defs/RunCommandInputParameter"
          },
          "x-ms-identifiers": [
            "name"
          ]
        },
        "protectedParameters": {
          "type": "array",
          "description": "The parameters used by the script.",
          "items": {
            "$ref": "#/$defs/RunCommandInputParameter"
          },
          "x-ms-identifiers": [
            "name"
          ]
        },
        "asyncExecution": {
          "type": "boolean",
          "description": "Optional. If set to true, provisioning will complete as soon as script starts and will not wait for script to complete.",
          "default": false
        },
        "runAsUser": {
          "type": "string",
          "description": "Specifies the user account on the machine when executing the run command."
        },
        "runAsPassword": {
          "type": "string",
          "format": "password",
          "description": "Specifies the user account password on the machine when executing the run command.",
          "x-ms-secret": true
        },
        "timeoutInSeconds": {
          "type": "integer",
          "format": "int32",
          "description": "The timeout in seconds to execute the run command."
        },
        "outputBlobUri": {
          "type": "string",
          "description": "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."
        },
        "errorBlobUri": {
          "type": "string",
          "description": "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."
        },
        "outputBlobManagedIdentity": {
          "$ref": "#/$defs/RunCommandManagedIdentity",
          "description": "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"
        },
        "errorBlobManagedIdentity": {
          "$ref": "#/$defs/RunCommandManagedIdentity",
          "description": "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"
        },
        "provisioningState": {
          "type": "string",
          "description": "The provisioning state, which only appears in the response.",
          "readOnly": true
        },
        "instanceView": {
          "$ref": "#/$defs/MachineRunCommandInstanceView",
          "description": "The machine run command instance view.",
          "readOnly": true
        }
      }
    },
    "MachineRunCommandScriptSource": {
      "type": "object",
      "description": "Describes the script sources for run command. Use only one of script, scriptUri, commandId.",
      "properties": {
        "script": {
          "type": "string",
          "description": "Specifies the script content to be executed on the machine."
        },
        "scriptUri": {
          "type": "string",
          "description": "Specifies the script download location. It can be either SAS URI of an Azure storage blob with read access or public URI."
        },
        "commandId": {
          "type": "string",
          "description": "Specifies the commandId of predefined built-in script."
        },
        "scriptUriManagedIdentity": {
          "$ref": "#/$defs/RunCommandManagedIdentity",
          "description": "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."
        }
      }
    },
    "RunCommandInputParameter": {
      "type": "object",
      "description": "Describes the properties of a run command parameter.",
      "properties": {
        "name": {
          "type": "string",
          "description": "The run command parameter name."
        },
        "value": {
          "type": "string",
          "description": "The run command parameter value."
        }
      },
      "required": [
        "name",
        "value"
      ]
    },
    "RunCommandManagedIdentity": {
      "type": "object",
      "description": "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.",
      "properties": {
        "clientId": {
          "type": "string",
          "description": "Client Id (GUID value) of the user-assigned managed identity. ObjectId should not be used if this is provided."
        },
        "objectId": {
          "type": "string",
          "description": "Object Id (GUID value) of the user-assigned managed identity. ClientId should not be used if this is provided."
        }
      }
    },
    "TrackedResource": {
      "type": "object",
      "title": "Tracked Resource",
      "description": "The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location'",
      "properties": {
        "tags": {
          "type": "object",
          "description": "Resource tags.",
          "additionalProperties": {
            "type": "string"
          },
          "x-ms-mutability": [
            "read",
            "create",
            "update"
          ]
        },
        "location": {
          "type": "string",
          "description": "The geo-location where the resource lives",
          "x-ms-mutability": [
            "read",
            "create"
          ]
        }
      },
      "required": [
        "location"
      ],
      "allOf": [
        {
          "$ref": "#/$defs/Resource"
        }
      ]
    }
  }
}