Skip to content

Instantly share code, notes, and snippets.

@ChendrayanV
Created December 21, 2021 02:08
Show Gist options
  • Save ChendrayanV/1ce319eb76fcf3ec22fb0cfb6539878d to your computer and use it in GitHub Desktop.
Save ChendrayanV/1ce319eb76fcf3ec22fb0cfb6539878d to your computer and use it in GitHub Desktop.
Resize Azure VM - REST API
$Body = [pscustomobject]@{
properties = [pscustomobject]@{
hardwareProfile = [pscustomobject]@{
vmSize = 'Standard_D2s_v3'
}
}
} | ConvertTo-Json -Compress
$SubcriptionId = ''
$ResourceGroup = ''
$VMName = ''
$Uri = "https://management.azure.com/subscriptions/$($SubcriptionId)/resourceGroups/$($ResourceGroup)/providers/Microsoft.Compute/virtualMachines/$($VMName)?api-version=2021-07-01"
Invoke-RestMethod -Method Patch -Uri $Uri -Body $Body -Headers @{'Authorization' = "Bearer {0}" -f (Get-AzAccessToken).Token } -ContentType 'application/json'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment