Gets the current network topology by resource group.
POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/topology?api-version=2023-09-01
URI Parameters
Name |
In |
Required |
Type |
Description |
networkWatcherName
|
path |
True
|
string
|
The name of the network watcher.
|
resourceGroupName
|
path |
True
|
string
|
The name of the resource group.
|
subscriptionId
|
path |
True
|
string
|
The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.
|
api-version
|
query |
True
|
string
|
Client API version.
|
Request Body
Name |
Type |
Description |
targetResourceGroupName
|
string
|
The name of the target resource group to perform topology on.
|
targetSubnet
|
SubResource
|
The reference to the Subnet resource.
|
targetVirtualNetwork
|
SubResource
|
The reference to the Virtual Network resource.
|
Responses
Name |
Type |
Description |
200 OK
|
Topology
|
Request successful. The operation returns the topology of resource group.
|
Other Status Codes
|
ErrorResponse
|
Error response describing why the operation failed.
|
Security
azure_auth
Azure Active Directory OAuth2 Flow.
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
Name |
Description |
user_impersonation
|
impersonate your user account
|
Examples
Get Topology
Sample Request
POST https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/networkWatchers/nw1/topology?api-version=2023-09-01
{
"targetResourceGroupName": "rg2"
}
import com.azure.resourcemanager.network.models.TopologyParameters;
/**
* Samples for NetworkWatchers GetTopology.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/network/resource-manager/Microsoft.Network/stable/2023-09-01/examples/NetworkWatcherTopologyGet.
* json
*/
/**
* Sample code: Get Topology.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void getTopology(com.azure.resourcemanager.AzureResourceManager azure) {
azure.networks().manager().serviceClient().getNetworkWatchers().getTopologyWithResponse("rg1", "nw1",
new TopologyParameters().withTargetResourceGroupName("rg2"), com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.network import NetworkManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-network
# USAGE
python network_watcher_topology_get.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = NetworkManagementClient(
credential=DefaultAzureCredential(),
subscription_id="subid",
)
response = client.network_watchers.get_topology(
resource_group_name="rg1",
network_watcher_name="nw1",
parameters={"targetResourceGroupName": "rg2"},
)
print(response)
# x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2023-09-01/examples/NetworkWatcherTopologyGet.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armnetwork_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v5"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d4205894880b989ede35d62d97c8e901ed14fb5a/specification/network/resource-manager/Microsoft.Network/stable/2023-09-01/examples/NetworkWatcherTopologyGet.json
func ExampleWatchersClient_GetTopology() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armnetwork.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewWatchersClient().GetTopology(ctx, "rg1", "nw1", armnetwork.TopologyParameters{
TargetResourceGroupName: to.Ptr("rg2"),
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.Topology = armnetwork.Topology{
// CreatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-02T19:31:55.946Z"); return t}()),
// ID: to.Ptr("ce592f46-8164-4bf2-ad36-b8e4acf6fb68"),
// LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-05-27T00:00:13.200Z"); return t}()),
// Resources: []*armnetwork.TopologyResource{
// {
// Name: to.Ptr("MultiTierApp0"),
// Associations: []*armnetwork.TopologyAssociation{
// {
// Name: to.Ptr("appNic0"),
// AssociationType: to.Ptr(armnetwork.AssociationTypeContains),
// ResourceID: to.Ptr("/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/networkInterfaces/appNic0"),
// },
// {
// Name: to.Ptr("appNic10"),
// AssociationType: to.Ptr(armnetwork.AssociationTypeContains),
// ResourceID: to.Ptr("/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/networkInterfaces/appNic10"),
// }},
// ID: to.Ptr("/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Compute/virtualMachines/MultiTierApp0"),
// Location: to.Ptr("westus"),
// }},
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { NetworkManagementClient } = require("@azure/arm-network");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Gets the current network topology by resource group.
*
* @summary Gets the current network topology by resource group.
* x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2023-09-01/examples/NetworkWatcherTopologyGet.json
*/
async function getTopology() {
const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid";
const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1";
const networkWatcherName = "nw1";
const parameters = { targetResourceGroupName: "rg2" };
const credential = new DefaultAzureCredential();
const client = new NetworkManagementClient(credential, subscriptionId);
const result = await client.networkWatchers.getTopology(
resourceGroupName,
networkWatcherName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using System;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.Network;
using Azure.ResourceManager.Network.Models;
using Azure.ResourceManager.Resources;
// Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2023-09-01/examples/NetworkWatcherTopologyGet.json
// this example is just showing the usage of "NetworkWatchers_GetTopology" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this NetworkWatcherResource created on azure
// for more information of creating NetworkWatcherResource, please refer to the document of NetworkWatcherResource
string subscriptionId = "subid";
string resourceGroupName = "rg1";
string networkWatcherName = "nw1";
ResourceIdentifier networkWatcherResourceId = NetworkWatcherResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkWatcherName);
NetworkWatcherResource networkWatcher = client.GetNetworkWatcherResource(networkWatcherResourceId);
// invoke the operation
TopologyContent content = new TopologyContent()
{
TargetResourceGroupName = "rg2",
};
NetworkTopology result = await networkWatcher.GetTopologyAsync(content);
Console.WriteLine($"Succeeded: {result}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample Response
{
"id": "ce592f46-8164-4bf2-ad36-b8e4acf6fb68",
"createdDateTime": "2017-08-02T19:31:55.9461781Z",
"lastModified": "2017-05-27T00:00:13.2005337Z",
"resources": [
{
"name": "MultiTierApp0",
"id": "/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Compute/virtualMachines/MultiTierApp0",
"location": "westus",
"associations": [
{
"name": "appNic0",
"resourceId": "/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/networkInterfaces/appNic0",
"associationType": "Contains"
},
{
"name": "appNic10",
"resourceId": "/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/networkInterfaces/appNic10",
"associationType": "Contains"
}
]
}
]
}
Definitions
AssociationType
The association type of the child resource to the parent resource.
Name |
Type |
Description |
Associated
|
string
|
|
Contains
|
string
|
|
ErrorDetails
Common error details representation.
Name |
Type |
Description |
code
|
string
|
Error code.
|
message
|
string
|
Error message.
|
target
|
string
|
Error target.
|
ErrorResponse
The error object.
Name |
Type |
Description |
error
|
ErrorDetails
|
Error
The error details object.
|
SubResource
Reference to another subresource.
Name |
Type |
Description |
id
|
string
|
Resource ID.
|
Topology
Topology of the specified resource group.
Name |
Type |
Description |
createdDateTime
|
string
|
The datetime when the topology was initially created for the resource group.
|
id
|
string
|
GUID representing the operation id.
|
lastModified
|
string
|
The datetime when the topology was last modified.
|
resources
|
TopologyResource[]
|
A list of topology resources.
|
TopologyAssociation
Resources that have an association with the parent resource.
Name |
Type |
Description |
associationType
|
AssociationType
|
The association type of the child resource to the parent resource.
|
name
|
string
|
The name of the resource that is associated with the parent resource.
|
resourceId
|
string
|
The ID of the resource that is associated with the parent resource.
|
TopologyParameters
Parameters that define the representation of topology.
Name |
Type |
Description |
targetResourceGroupName
|
string
|
The name of the target resource group to perform topology on.
|
targetSubnet
|
SubResource
|
The reference to the Subnet resource.
|
targetVirtualNetwork
|
SubResource
|
The reference to the Virtual Network resource.
|
TopologyResource
The network resource topology information for the given resource group.
Name |
Type |
Description |
associations
|
TopologyAssociation[]
|
Holds the associations the resource has with other resources in the resource group.
|
id
|
string
|
ID of the resource.
|
location
|
string
|
Resource location.
|
name
|
string
|
Name of the resource.
|