MicrosoftDocs / azure-docs

Open source documentation of Microsoft Azure
https://docs.microsoft.com/azure
Creative Commons Attribution 4.0 International
10.28k stars 21.46k forks source link

Enable Periodic assessment for VM with API REST #112733

Closed AKowsigan closed 9 months ago

AKowsigan commented 1 year ago

Hello,

I find a way to enable Periodic assessment for azure VM and also change patch orchestration to "Customer Managed Schedules (Preview)" with the API REST in Powershell with this :

$subscriptionId = "mySubscription" $resourceGroup = "myRG" $virtualMachine = "myVM" $apiUrl = "https://management.azure.com/subscriptions/$subscriptionId/resourceGroups/$resourceGroup/providers/Microsoft.Compute/virtualMachines/$($virtualMachine)?api-version=2023-03-01"

$body = "{

"properties": { "osProfile": { "windowsConfiguration": { "provisionVMAgent": true, "enableAutomaticUpdates": true, "patchSettings": { "patchMode": "AutomaticByPlatform", "assessmentMode": "AutomaticByPlatform", "automaticByPlatformSettings":{ "bypassPlatformSafetyChecksOnUserSchedule":true } } } } } }"

$response = Invoke-RestMethod -Method PATCH -Uri $apiUrl -Body $body -Headers @{Authorization = "bearer $($token.Token)" } -ContentType "application/json"

I think it could be great if you can update the documentation for other people, so they know that they can also use the API :).

ALAGARAJAH Kowsigan

Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

KrishnaG-MSFT commented 1 year ago

@AKowsigan Thanks for your comment! We will review and provide an update as appropriate.

superfliege commented 1 year ago

@AKowsigan My hero of the day! Thanks a lot for this github entry. @KrishnaG-MSFT Can you please provide a documentation about this github entry? Thanks a lot <3

SnehaSudhirG commented 9 months ago

Thanks for your dedication to our documentation. Unfortunately, at this time we have been unable to review your issue in a timely manner and we sincerely apologize for the delayed response. The requested updates have not been made since the creation of this issue, and the timeline for resolution may vary based on resourcing, so we've created an internal work item to incorporate your suggestions. We are closing this issue for now, but feel free to comment here as necessary. #please-close