title | description | services | documentationcenter | author | editor | tags | ms.service | ms.topic | ms.tgt_pltfrm | ms.workload | ms.date | ms.author | ms.custom |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Tutorial - Monitor network communication using the Azure portal using VM scale set |
In this tutorial, learn how to monitor network communication between two virtual machine scale sets with Azure Network Watcher's connection monitor capability. |
network-watcher |
na |
mjha |
azure-resource-manager |
network-watcher |
tutorial |
na |
infrastructure-services |
05/24/2022 |
mjha |
mvc |
Tutorial: Monitor network communication between two virtual machine scale sets using the Azure portal
Note
This tutorial cover Connection Monitor (classic). Try the new and improved Connection Monitor to experience enhanced connectivity monitoring
Important
Starting 1 July 2021, you will not be able to add new connection monitors in Connection Monitor (classic) but you can continue to use existing connection monitors created prior to 1 July 2021. To minimize service disruption to your current workloads, migrate from Connection Monitor (classic) to the new Connection Monitor in Azure Network Watcher before 29 February 2024.
Successful communication between a virtual machine scale set (VMSS) and an endpoint such as another VM, can be critical for your organization. Sometimes, configuration changes are introduced which can break communication. In this tutorial, you learn how to:
[!div class="checklist"]
- Create a VM scale set and a VM
- Monitor communication between VMs with the connection monitor capability of Network Watcher
- Generate alerts on Connection Monitor metrics
- Diagnose a communication problem between two VM scale sets, and learn how you can resolve it
If you don't have an Azure subscription, create a free account before you begin.
Sign in to the Azure portal.
Create a VM scale set
Azure load balancer distributes incoming traffic among healthy virtual machine instances.
First, create a public Standard Load Balancer by using the portal. The name and public IP address you create are automatically configured as the load balancer's front end.
-
In the search box, type load balancer. Under Marketplace in the search results, pick Load balancer.
-
In the Basics tab of the Create load balancer page, enter or select the following information:
Setting Value Subscription Select your subscription. Resource group Select Create new and type myVMSSResourceGroup in the text box. Name myLoadBalancer Region Select East US. Type Select Public. SKU Select Standard. Public IP address Select Create new. Public IP address name myPip Assignment Static Availability zone Select Zone-redundant. -
When you are done, select Review + create
-
After it passes validation, select Create.
You can deploy a scale set with a Windows Server image or Linux image such as RHEL, CentOS, Ubuntu, or SLES.
-
Type Scale set in the search box. In the results, under Marketplace, select Virtual machine scale sets. Select Create on the Virtual machine scale sets page, which will open the Create a virtual machine scale set page.
-
In the Basics tab, under Project details, make sure the correct subscription is selected and select myVMSSResourceGroup from resource group list.
-
Type myScaleSet as the name for your scale set.
-
In Region, select a region that is close to your area.
-
Under Orchestration, ensure the Uniform option is selected for Orchestration mode.
-
Select a marketplace image for Image. In this example, we have chosen Ubuntu Server 18.04 LTS.
-
Enter your desired username, and select which authentication type you prefer.
- A Password must be at least 12 characters long and meet three out of the four following complexity requirements: one lower case character, one upper case character, one number, and one special character. For more information, see username and password requirements.
- If you select a Linux OS disk image, you can instead choose SSH public key. Only provide your public key, such as ~/.ssh/id_rsa.pub. You can use the Azure Cloud Shell from the portal to create and use SSH keys.
-
Select Next to move the other pages.
-
Leave the defaults for the Instance and Disks pages.
-
On the Networking page, under Load balancing, select Yes to put the scale set instances behind a load balancer.
-
In Load balancing options, select Azure load balancer.
-
In Select a load balancer, select myLoadBalancer that you created earlier.
-
For Select a backend pool, select Create new, type myBackendPool, then select Create.
-
When you are done, select Review + create.
-
After it passes validation, select Create to deploy the scale set.
Once the scale set is created, follow the steps below to enable the Network Watcher extension in the scale set.
- Under Settings, select Extensions. Select Add extension, and select Network Watcher Agent for Windows, as shown in the following picture:
:::image type="content" source="./media/connection-monitor/nw-agent-extension.png" alt-text="Screenshot that shows Network Watcher extension addition.":::
- Under Network Watcher Agent for Windows, select Create, under Install extension select OK, and then under Extensions, select OK.
Complete the steps in create a VM again, with the following changes:
Step | Setting | Value |
---|---|---|
1 | Select a version of Ubuntu Server | |
3 | Name | myVm2 |
3 | Authentication type | Paste your SSH public key or select Password, and enter a password. |
3 | Resource group | Select Use existing and select myResourceGroup. |
6 | Extensions | Network Watcher Agent for Linux |
The VM takes a few minutes to deploy. Wait for the VM to finish deploying before continuing with the remaining steps.
Create a connection monitor to monitor communication over TCP port 22 from myVmss1 to myVm2.
-
On the left side of the portal, select All services.
-
Start typing network watcher in the Filter box. When Network Watcher appears in the search results, select it.
-
Under MONITORING, select Connection monitor.
-
Select + Add.
-
Enter or select the information for the connection you want to monitor, and then select Add. In the example shown in the following picture, the connection monitored is from the myVmss1 VM scale set to the myVm2 VM over port 22:
Setting Value Name myVmss1-myVm2(22) Source Virtual machine myVmss1 Destination Select a virtual machine Virtual machine myVm2 Port 22 :::image type="content" source="./media/connection-monitor/add-connection-monitor.png" alt-text="Screenshot that shows addition of Connection Monitor.":::
-
Complete steps 1-3 in Create a connection monitor to view connection monitoring. You see a list of existing connection monitors, as shown in the following picture:
:::image type="content" source="./media/connection-monitor/connection-monitors.png" alt-text="Screenshot that shows Connection Monitor.":::
-
Select the monitor with the name myVmss1-myVm2(22), as shown in the previous picture, to see details for the monitor, as shown in the following picture:
:::image type="content" source="./media/connection-monitor/vm-monitor.png" alt-text="Screenshot that shows virtual machine monitor.":::
Note the following information:
Item Value Details Status Reachable Lets you know whether the endpoint is reachable or not. AVG. ROUND-TRIP Lets you know the round-trip time to make the connection, in milliseconds. Connection monitor probes the connection every 60 seconds, so you can monitor latency over time. Hops Connection monitor lets you know the hops between the two endpoints. In this example, the connection is between two VMs in the same virtual network, so there is only one hop, to the 10.0.0.5 IP address. If any existing system or custom routes, route traffic between the VMs through a VPN gateway, or network virtual appliance, for example, additional hops are listed. STATUS The green check marks for each endpoint let you know that each endpoint is healthy.
Alerts are created by alert rules in Azure Monitor and can automatically run saved queries or custom log searches at regular intervals. A generated alert can automatically run one or more actions, such as to notify someone or start another process. When setting an alert rule, the resource that you target determines the list of available metrics that you can use to generate alerts.
-
In Azure portal, select the Monitor service, and then select Alerts > New alert rule.
-
Click Select target, and then select the resources that you want to target. Select the Subscription, and set Resource type to filter down to the Connection Monitor that you want to use.
:::image type="content" source="./media/connection-monitor/set-alert-rule.png" alt-text="Screenshot of alert rule.":::
-
Once you have selected a resource to target, select Add criteria.The Network Watcher has metrics on which you can create alerts. Set Available signals to the metrics ProbesFailedPercent and AverageRoundtripMs:
:::image type="content" source="./media/connection-monitor/set-alert-signals.png" alt-text="Screenshot of alert signals.":::
-
Fill out the alert details like alert rule name, description and severity. You can also add an action group to the alert to automate and customize the alert response.
By default, Azure allows communication over all ports between VMs in the same virtual network. Over time, you, or someone in your organization, might override Azure's default rules, inadvertently causing a communication failure. Complete the following steps to create a communication problem and then view the connection monitor again:
-
In the search box at the top of the portal, enter myResourceGroup. When the myResourceGroup resource group appears in the search results, select it.
-
Select the myVm2-nsg network security group.
-
Select Inbound security rules, and then select Add, as shown in the following picture:
:::image type="content" source="./media/connection-monitor/inbound-security-rules.png" alt-text="Screenshot of network security rules.":::
-
The default rule that allows communication between all VMs in a virtual network is the rule named AllowVnetInBound. Create a rule with a higher priority (lower number) than the AllowVnetInBound rule that denies inbound communication over port 22. Select, or enter, the following information, accept the remaining defaults, and then select Add:
Setting Value Destination port ranges 22 Action Deny Priority 100 Name DenySshInbound -
Since connection monitor probes at 60-second intervals, wait a few minutes and then on the left side of the portal, select Network Watcher, then Connection monitor, and then select the myVm1-myVm2(22) monitor again. The results are different now, as shown in the following picture:
:::image type="content" source="./media/connection-monitor/vm-monitor-fault.png" alt-text="Screenshot of virtual machine at fault.":::
You can see that there's a red exclamation icon in the status column for the myvm2529 network interface.
-
To learn why the status has changed, select 10.0.0.5, in the previous picture. Connection monitor informs you that the reason for the communication failure is: Traffic blocked due to the following network security group rule: UserRule_DenySshInbound.
If you didn't know that someone had implemented the security rule you created in step 4, you'd learn from connection monitor that the rule is causing the communication problem. You could then change, override, or remove the rule, to restore communication between the VMs.
When no longer needed, delete the resource group and all of the resources it contains:
- Enter myResourceGroup in the Search box at the top of the portal. When you see myResourceGroup in the search results, select it.
- Select Delete resource group.
- Enter myResourceGroup for TYPE THE RESOURCE GROUP NAME: and select Delete.
In this tutorial, you learned how to monitor a connection between two VMs. You learned that a network security group rule prevented communication to a VM. To learn about all of the different responses connection monitor can return, see response types. You can also monitor a connection between a VM, a fully qualified domain name, a uniform resource identifier, or an IP address.
At some point, you may find that resources in a virtual network are unable to communicate with resources in other networks connected by an Azure virtual network gateway. Advance to the next tutorial to learn how to diagnose a problem with a virtual network gateway.
[!div class="nextstepaction"] Diagnose communication problems between networks