{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/microsoft-azure-virtual-machines/json-schema/microsoft-azure-virtual-machines-virtual-machine-diagnostic-run-command-schema.json",
  "title": "VirtualMachineDiagnosticRunCommand",
  "description": "Describes a Virtual Machine diagnostic run command.",
  "x-generated": "2026-11-12",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/microsoft-azure-virtual-machines-virtualmachinediagnosticruncommands-api-openapi.yml#/components/schemas/VirtualMachineDiagnosticRunCommand",
  "type": "object",
  "properties": {
    "properties": {
      "$ref": "#/$defs/VirtualMachineRunCommandProperties",
      "description": "Describes the properties of a Virtual Machine diagnostic run command."
    }
  },
  "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"
          },
          {
            "name": "Pending",
            "value": "Pending"
          },
          {
            "name": "Running",
            "value": "Running"
          },
          {
            "name": "Failed",
            "value": "Failed"
          },
          {
            "name": "Succeeded",
            "value": "Succeeded"
          },
          {
            "name": "TimedOut",
            "value": "TimedOut"
          },
          {
            "name": "Canceled",
            "value": "Canceled"
          }
        ]
      }
    },
    "InstanceViewStatus": {
      "type": "object",
      "description": "Instance view status.",
      "properties": {
        "code": {
          "type": "string",
          "description": "The status code."
        },
        "level": {
          "$ref": "#/$defs/StatusLevelTypes",
          "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."
        }
      }
    },
    "Resource": {
      "type": "object",
      "description": "Referenced by this document but never defined in it. API Evangelist added this empty placeholder so the document resolves; the shape is unknown and is NOT a claim about the API.",
      "x-ae-placeholder": true
    },
    "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."
        }
      }
    },
    "ScriptShellTypes": {
      "type": "string",
      "description": "Script shell types.",
      "enum": [
        "Default",
        "Powershell7"
      ],
      "x-ms-enum": {
        "name": "ScriptShellTypes",
        "modelAsString": true,
        "values": [
          {
            "name": "Default",
            "value": "Default",
            "description": "Default script shell type."
          },
          {
            "name": "Powershell7",
            "value": "Powershell7",
            "description": "Powershell7 script shell type."
          }
        ]
      }
    },
    "StatusLevelTypes": {
      "type": "string",
      "description": "The level code.",
      "enum": [
        "Info",
        "Warning",
        "Error"
      ],
      "x-ms-enum": {
        "name": "StatusLevelTypes",
        "modelAsString": false
      }
    },
    "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"
        }
      ]
    },
    "VirtualMachineRunCommandInstanceView": {
      "type": "object",
      "description": "The instance view of a virtual 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 resource status information.",
          "items": {
            "$ref": "#/$defs/InstanceViewStatus"
          },
          "x-ms-identifiers": []
        }
      }
    },
    "VirtualMachineRunCommandProperties": {
      "type": "object",
      "description": "Describes the properties of a Virtual Machine run command.",
      "properties": {
        "source": {
          "$ref": "#/$defs/VirtualMachineRunCommandScriptSource",
          "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 the script starts and will not wait for script to complete."
        },
        "runAsUser": {
          "type": "string",
          "description": "Specifies the user account on the VM when executing the run command."
        },
        "runAsPassword": {
          "type": "string",
          "description": "Specifies the user account password on the VM when executing the run command."
        },
        "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. If treatFailureAsDeploymentFailure set to true, any failure in the script will fail the deployment and ProvisioningState will be marked as Failed. If treatFailureAsDeploymentFailure set to false, ProvisioningState would only reflect whether the run command was run or not by the extensions platform, it would not indicate whether script failed in case of script failures. See instance view of run command in case of script failures to see executionMessage, output, error: https://aka.ms/runcommandmanaged#get-execution-status-and-results",
          "readOnly": true
        },
        "instanceView": {
          "$ref": "#/$defs/VirtualMachineRunCommandInstanceView",
          "description": "The virtual machine run command instance view.",
          "readOnly": true
        },
        "treatFailureAsDeploymentFailure": {
          "type": "boolean",
          "description": "Optional. If set to true, any failure in the script will fail the deployment and ProvisioningState will be marked as Failed. If set to false, ProvisioningState would only reflect whether the run command was run or not by the extensions platform, it would not indicate whether script failed in case of script failures. See instance view of run command in case of script failures to see executionMessage, output, error: https://aka.ms/runcommandmanaged#get-execution-status-and-results"
        }
      }
    },
    "VirtualMachineRunCommandScriptSource": {
      "type": "object",
      "description": "Describes the script sources for run command. Use only one of these script sources: script, scriptUri, commandId, galleryScriptReferenceId.",
      "properties": {
        "script": {
          "type": "string",
          "description": "Specifies the script content to be executed on the VM."
        },
        "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 a commandId of predefined built-in script. Command IDs available for Linux are listed at https://aka.ms/RunCommandManagedLinux#available-commands, Windows at https://aka.ms/RunCommandManagedWindows#available-commands."
        },
        "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."
        },
        "scriptShell": {
          "$ref": "#/$defs/ScriptShellTypes",
          "description": "Optional. Specify which shell to use for running the script. These values must match those expected by the extension. Currently supported only for Windows VMs, script uses Powershell 7 when specified. Powershell 7 must be already installed on the machine to use Powershell7 parameter value."
        },
        "galleryScriptReferenceId": {
          "type": "string",
          "description": "The resource ID of a Gallery Script version that needs to be executed. Example ID looks like /subscriptions/{subId}/resourceGroups/{rgName}/providers/Microsoft.Compute/galleries/{galleryName}/scripts/{scriptName}/versions/{version}."
        }
      }
    }
  }
}