Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
This script retrieves resources from a managed resource group, and resizes the VMs in that resource group.
To run this sample, install the latest version of the Azure CLI. To start, run az login
to create a connection with Azure.
Samples for the Azure CLI are written for the bash
shell. To run this sample in Windows PowerShell or Command Prompt, you may need to change
elements of the script.
If you don't have an Azure subscription, create a trial account before you begin.
Sample script
#!/bin/bash
# Get managed applications from known resource group
az managedapp list --query "[?contains(resourceGroup,'DemoApp')]"
# Get ID of managed resource group
az managedapp list --query "[?contains(resourceGroup,'DemoApp')].{ managedResourceGroup:managedResourceGroupId }"
# Get virtual machines in the managed resource group
az resource list -g DemoApp6zkevchqk7sfq --query "[?contains(type,'Microsoft.Compute/virtualMachines')]"
# Get information about virtual machines in managed resource group
az vm list -g DemoApp6zkevchqk7sfq --query "[].{VMName:name,OSType:storageProfile.osDisk.osType,VMSize:hardwareProfile.vmSize}"
## Resize virtual machines in managed resource group
az vm resize --size Standard_D2_v2 --ids $(az vm list -g DemoApp6zkevchqk7sfq --query "[].id" -o tsv)
Script explanation
This script uses the following commands to deploy the managed application. Each command in the table links to command-specific documentation.
Command | Notes |
---|---|
az managedapp list | List managed applications. Provide query values to focus the results. |
az resource list | List resources. Provide a resource group and query values to focus the result. |
az vm resize | Update a virtual machine's size. |
Next steps
- For an introduction to managed applications, see Azure Managed Application overview.
- For more information on the Azure CLI, see Azure CLI documentation.