Request Boddy Json Syntax: Network Watcher Rest API
Category: azure scripting and command line tools
Question
Supong kichu on Mon, 09 Jul 2018 17:44:57
How can I create the JSON payload(Request body) to check the connectivity using network watcher Rest API.
What is the expected payload? Could someone please give me a example?
https://docs.microsoft.com/en-us/rest/api/network-watcher/networkwatchers/checkconnectivity
Replies
CHEEKATLAPRADEEP-MSFT on Tue, 10 Jul 2018 08:42:22
This example checks connectivity to a destination virtual machine over port 80.
$subscriptionId = "00000000-0000-0000-0000-000000000000" $resourceGroupName = "NetworkWatcherRG" $networkWatcherName = "NetworkWatcher_westcentralus" $sourceResourceId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ContosoRG/providers/Microsoft.Compute/virtualMachines/MultiTierApp0" $destinationAddress = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ContosoRG/providers/Microsoft.Compute/virtualMachines/Database0" $destinationPort = "0" $requestBody = @" { 'source': { 'resourceId': '${sourceResourceId}', 'port': 0 }, 'destination': { 'resourceId': '${destinationAddress}', 'port': ${destinationPort} } } "@ $response = armclient post "https://management.azure.com/subscriptions/${subscriptionId}/ResourceGroups/${resourceGroupName}/providers/Microsoft.Network/networkWatchers/${networkWatcherName}/connectivityCheck?api-version=2017-03-01" $requestBody
For more details, refer check connectivity using REST API.
-----------------------------------------------------------------------------------------------
If this answer was helpful, click “Mark as Answer” or “Up-Vote”. To provide additional feedback on your forum experience, click here
CHEEKATLAPRADEEP-MSFT on Thu, 12 Jul 2018 07:21:29
Just Checking in to see if the above answer helped. If this answers your query, do click “Mark as Answer” and Up-Vote for the same. And, if you have any further query do let us know.