1. Resources
  2. Detection sources
  3. MICROSOFT.COMPUTE/VIRTUALMACHINES/RUNCOMMAND/ACTION

MICROSOFT.COMPUTE/VIRTUALMACHINES/RUNCOMMAND/ACTION: A script was run on an Azure virtual machine with Run Command

Recorded when someone runs a script on a VM through the action Run Command. The script runs through the VM agent as System on Windows or root on Linux, and its output goes back to the caller.

Log source
Azure Activity log
Detection value
Supporting
Volume
Low (estimate)
Last updated
Log
Azure Activity log (Azure Activity log, on by default)
Service
Azure Activity log
Operation
MICROSOFT.COMPUTE/VIRTUALMACHINES/RUNCOMMAND/ACTION
Detects
2 attacks (2 rules · 3 detection logic)
MITRE ATT&CK
2 techniques in 3 tactics
Threat groups
28 groups that MITRE ATT&CK records using these techniques
Fields the rules read
OperationNameValueActivityStatusValueCaller

When it is written

The action Run Command runs a script inside a VM through the VM agent, for management and for fixing machines whose access or network is broken. The REST API's request takes a commandId (a built-in script), an optional script that replaces the command's default script, and parameters. Microsoft documents that scripts run as System on Windows (root on Linux), one at a time, for at most 90 minutes, that the output is limited to the last 4,096 bytes, and that Virtual Machine Contributor and higher roles can run them. Microsoft lists this permission as executing a predefined script on the virtual machine.

The record shows the caller and names the VM in its resource ID. Microsoft documents no request body for the action in the Activity log, so the script is not in the record; on a Windows VM, Microsoft points to the Run Command extension's log under C:\WindowsAzure\Logs\Plugins for troubleshooting.

How to turn it on

Azure Activity log records MICROSOFT.COMPUTE/VIRTUALMACHINES/RUNCOMMAND/ACTION calls to Azure Activity log without any setup. Vendor documentation

Azure records the Activity log of every subscription without any setup and keeps it for 90 days at no cost; it can be read in the portal (Monitor > Activity log), with the Azure CLI, Azure PowerShell or the REST API. The 90 days are not a collection point: to keep the records longer and send them to a SIEM, create a diagnostic setting on the subscription (Activity log > Export Activity Logs) that includes the Administrative category.

  • Destinations: a Log Analytics workspace (the AzureActivity table that Microsoft Sentinel reads; no ingestion charge, retention beyond 90 days is billed, up to 12 years), Azure Event Hubs (for a third-party SIEM; JSON in the resource log schema) or a storage account. A subscription can have up to five diagnostic settings; remove a legacy log profile once a setting replaces it, or records are duplicated.
  • Create the setting on every subscription. A setting on a management group exports only the events that carry the management group hierarchy, which resource providers outside Resource Manager do not write. Changes made to a management group itself, such as a role assignment at its scope, are in that management group's own activity log; Microsoft documents a management group diagnostic setting, created through the REST API, to export them.
  • Write, delete and action operations are recorded twice or more: when they start and when they succeed or fail, with the same CorrelationId. Requests that Resource Manager rejects during authentication or authorization, before the operation starts, are not recorded: the Activity log is not an access audit log.
  • Read operations are usually not recorded; actions that return secrets or keys (listKeys, listSecrets and similar .../action operations) are.
  • Records are usually available within 3 to 20 minutes. Values can differ in case from one record to another (Microsoft.Authorization and MICROSOFT.AUTHORIZATION): compare without regard to case.
  • Data-plane activity inside a resource (reading a Key Vault secret, a request to a database) is in the resource's own logs, not here.
List the diagnostic settings that export this subscription's Activity log (read only)
az monitor diagnostic-settings subscription list --output table
Based on vendor documentation.
See the categories and the destination of one setting (read only)
az monitor diagnostic-settings subscription show --name <setting-name>
Based on vendor documentation.
Check for a legacy log profile that still exports the log (read only)
az monitor log-profiles list --output table
Based on vendor documentation.
Find recent MICROSOFT.COMPUTE/VIRTUALMACHINES/RUNCOMMAND/ACTION records (read only)
az monitor activity-log list --offset 7d --max-events 1000 --output json | jq '[.[] | select((.operationName.value | ascii_upcase) == "MICROSOFT.COMPUTE/VIRTUALMACHINES/RUNCOMMAND/ACTION")]'
Based on vendor documentation.

Fields

The operation’s own fields first, then the fields every Azure Activity log record has. Field names are the JSON paths of the record as the vendor documents it.

FieldWhat it holds
Properties.entityThe VM the script ran on (.../providers/Microsoft.Compute/virtualMachines/<vm>). Microsoft shows no example record of this operation.
Authorization.scopeThe scope the RBAC check was made at, the same VM.
Fields every Azure Activity log record has (21)
FieldWhat it holds
TimeGeneratedWhen the service that processed the request generated the record, in UTC.
OperationNameValueRead by 2 rulesThe Resource Manager operation, as <provider>/<resource type>/<verb> (for example Microsoft.Authorization/roleAssignments/write). The operation this page is about.
ActivityStatusValueRead by 2 rulesStatus of the operation. Microsoft lists Started, Succeeded and Failed among the common values; records exported through a diagnostic setting can carry the short forms of the resource log schema (Start, Success, Failure), so the detection rules match both.
ActivitySubstatusValueUsually the HTTP status of the call (for example OK, Created, Accepted, Bad Request, Conflict).
CallerRead by 1 ruleWho performed the operation: the user's UPN or e-mail address, or the object ID of a service principal or managed identity.
CallerIpAddressThe address the request came from, when Resource Manager recorded one.
CategoryValueThe Activity log category; operations through Resource Manager are Administrative.
LevelSeverity the resource provider gave the record (Critical, Error, Warning, Informational).
ResourceProviderValueThe resource provider of the affected resource (for example Microsoft.Storage).
ResourceGroupThe resource group of the affected resource, when it has one.
_ResourceIdResource ID of the affected resource (subscription, resource group, provider, type and name).
SubscriptionIdThe subscription of the affected resource.
CorrelationIdShared by all records of one request, for example its Started and Succeeded records.
OperationIdShared by the records that belong to one operation.
EventDataIdUnique identifier of the record.
AuthorizationThe Azure RBAC side of the request, as JSON text: the action that was checked, the scope it was checked at and, when present, evidence with the role and role assignment that allowed it.
PropertiesDetails of the record, as JSON text (Properties_d holds the same as a dynamic value): usually statusCode, serviceRequestId, eventCategory, entity (the resource), message and hierarchy; the record of some operations adds requestbody or responseBody.
ClaimsThe claims of the Microsoft Entra token the caller used (application ID, object ID, UPN, authentication methods, source address), as JSON text.
HTTPRequestThe HTTP request, as JSON text, usually clientRequestId, clientIpAddress and method.
HierarchyThe management group path of the subscription (tenant, management groups, subscription).
EventSubmissionTimestampWhen the record became available for querying.

Values to know

ActivityStatusValue

ValueMeaningSignal
Success, SucceededThe Run Command operation completedThe record the detection rules read; whether the script itself succeeded is in its output.Attack signal
Failure, FailedThe request reached Resource Manager but failedCalls denied by Azure RBAC before the operation starts are not recorded at all.Failure

Volume and noise

Low: administrators use Run Command to troubleshoot machines they cannot reach otherwise. A run by an identity that does not administer the machine, on a domain controller or another Tier 0 server, or several runs by one caller across machines within minutes is the one to read first.

Keeping it manageable

  • Compare Caller with the people who administer the machine, and count its runs in the last 30 minutes (the threshold rule counts five).
  • Follow the Activity log records of the machine's managed identity after the run, and look for a role on the machine given to the caller shortly before (detection logic hypotheses on this operation).
  • On the machine, read the Run Command extension's log and what the script changed.

Sample event

A Azure Activity log record in the vendor’s format, with made-up values.

{
  "TimeGenerated": "2026-11-18T09:30:12.441Z",
  "OperationNameValue": "MICROSOFT.COMPUTE/VIRTUALMACHINES/RUNCOMMAND/ACTION",
  "CategoryValue": "Administrative",
  "Level": "Informational",
  "ActivityStatusValue": "Success",
  "ActivitySubstatusValue": "OK",
  "Caller": "ops-admin@corp.example.com",
  "CallerIpAddress": "203.0.113.24",
  "ResourceProviderValue": "MICROSOFT.COMPUTE",
  "ResourceGroup": "rg-prod-apps",
  "_ResourceId": "/subscriptions/00000000-0000-0000-0000-000000000001/resourcegroups/rg-prod-apps/providers/Microsoft.Compute/virtualMachines/app01",
  "SubscriptionId": "00000000-0000-0000-0000-000000000001",
  "CorrelationId": "00000000-1111-2222-3333-444444444444",
  "OperationId": "00000000-5555-6666-7777-888888888888",
  "EventDataId": "00000000-9999-aaaa-bbbb-cccccccccccc",
  "Authorization": {
    "action": "Microsoft.Compute/virtualMachines/runCommand/action",
    "scope": "/subscriptions/00000000-0000-0000-0000-000000000001/resourcegroups/rg-prod-apps/providers/Microsoft.Compute/virtualMachines/app01"
  },
  "Properties": {
    "eventCategory": "Administrative",
    "entity": "/subscriptions/00000000-0000-0000-0000-000000000001/resourcegroups/rg-prod-apps/providers/Microsoft.Compute/virtualMachines/app01",
    "message": "Microsoft.Compute/virtualMachines/runCommand/action",
    "hierarchy": "00000000-0000-0000-0000-00000000aaaa/mg-corp/00000000-0000-0000-0000-000000000001"
  },
  "Claims": {
    "appid": "00000000-0000-0000-0000-00000000c11e",
    "http://schemas.microsoft.com/identity/claims/objectidentifier": "00000000-0000-0000-0000-00000000b0b0",
    "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/upn": "ops-admin@corp.example.com",
    "ipaddr": "203.0.113.24"
  },
  "HTTPRequest": {
    "clientRequestId": "00000000-1234-5678-9abc-def012345678",
    "clientIpAddress": "203.0.113.24"
  },
  "Hierarchy": "00000000-0000-0000-0000-00000000aaaa/mg-corp/00000000-0000-0000-0000-000000000001",
  "EventSubmissionTimestamp": "2026-11-18T09:31:02.118Z"
}

Attacks this event reveals

Detection rules that read this event:

Detection logic (hypotheses that join this event with others) for:

References