A network team wants to send diagnostic logs from an Azure VPN gateway to a Log Analytics workspace. Which command should be used to configure this?
Exhibit
Goal: Centralized logging server = 192.0.2.50
Trap 1: Set-AzVpnGateway -LoggingConfiguration
Incorrect. 'Set-AzVpnGateway' is used to modify VPN gateway properties like SKU or connections, but it does not have a -LoggingConfiguration parameter for sending logs to Log Analytics.
Trap 2: Set-AzVNetGateway -DiagnosticLogging
Incorrect. 'Set-AzVNetGateway' is used to configure virtual network gateway settings, but it does not have a -DiagnosticLogging parameter.
Trap 3: Add-AzLogAnalyticsSolution
Incorrect. 'Add-AzLogAnalyticsSolution' installs a management solution (e.g., 'Azure VPN Gateway' solution) into a Log Analytics workspace, but it does not configure diagnostic settings for individual resources; diagnostic settings must be created separately.
- A
Set-AzVpnGateway -LoggingConfiguration
Why wrong: Incorrect. 'Set-AzVpnGateway' is used to modify VPN gateway properties like SKU or connections, but it does not have a -LoggingConfiguration parameter for sending logs to Log Analytics.
- B
New-AzDiagnosticSetting -ResourceId $gw.Id -WorkspaceId $ws.Id
Correct. Creates a diagnostic setting that routes logs and metrics from the VPN gateway to a Log Analytics workspace.
- C
Set-AzVNetGateway -DiagnosticLogging
Why wrong: Incorrect. 'Set-AzVNetGateway' is used to configure virtual network gateway settings, but it does not have a -DiagnosticLogging parameter.
- D
Add-AzLogAnalyticsSolution
Why wrong: Incorrect. 'Add-AzLogAnalyticsSolution' installs a management solution (e.g., 'Azure VPN Gateway' solution) into a Log Analytics workspace, but it does not configure diagnostic settings for individual resources; diagnostic settings must be created separately.