Azure / Azure/azure-cli

Omit null value in CLI output.

Open
#16,172 3 comments 0 reactions 1 assignee Claimed by @qwordy View on GitHub
feature-request
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

**Is your feature request related to a problem? Please describe.**

CLI outputs all properties defined in swagger model definition although it is not returned in response. We can see some "null"s in final output. More than one customers reported it is confusing. They want to remove them.

Example
```
Response content:
{
"name": "vm1",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fyvm/providers/Microsoft.Compute/virtualMachines/vm1",
"type": "Microsoft.Compute/virtualMachines",
"location": "eastasia",
"tags": {},
"properties": {
"vmId": "00000000-0000-0000-0000-000000000000",
"hardwareProfile": {
"vmSize": "Standard_DS1_v2"
},
"storageProfile": {
"imageReference": {
"publisher": "Canonical",
"offer": "UbuntuServer",
"sku": "18.04-LTS",
"version": "latest",
"exactVersion": "18.04.202007290"
},
"osDisk": {
"osType": "Linux",
"name": "vm1_OsDisk_1_53a437614cfa458fa68ab0c7b28f5765",
"createOption": "FromImage",
"caching": "ReadWrite",
"managedDisk": {
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/FYVM/providers/Microsoft.Compute/disks/vm1_OsDisk_1_53a437614cfa458fa68ab0c7b28f5765"
}
},
"dataDisks": []
},
"osProfile": {
"computerName": "vm1",
"adminUsername": "fey",
"linuxConfiguration": {
"disablePasswordAuthentication": true,
"ssh": {
"publicKeys": [
{
"path": "/home/fey/.ssh/authorized_keys",
"keyData": "ssh-rsa xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n"
}
]
},
"provisionVMAgent": true,
"patchSettings": {
"patchMode": "ImageDefault"
}
},
"secrets": [],
"allowExtensionOperations": true,
"requireGuestProvisionSignal": true
},
"networkProfile": {"networkInterfaces":[{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fyvm/providers/Microsoft.Network/networkInterfaces/vm1VMNic"}]},
"provisioningState": "Succeeded"
},
"resources": [
{
"name": "AzureNetworkWatcherExtension",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fyvm/providers/Microsoft.Compute/virtualMachines/vm1/extensions/AzureNetworkWatcherExtension",
"type": "Microsoft.Compute/virtualMachines/extensions",
"location": "eastasia",
"properties": {
"autoUpgradeMinorVersion": true,
"provisioningState": "Succeeded",
"publisher": "Microsoft.Azure.NetworkWatcher",
"type": "NetworkWatcherAgentLinux",
"typeHandlerVersion": "1.4",
"settings": {}
}
}
]
}
CLI output:
{
"additionalCapabilities": null,
"availabilitySet": null,
"billingProfile": null,
"diagnosticsProfile": null,
"evictionPolicy": null,
"extensionsTimeBudget": null,
"hardwareProfile": {
"vmSize": "Standard_DS1_v2"
},
"host": null,
"hostGroup": null,
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fyvm/providers/Microsoft.Compute/virtualMachines/vm1",
"identity": null,
"instanceView": null,
"licenseType": null,
"location": "eastasia",
"name": "vm1",
"networkProfile": {
"networkInterfaces": [
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fyvm/providers/Microsoft.Network/networkInterfaces/vm1VMNic",
"primary": null,
"resourceGroup": "fyvm"
}
]
},
"osProfile": {
"adminPassword": null,
"adminUsername": "fey",
"allowExtensionOperations": true,
"computerName": "vm1",
"customData": null,
"linuxConfiguration": {
"disablePasswordAuthentication": true,
"patchSettings": {
"patchMode": "ImageDefault"
},
"provisionVmAgent": true,
"ssh": {
"publicKeys": [
{
"keyData": "ssh-rsa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n",
"path": "/home/fey/.ssh/authorized_keys"
}
]
}
},
"requireGuestProvisionSignal": true,
"secrets": [],
"windowsConfiguration": null
},
"plan": null,
"priority": null,
"provisioningState": "Succeeded",
"proximityPlacementGroup": null,
"resourceGroup": "fyvm",
"resources": [
{
"autoUpgradeMinorVersion": true,
"enableAutomaticUpgrade": null,
"forceUpdateTag": null,
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fyvm/providers/Microsoft.Compute/virtualMachines/vm1/extensions/AzureNetworkWatcherExtension",
"instanceView": null,
"location": "eastasia",
"name": "AzureNetworkWatcherExtension",
"protectedSettings": null,
"provisioningState": "Succeeded",
"publisher": "Microsoft.Azure.NetworkWatcher",
"resourceGroup": "fyvm",
"settings": {},
"tags": null,
"type": "Microsoft.Compute/virtualMachines/extensions",
"typeHandlerVersion": "1.4",
"typePropertiesType": "NetworkWatcherAgentLinux"
}
],
"securityProfile": null,
"storageProfile": {
"dataDisks": [],
"imageReference": {
"exactVersion": "18.04.202007290",
"id": null,
"offer": "UbuntuServer",
"publisher": "Canonical",
"sku": "18.04-LTS",
"version": "latest"
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"diffDiskSettings": null,
"diskSizeGb": null,
"encryptionSettings": null,
"image": null,
"managedDisk": {
"diskEncryptionSet": null,
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/FYVM/providers/Microsoft.Compute/disks/vm1_OsDisk_1_53a437614cfa458fa68ab0c7b28f5765",
"resourceGroup": "FYVM",
"storageAccountType": null
},
"name": "vm1_OsDisk_1_53a437614cfa458fa68ab0c7b28f5765",
"osType": "Linux",
"vhd": null,
"writeAcceleratorEnabled": null
}
},
"tags": {},
"type": "Microsoft.Compute/virtualMachines",
"virtualMachineScaleSet": null,
"vmId": "00000000-0000-0000-0000-000000000000",
"zones": null
}
```

**Describe the solution you'd like**

**Describe alternatives you've considered**

**Additional context**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.