0
0
Azurecloud~7 mins

Performance efficiency pillar in Azure - Commands & Configuration

Choose your learning style9 modes available
Introduction
Performance efficiency pillar helps you make sure your cloud setup runs fast and uses resources well. It solves problems like slow apps or wasted computing power by guiding you to choose the right tools and settings.
When your website loads slowly and you want to speed it up without extra cost
When your app needs to handle more users during busy times without crashing
When you want to pick the best Azure services that fit your workload needs
When you want to monitor and improve how your cloud resources perform over time
When you want to avoid paying for more resources than you actually need
Commands
This command checks the CPU usage of a virtual machine every minute to see if it is running efficiently.
Terminal
az monitor metrics list --resource /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM --metric Percentage CPU --interval PT1M
Expected OutputExpected
value: [ { "average": 15.3, "timeStamp": "2024-06-01T12:00:00Z" }, { "average": 20.1, "timeStamp": "2024-06-01T12:01:00Z" } ]
--metric - Specifies which performance metric to check
--interval - Sets how often to collect the metric data
This command changes the size of the virtual machine to a more powerful one to improve performance.
Terminal
az vm resize --resource-group myResourceGroup --name myVM --size Standard_DS2_v2
Expected OutputExpected
OperationId : 12345678-1234-1234-1234-123456789abc Status : Succeeded
--size - Defines the new VM size to improve performance
This command sets up automatic scaling for the VM so it can add or remove resources based on demand.
Terminal
az monitor autoscale create --resource-group myResourceGroup --resource myVM --resource-type Microsoft.Compute/virtualMachines --name myAutoscale --min-count 1 --max-count 3 --count 1
Expected OutputExpected
{ "name": "myAutoscale", "location": "eastus", "profiles": [], "enabled": true }
--min-count - Minimum number of VM instances
--max-count - Maximum number of VM instances
This command adds a rule to increase VM instances when CPU usage goes above 70% for 5 minutes.
Terminal
az monitor autoscale rule create --resource-group myResourceGroup --autoscale-name myAutoscale --condition "Percentage CPU > 70 avg 5m" --scale out 1
Expected OutputExpected
{ "name": "ScaleOutRule", "condition": "Percentage CPU > 70 avg 5m", "direction": "Increase", "changeCount": 1 }
--condition - Defines when to trigger scaling
--scale - Specifies scaling direction and amount
This command adds a rule to decrease VM instances when CPU usage drops below 30% for 5 minutes.
Terminal
az monitor autoscale rule create --resource-group myResourceGroup --autoscale-name myAutoscale --condition "Percentage CPU < 30 avg 5m" --scale in 1
Expected OutputExpected
{ "name": "ScaleInRule", "condition": "Percentage CPU < 30 avg 5m", "direction": "Decrease", "changeCount": 1 }
--condition - Defines when to trigger scaling
--scale - Specifies scaling direction and amount
Key Concept

If you remember nothing else from this pattern, remember: monitor your resources and adjust their size or count automatically to keep performance high and costs low.

Common Mistakes
Not monitoring performance metrics before resizing or scaling
You might increase resources unnecessarily, wasting money without improving performance.
Always check metrics like CPU usage first to understand if scaling is needed.
Setting autoscale rules with thresholds that are too high or too low
This can cause slow response to demand changes or frequent scaling that disrupts service.
Choose balanced thresholds based on typical workload patterns.
Forgetting to verify autoscale settings after creation
Incorrect or missing rules can cause autoscaling to fail silently.
Use commands to list and check autoscale profiles and rules after setup.
Summary
Use Azure CLI to monitor performance metrics like CPU usage on your virtual machines.
Resize virtual machines to better sizes based on performance needs.
Set up autoscaling rules to automatically add or remove resources based on demand.
Check and adjust autoscale thresholds to balance performance and cost.