Azure / Azure/azure-cli

VM update commands fails to update VM OS configs with azure cli v2.81 & v2.82

Open
#32,671 5 comments 0 reactions 2 assignees Assigned to @zhoxing-ms View on GitHub
act-observability-squad Auto-Assign Azure CLI Team Breaking Change Compute customer-reported needs-team-triage question
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

### Describe the bug

The latest azure cli version fails to update the OS profile with below error.

"ERROR: Couldn't find 'automaticByPlatformSettings' in 'osProfile.windowsConfiguration.patchSettings'. Available options: ['assessmentMode', 'patchMode']
"
Command:
`az vm update --resource-group $AzResourceGroup.name `
--name $VirtualMachineName `
--set osProfile.windowsConfiguration.enableAutomaticUpdates=true `
osProfile.windowsConfiguration.patchSettings.patchMode=AutomaticByPlatform `
osProfile.windowsConfiguration.patchSettings.automaticByPlatformSettings.bypassPlatformSafetyChecksOnUserSchedule=true `
| Out-Null`

Note: The above used to work as expected until v2.78 and probably for later releases before v2.81. We noticed our pipelines started with fail after AzureManagedPools updated the underneath azure cli version to v2.81. We figured out a workaround but wanted to highlist so this can be fixed in later versions of azure cli.

Steps to reproduce:
1. Create a windows VM with default setting with "patchMode" as "AutomaticByOS" and "enableAutomaticUpdates" to true.
2. Run above command to update the upgrade configs for Customer Managed Schedules

Work Around:
Instead of az vm update we are direcly utlizing the az rest api calls.
Example:
`$azVmId = $result.id
$body = '{"properties":{"osProfile":{"windowsConfiguration":{"enableAutomaticUpdates":true,"patchSettings":{"patchMode":"AutomaticByPlatform","automaticByPlatformSettings":{"bypassPlatformSafetyChecksOnUserSchedule":true}}}}}}'
$jsonBody = $body | ConvertTo-Json -Depth 10 -Compress
az rest --uri "https://management.azure.com/$azVmId?api-version=2024-03-01" `
--method patch `
--headers "Content-Type=application/json" `
--body $jsonBody `
| Out-Null`

### Related command

az vm update

### Errors

ERROR: Couldn't find 'automaticByPlatformSettings' in 'osProfile.windowsConfiguration.patchSettings'. Available options: ['assessmentMode', 'patchMode']

### Issue script & Debug output

Not sure. But added a workaround which might help the backend team to figure the root cause.

### Expected behavior

az vm update should be able to update the automatic upgrade configs without any errors.

### Environment Summary

azure cli v2.82

### Additional context

NA

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.