Skip to content

Commit db98deb

Browse files
authored
Merge pull request #259866 from halkazwini/nw-vpncli
Rewrite article
2 parents c362768 + 9b41848 commit db98deb

File tree

1 file changed

+76
-49
lines changed

1 file changed

+76
-49
lines changed
Lines changed: 76 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,122 @@
11
---
2-
title: Troubleshoot Azure VNet gateway and connections - Azure CLI
2+
title: Troubleshoot VPN gateways and connections - Azure CLI
33
titleSuffix: Azure Network Watcher
4-
description: This page explains how to use the Azure Network Watcher troubleshoot Azure CLI.
5-
services: network-watcher
4+
description: Learn how to use Azure Network Watcher VPN troubleshoot capability to troubleshoot VPN virtual network gateways and their connections using the Azure CLI.
65
author: halkazwini
6+
ms.author: halkazwini
77
ms.service: network-watcher
88
ms.topic: how-to
9-
ms.workload: infrastructure-services
10-
ms.date: 07/25/2022
11-
ms.author: halkazwini
12-
ms.custom: engagement-fy23, devx-track-azurecli
9+
ms.date: 11/30/2023
10+
ms.custom: devx-track-azurecli
11+
12+
#CustomerIntent: As a network administrator, I want to determine why resources in a virtual network can't communicate with resources in a different virtual network over a VPN connection.
1313
---
1414

15-
# Troubleshoot virtual network gateway and connections with Azure Network Watcher using Azure CLI
15+
# Troubleshoot VPN virtual network gateways and connections using the Azure CLI
1616

1717
> [!div class="op_single_selector"]
1818
> - [Portal](diagnose-communication-problem-between-networks.md)
1919
> - [PowerShell](network-watcher-troubleshoot-manage-powershell.md)
2020
> - [Azure CLI](network-watcher-troubleshoot-manage-cli.md)
21-
> - [REST API](network-watcher-troubleshoot-manage-rest.md)
2221
23-
Network Watcher provides many capabilities as it relates to understanding your network resources in Azure. One of these capabilities is resource troubleshooting. Resource troubleshooting can be called through the portal, PowerShell, CLI, or REST API. When called, Network Watcher inspects the health of a Virtual Network Gateway or a Connection and returns its findings.
22+
In this article, you learn how to use Network Watcher VPN troubleshoot capability to diagnose and troubleshoot VPN virtual network gateways and their connections to solve connectivity issues between your virtual network and on-premises network. VPN troubleshoot requests are long running requests, which could take several minutes to return a result. The logs from troubleshooting are stored in a container on a storage account that is specified.
23+
24+
## Prerequisites
2425

25-
To perform the steps in this article, you need to [install the Azure CLI](/cli/azure/install-azure-cli) for Windows, Linux, or macOS.
26+
- An Azure account with an active subscription. [create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
2627

27-
## Before you begin
28+
- A Network Watcher enabled in the region of the virtual network gateway. For more information, see [Enable or disable Azure Network Watcher](network-watcher-create.md?tabs=cli).
2829

29-
This scenario assumes you have already followed the steps in [Create a Network Watcher](network-watcher-create.md) to create a Network Watcher.
30+
- A virtual network gateway. For more information, see [Supported gateway types](network-watcher-troubleshoot-overview.md#supported-gateway-types).
3031

31-
For a list of supported gateway types visit, [Supported Gateway types](network-watcher-troubleshoot-overview.md#supported-gateway-types).
32+
- Azure Cloud Shell or Azure CLI.
33+
34+
The steps in this article run the Azure CLI commands interactively in [Azure Cloud Shell](/azure/cloud-shell/overview). To run the commands in the Cloud Shell, select **Open Cloudshell** at the upper-right corner of a code block. Select **Copy** to copy the code, and paste it into Cloud Shell to run it. You can also run the Cloud Shell from within the Azure portal.
35+
36+
You can also [install Azure CLI locally](/cli/azure/install-azure-cli) to run the commands. If you run Azure CLI locally, sign in to Azure using the [az login](/cli/azure/reference-index#az-login) command.
3237

33-
## Overview
38+
## Troubleshoot using an existing storage account
3439

35-
Resource troubleshooting provides the ability troubleshoot issues that arise with Virtual Network Gateways and Connections. When a request is made to resource troubleshooting, logs are being queried and inspected. When inspection is complete, the results are returned. Resource troubleshooting requests are long running requests, which could take multiple minutes to return a result. The logs from troubleshooting are stored in a container on a storage account that is specified.
40+
In this section, you learn how to troubleshoot a VPN virtual network gateway or a VPN connection using an existing storage account.
3641

37-
## Retrieve a Virtual Network Gateway Connection
42+
# [**Gateway**](#tab/gateway)
3843

39-
In this example, resource troubleshooting is being ran on a Connection. You can also pass it a Virtual Network Gateway. The following cmdlet lists the vpn-connections in a resource group.
44+
Use [az storage account show](/cli/azure/storage/account#az-storage-account-show) to retrieve the resource ID of the storage account. Then use [az network watcher troubleshooting start](/cli/azure/network/watcher/troubleshooting#az-network-watcher-troubleshooting-start) to start troubleshooting the VPN gateway.
4045

41-
```azurecli
42-
az network vpn-connection list --resource-group resourceGroupName
46+
```azurecli-interactive
47+
# Place the storage account ID into a variable.
48+
storageId=$(az storage account show --name 'mystorageaccount' --resource-group 'myResourceGroup' --query 'id' --output tsv)
49+
50+
# Start VPN troubleshoot session.
51+
az network watcher troubleshooting start --resource-group 'myResourceGroup' --resource 'myGateway' --resource-type 'vnetGateway' --storage-account $storageId --storage-path 'https://mystorageaccount.blob.core.windows.net/{containerName}'
4352
```
4453

45-
Once you have the name of the connection, you can run this command to get its resource Id:
54+
# [**Connection**](#tab/connection)
55+
56+
Use [az storage account show](/cli/azure/storage/account#az-storage-account-show) to retrieve the resource ID of the storage account. Then use [az network watcher troubleshooting start](/cli/azure/network/watcher/troubleshooting#az-network-watcher-troubleshooting-start) to start troubleshooting the VPN connection.
57+
58+
```azurecli-interactive
59+
# Place the storage account ID into a variable.
60+
storageId=$(az storage account show --name 'mystorageaccount' --resource-group 'myResourceGroup' --query 'id' --output tsv)
4661
47-
```azurecli
48-
az network vpn-connection show --resource-group resourceGroupName --ids vpnConnectionIds
62+
# Start VPN troubleshoot session.
63+
az network watcher troubleshooting start --resource-group 'myResourceGroup' --resource 'myConnection' --resource-type 'vpnConnection' --storage-account $storageId --storage-path 'https://mystorageaccount.blob.core.windows.net/{containerName}'
4964
```
5065

51-
## Create a storage account
66+
---
5267

53-
Resource troubleshooting returns data about the health of the resource, it also saves logs to a storage account to be reviewed. In this step, we create a storage account, if an existing storage account exists you can use it.
68+
After the troubleshooting request is completed, ***Healthy*** or ***UnHealthy*** is returned with action text that provides general guidance on how to resolve the issue. If an action can be taken for the issue, a link is provided with more guidance.
5469

55-
1. Create the storage account
70+
Additionally, detailed logs are stored in the storage account container you specified in the previous command. For more information, see [Log files](network-watcher-troubleshoot-overview.md#log-files). You can use Storage explorer or any other way you prefer to access and download the logs. For more information, see [Get started with Storage Explorer](../vs-azure-tools-storage-manage-with-storage-explorer.md).
5671

57-
```azurecli
58-
az storage account create --name storageAccountName --location westcentralus --resource-group resourceGroupName --sku Standard_LRS
59-
```
72+
## Troubleshoot using a new storage account
6073

61-
1. Get the storage account keys
74+
In this section, you learn how to troubleshoot a VPN virtual network gateway or a VPN connection using a new storage account.
6275

63-
```azurecli
64-
az storage account keys list --resource-group resourcegroupName --account-name storageAccountName
65-
```
76+
# [**Gateway**](#tab/gateway)
6677

67-
1. Create the container
78+
Use [az storage account create](/cli/azure/storage/account#az-storage-account-create) and [az storage container create](/cli/azure/storage/container#az-storage-container-create) to create a new storage account and a container respectively. Then, use [az network watcher troubleshooting start](/cli/azure/network/watcher/troubleshooting#az-network-watcher-troubleshooting-start) to start troubleshooting the VPN gateway.
6879

69-
```azurecli
70-
az storage container create --account-name storageAccountName --account-key {storageAccountKey} --name logs
71-
```
80+
```azurecli-interactive
81+
# Create a new storage account.
82+
az storage account create --name 'mystorageaccount' --resource-group 'myResourceGroup' --location 'eastus' --sku 'Standard_LRS'
7283
73-
## Run Network Watcher resource troubleshooting
84+
# Get the storage account keys.
85+
az storage account keys list --resource-group 'myResourceGroup' --account-name 'mystorageaccount'
7486
75-
You troubleshoot resources with the `az network watcher troubleshooting` cmdlet. We pass the cmdlet the resource group, the name of the Network Watcher, the Id of the connection, the Id of the storage account, and the path to the blob to store the troubleshoot results in.
87+
# Create a container.
88+
az storage container create --account-name 'mystorageaccount' --account-key {storageAccountKey} --name 'vpn'
7689
77-
```azurecli
78-
az network watcher troubleshooting start --resource-group resourceGroupName --resource resourceName --resource-type {vnetGateway/vpnConnection} --storage-account storageAccountName --storage-path https://{storageAccountName}.blob.core.windows.net/{containerName}
90+
# Start VPN troubleshoot session.
91+
az network watcher troubleshooting start --resource-group 'myResourceGroup' --resource 'myGateway' --resource-type 'vnetGateway' --storage-account 'mystorageaccount' --storage-path 'https://mystorageaccount.blob.core.windows.net/vpn'
7992
```
8093

81-
Once you run the cmdlet, Network Watcher reviews the resource to verify the health. It returns the results to the shell and stores logs of the results in the storage account specified.
94+
# [**Connection**](#tab/connection)
95+
96+
Use [az storage account create](/cli/azure/storage/account#az-storage-account-create) and [az storage container create](/cli/azure/storage/container#az-storage-container-create) to create a new storage account and a container respectively. Then, use [az network watcher troubleshooting start](/cli/azure/network/watcher/troubleshooting#az-network-watcher-troubleshooting-start) to start troubleshooting the VPN connection.
97+
98+
```azurecli-interactive
99+
# Create a new storage account.
100+
az storage account create --name 'mystorageaccount' --resource-group 'myResourceGroup' --location 'eastus' --sku 'Standard_LRS'
101+
102+
# Get the storage account keys.
103+
az storage account keys list --resource-group 'myResourceGroup' --account-name 'mystorageaccount'
82104
83-
## Understanding the results
105+
# Create a container.
106+
az storage container create --account-name 'mystorageaccount' --account-key {storageAccountKey} --name 'vpn'
84107
85-
The action text provides general guidance on how to resolve the issue. If an action can be taken for the issue, a link is provided with additional guidance. In the case where there is no additional guidance, the response provides the url to open a support case. For more information about the properties of the response and what is included, visit [Network Watcher Troubleshoot overview](network-watcher-troubleshoot-overview.md)
108+
# Start VPN troubleshoot session.
109+
az network watcher troubleshooting start --resource-group 'myResourceGroup' --resource 'myConnection' --resource-type 'vpnConnection' --storage-account 'mystorageaccount' --storage-path 'https://mystorageaccount.blob.core.windows.net/vpn'
110+
```
111+
112+
---
86113

87-
For instructions on downloading files from azure storage accounts, refer to [Get started with Azure Blob storage using .NET](../storage/blobs/storage-quickstart-blobs-dotnet.md). Another tool that can be used is Storage Explorer. More information about Storage Explorer can be found here at the following link: [Storage Explorer](https://storageexplorer.com/)
114+
After the troubleshooting request is completed, ***Healthy*** or ***UnHealthy*** is returned with action text that provides general guidance on how to resolve the issue. If an action can be taken for the issue, a link is provided with more guidance.
88115

89-
## Azure CLI troubleshooting
116+
Additionally, detailed logs are stored in the storage account container you specified in the previous command. For more information, see [Log files](network-watcher-troubleshoot-overview.md#log-files). You can use Storage explorer or any other way you prefer to access and download the logs. For more information, see [Get started with Storage Explorer](../vs-azure-tools-storage-manage-with-storage-explorer.md).
90117

91-
[!INCLUDE [azure-cli-troubleshooting.md](../../includes/azure-cli-troubleshooting.md)]
118+
## Related content
92119

93-
## Next steps
120+
- [Tutorial: Diagnose a communication problem between virtual networks using the Azure portal](diagnose-communication-problem-between-networks.md).
94121

95-
If settings have been changed that stop VPN connectivity, see [Manage Network Security Groups](../virtual-network/manage-network-security-group.md) to track down the network security group and security rules that may be in question.
122+
- [VPN troubleshoot overview](network-watcher-troubleshoot-overview.md).

0 commit comments

Comments
 (0)