There is a command group 'az_vm_diagnostics'. This group of commands could 'configure the azure virtual machine diagnostics extension'. The group of commands has global parameter '--debug' which means 'Increase logging verbosity to show all debug logs.'. The group of commands has global parameter '--help -h' which means 'Show this help message and exit.'. The group of commands has global parameter '--only-show-errors' which means 'Only show errors, suppressing warnings.'. The group of commands has global parameter '--output -o' which means 'Output format.'. The group of commands has global parameter '--query' which means 'JMESPath query string. See <a href="http://jmespath.org/">http://jmespath.org/</a> for more information and examples.'. The group of commands has global parameter '--subscription' which means 'Name or ID of subscription. You can configure the default subscription using `az account set -s NAME_OR_ID`.'. The group of commands has global parameter '--verbose' which means 'Increase logging verbosity. Use --debug for full debug logs.'. This group contains a child command 'az_vm_diagnostics_set'.The syntax is: az vm diagnostics set --settings
                      [--ids]
                      [--no-auto-upgrade {false, true}]
                      [--no-auto-upgrade-minor-version {false, true}]
                      [--protected-settings]
                      [--resource-group]
                      [--subscription]
                      [--version]
                      [--vm-name]. The 1th example of the child command would be to use it to 'set up default diagnostics on a linux vm for azure portal vm metrics graphs and syslog collection', the syntax is: # Set the following 3 parameters first.
my_resource_group={Resource group name containing your Linux VM and the storage account}
my_linux_vm={Your Azure Linux VM name}
my_diagnostic_storage_account={Your Azure storage account for storing VM diagnostic data}

my_vm_resource_id=$(az vm show -g $my_resource_group -n $my_linux_vm --query "id" -o tsv)

default_config=$(az vm diagnostics get-default-config \
    | sed "s#__DIAGNOSTIC_STORAGE_ACCOUNT__#$my_diagnostic_storage_account#g" \
    | sed "s#__VM_OR_VMSS_RESOURCE_ID__#$my_vm_resource_id#g")

storage_sastoken=$(az storage account generate-sas \
    --account-name $my_diagnostic_storage_account --expiry 2037-12-31T23:59:00Z \
    --permissions wlacu --resource-types co --services bt -o tsv)

protected_settings="{'storageAccountName': '$my_diagnostic_storage_account', \
    'storageAccountSasToken': '$storage_sastoken'}"

az vm diagnostics set --settings "$default_config" \
    --protected-settings "$protected_settings" \
    --resource-group $my_resource_group --vm-name $my_linux_vm. The 2th example of the child command would be to use it to 'set up default diagnostics on a windows vm', the syntax is: # Set the following 3 parameters first.
my_resource_group={Resource group name containing your Windows VM and the storage account}
my_windows_vm={Your Azure Windows VM name}
my_diagnostic_storage_account={Your Azure storage account for storing VM diagnostic data}

my_vm_resource_id=$(az vm show -g $my_resource_group -n $my_windows_vm --query "id" -o tsv)

default_config=$(az vm diagnostics get-default-config  --is-windows-os \
    | sed "s#__DIAGNOSTIC_STORAGE_ACCOUNT__#$my_diagnostic_storage_account#g" \
    | sed "s#__VM_OR_VMSS_RESOURCE_ID__#$my_vm_resource_id#g")

# Please use the same options, the WAD diagnostic extension has strict
# expectations of the sas token's format. Set the expiry as desired.
storage_sastoken=$(az storage account generate-sas \
    --account-name $my_diagnostic_storage_account --expiry 2037-12-31T23:59:00Z \
    --permissions acuw --resource-types co --services bt --https-only --output tsv)

protected_settings="{'storageAccountName': '$my_diagnostic_storage_account', \
    'storageAccountSasToken': '$storage_sastoken'}"

az vm diagnostics set --settings "$default_config" \
    --protected-settings "$protected_settings" \
    --resource-group $my_resource_group --vm-name $my_windows_vm

# # Alternatively, if the WAD extension has issues parsing the sas token,
# # one can use a storage account key instead.
storage_account_key=$(az storage account keys list --account-name {my_storage_account} \
  --query [0].value -o tsv)
protected_settings="{'storageAccountName': '$my_diagnostic_storage_account', \
  'storageAccountKey': '$storage_account_key'}". The parameter '--settings' is required. It is used to json string or a file path, which defines data to be collected.. The parameter '--ids' is optional. one or more resource ids (space-delimited). it should be a complete resource id containing all information of 'resource id' arguments. you should provide either --ids or other 'resource id' arguments.. The parameter '--no-auto-upgrade' is optional. if set, the extension service will not automatically pick or upgrade to the latest minor version, even if the extension is redeployed.. The parameter '--no-auto-upgrade-minor-version' is optional. if set, the extension service will not automatically pick or upgrade to the latest minor version, even if the extension is redeployed.. The parameter '--protected-settings' is optional. json string or a file path containing private configurations such as storage account keys, etc.. The parameter '--resource-group -g' is optional. name of resource group. you can configure the default group using `az configure --defaults group=<name>`.. The parameter '--subscription' is optional. name or id of subscription. you can configure the default subscription using `az account set -s name_or_id`.. The parameter '--version' is optional. version of the diagnostics extension. will use the latest if not specfied.. The parameter '--vm-name' is optional. the name of the virtual machine. you can configure the default using `az configure --defaults vm=<name>`.. 