az vm diagnostics
Configure the Azure Virtual Machine diagnostics extension.
Commands
Name | Description | Type | Status |
---|---|---|---|
az vm diagnostics get-default-config |
Get the default configuration settings for a VM. |
Core | GA |
az vm diagnostics set |
Configure the Azure VM diagnostics extension. |
Core | GA |
az vm diagnostics get-default-config
Get the default configuration settings for a VM.
az vm diagnostics get-default-config [--is-windows-os]
Examples
Get the default diagnostics for a Linux VM and override the storage account name and the VM resource ID.
az vm diagnostics get-default-config \
| sed "s#__DIAGNOSTIC_STORAGE_ACCOUNT__#MyStorageAccount#g" \
| sed "s#__VM_OR_VMSS_RESOURCE_ID__#MyVmResourceId#g"
Get the default diagnostics for a Windows VM.
az vm diagnostics get-default-config --is-windows-os
Optional Parameters
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
For Windows VMs.
Property | Value |
---|---|
Default value: | False |
Global Parameters
Increase logging verbosity to show all debug logs.
Property | Value |
---|---|
Default value: | False |
Show this help message and exit.
Only show errors, suppressing warnings.
Property | Value |
---|---|
Default value: | False |
Output format.
Property | Value |
---|---|
Default value: | json |
Accepted values: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath query string. See http://jmespath.org/ for more information and examples.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Increase logging verbosity. Use --debug for full debug logs.
Property | Value |
---|---|
Default value: | False |
az vm diagnostics set
Configure the Azure VM diagnostics extension.
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]
Examples
Set up default diagnostics on a Linux VM for Azure Portal VM metrics graphs and syslog collection.
# 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
Set up default diagnostics on a Windows VM.
# 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'}"
Required Parameters
Json string or a file path, which defines data to be collected.
Optional Parameters
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
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.
Property | Value |
---|---|
Parameter group: | Resource Id Arguments |
Option '--no-auto-upgrade' has been deprecated and will be removed in a future release. Use '--no-auto-upgrade-minor-version' instead.
If set, the extension service will not automatically pick or upgrade to the latest minor version, even if the extension is redeployed.
Property | Value |
---|---|
Default value: | False |
Accepted values: | false, true |
If set, the extension service will not automatically pick or upgrade to the latest minor version, even if the extension is redeployed.
Property | Value |
---|---|
Default value: | False |
Accepted values: | false, true |
Json string or a file path containing private configurations such as storage account keys, etc.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Property | Value |
---|---|
Parameter group: | Resource Id Arguments |
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Property | Value |
---|---|
Parameter group: | Resource Id Arguments |
Version of the diagnostics extension. Will use the latest if not specfied.
The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>
.
Property | Value |
---|---|
Parameter group: | Resource Id Arguments |
Global Parameters
Increase logging verbosity to show all debug logs.
Property | Value |
---|---|
Default value: | False |
Show this help message and exit.
Only show errors, suppressing warnings.
Property | Value |
---|---|
Default value: | False |
Output format.
Property | Value |
---|---|
Default value: | json |
Accepted values: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath query string. See http://jmespath.org/ for more information and examples.
Increase logging verbosity. Use --debug for full debug logs.
Property | Value |
---|---|
Default value: | False |