We're deploying data collection rules to gather Performance counters and syslog messages from linux VMs. When we configure these rules via portal the Azure Monitor Linux agent extension is automatically provisioned on the VM and data is collected immediately, which is great. When we configure the exact same data collection rule and associate it to the VM via AZ cli, this automatic provisioning doesn't seem to be triggered. Here are the AZ cli commands:
az monitor data-collection rule create --resource-group $RG_NAME --location $LOCATION --name $DCR_SYSLOG_NAME --data-flows destinations=$LOG_WORKSPACE_NAME streams="Microsoft-Syslog" --log-analytics name=$LOG_WORKSPACE_NAME resource-id="/subscriptions/$SUBSCRIPTION/resourceGroups/$RG_NAME/providers/Microsoft.OperationalInsights/workspaces/$LOG_WORKSPACE_NAME" --syslog name="SyslogDataSource" facility-names="local3" log-levels="*" streams="Microsoft-Syslog"
az monitor data-collection rule create --resource-group $RG_NAME --location $LOCATION --name $DCR_METRICS_NAME --data-flows destinations=$INSIGHTS_WORKSPACE_NAME streams="Microsoft-Perf" --log-analytics name=$INSIGHTS_WORKSPACE_NAME resource-id="/subscriptions/$SUBSCRIPTION/resourceGroups/$RG_NAME/providers/Microsoft.OperationalInsights/workspaces/$INSIGHTS_WORKSPACE_NAME" --performance-counters name="MetricsDataSource" counter-specifiers="\\Logical Disk(*)\\% Used Space" counter-specifiers="\\Memory(*)\\% Used Memory" counter-specifiers="\\Network(*)\\Total Collisions" sampling-frequency="60" streams="Microsoft-Perf"
az monitor data-collection rule association create --name "DefaultSyslog" --rule-id $SYSLOGRULEID --resource $VMID
az monitor data-collection rule association create --name "DefaultMetrics" --rule-id $METRICSRULEID --resource $VMID
In portal everything looks exactly the same as it does when we configure it manually, but with the only difference that the agent is not deployed to the VM. Is this convinient auto-provisioning exclusive to the UI configuration? If so, what's an elegant way to deploy the agent to the VM in an automated manner?