Gets the specified virtual network peering.
GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/virtualNetworkPeerings/{virtualNetworkPeeringName}?api-version=2026-01-01
URI Parameters
| Name |
In |
Required |
Type |
Description |
|
resourceGroupName
|
path |
True
|
string
minLength: 1 maxLength: 90
|
The name of the resource group. The name is case insensitive.
|
|
subscriptionId
|
path |
True
|
string
(uuid)
|
The ID of the target subscription. The value must be an UUID.
|
|
virtualNetworkName
|
path |
True
|
string
|
The name of the virtual network.
|
|
virtualNetworkPeeringName
|
path |
True
|
string
|
The name of the virtual network peering.
|
|
api-version
|
query |
True
|
string
minLength: 1
|
The API version to use for this operation.
|
Responses
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 peering
Sample request
GET https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/peerTest/providers/Microsoft.Network/virtualNetworks/vnet1/virtualNetworkPeerings/peer?api-version=2026-01-01
/**
* Samples for VirtualNetworkPeerings Get.
*/
public final class Main {
/*
* x-ms-original-file: 2026-01-01/VirtualNetworkPeeringGet.json
*/
/**
* Sample code: Get peering.
*
* @param manager Entry point to NetworkManager.
*/
public static void getPeering(com.azure.resourcemanager.network.NetworkManager manager) {
manager.serviceClient().getVirtualNetworkPeerings().getWithResponse("peerTest", "vnet1", "peer",
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 virtual_network_peering_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="SUBSCRIPTION_ID",
)
response = client.virtual_network_peerings.get(
resource_group_name="peerTest",
virtual_network_name="vnet1",
virtual_network_peering_name="peer",
)
print(response)
# x-ms-original-file: 2026-01-01/VirtualNetworkPeeringGet.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/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v12"
)
// Generated from example definition: 2026-01-01/VirtualNetworkPeeringGet.json
func ExampleVirtualNetworkPeeringsClient_Get_getPeering() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armnetwork.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewVirtualNetworkPeeringsClient().Get(ctx, "peerTest", "vnet1", "peer", 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 = armnetwork.VirtualNetworkPeeringsClientGetResponse{
// VirtualNetworkPeering: armnetwork.VirtualNetworkPeering{
// Name: to.Ptr("peer"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/peerTest/providers/Microsoft.Network/virtualNetworks/vnet1/virtualNetworkPeerings/peer"),
// Properties: &armnetwork.VirtualNetworkPeeringPropertiesFormat{
// AllowForwardedTraffic: to.Ptr(true),
// AllowGatewayTransit: to.Ptr(false),
// AllowVirtualNetworkAccess: to.Ptr(true),
// PeeringState: to.Ptr(armnetwork.VirtualNetworkPeeringStateInitiated),
// PeeringSyncLevel: to.Ptr(armnetwork.VirtualNetworkPeeringLevelFullyInSync),
// ProvisioningState: to.Ptr(armnetwork.ProvisioningStateSucceeded),
// RemoteAddressSpace: &armnetwork.AddressSpace{
// AddressPrefixes: []*string{
// to.Ptr("12.0.0.0/8"),
// },
// },
// RemoteBgpCommunities: &armnetwork.VirtualNetworkBgpCommunities{
// RegionalCommunity: to.Ptr("12076:50004"),
// VirtualNetworkCommunity: to.Ptr("12076:20002"),
// },
// RemoteVirtualNetwork: &armnetwork.SubResource{
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/peerTest/providers/Microsoft.Network/virtualNetworks/vnet2"),
// },
// RemoteVirtualNetworkAddressSpace: &armnetwork.AddressSpace{
// AddressPrefixes: []*string{
// to.Ptr("12.0.0.0/8"),
// },
// },
// UseRemoteGateways: to.Ptr(false),
// },
// },
// }
}
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 specified virtual network peering.
*
* @summary gets the specified virtual network peering.
* x-ms-original-file: 2026-01-01/VirtualNetworkPeeringGet.json
*/
async function getPeering() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-0000-0000-0000-000000000000";
const client = new NetworkManagementClient(credential, subscriptionId);
const result = await client.virtualNetworkPeerings.get("peerTest", "vnet1", "peer");
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
Sample response
{
"name": "peer",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/peerTest/providers/Microsoft.Network/virtualNetworks/vnet1/virtualNetworkPeerings/peer",
"properties": {
"allowForwardedTraffic": true,
"allowGatewayTransit": false,
"allowVirtualNetworkAccess": true,
"peeringState": "Initiated",
"peeringSyncLevel": "FullyInSync",
"provisioningState": "Succeeded",
"remoteAddressSpace": {
"addressPrefixes": [
"12.0.0.0/8"
]
},
"remoteBgpCommunities": {
"regionalCommunity": "12076:50004",
"virtualNetworkCommunity": "12076:20002"
},
"remoteVirtualNetwork": {
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/peerTest/providers/Microsoft.Network/virtualNetworks/vnet2"
},
"remoteVirtualNetworkAddressSpace": {
"addressPrefixes": [
"12.0.0.0/8"
]
},
"useRemoteGateways": false
}
}
Get peering with remote virtual network encryption
Sample request
GET https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/peerTest/providers/Microsoft.Network/virtualNetworks/vnet1/virtualNetworkPeerings/peer?api-version=2026-01-01
/**
* Samples for VirtualNetworkPeerings Get.
*/
public final class Main {
/*
* x-ms-original-file: 2026-01-01/VirtualNetworkPeeringGetWithRemoteVirtualNetworkEncryption.json
*/
/**
* Sample code: Get peering with remote virtual network encryption.
*
* @param manager Entry point to NetworkManager.
*/
public static void
getPeeringWithRemoteVirtualNetworkEncryption(com.azure.resourcemanager.network.NetworkManager manager) {
manager.serviceClient().getVirtualNetworkPeerings().getWithResponse("peerTest", "vnet1", "peer",
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 virtual_network_peering_get_with_remote_virtual_network_encryption.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="SUBSCRIPTION_ID",
)
response = client.virtual_network_peerings.get(
resource_group_name="peerTest",
virtual_network_name="vnet1",
virtual_network_peering_name="peer",
)
print(response)
# x-ms-original-file: 2026-01-01/VirtualNetworkPeeringGetWithRemoteVirtualNetworkEncryption.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/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v12"
)
// Generated from example definition: 2026-01-01/VirtualNetworkPeeringGetWithRemoteVirtualNetworkEncryption.json
func ExampleVirtualNetworkPeeringsClient_Get_getPeeringWithRemoteVirtualNetworkEncryption() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armnetwork.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewVirtualNetworkPeeringsClient().Get(ctx, "peerTest", "vnet1", "peer", 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 = armnetwork.VirtualNetworkPeeringsClientGetResponse{
// VirtualNetworkPeering: armnetwork.VirtualNetworkPeering{
// Name: to.Ptr("peer"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/peerTest/providers/Microsoft.Network/virtualNetworks/vnet1/virtualNetworkPeerings/peer"),
// Properties: &armnetwork.VirtualNetworkPeeringPropertiesFormat{
// AllowForwardedTraffic: to.Ptr(true),
// AllowGatewayTransit: to.Ptr(false),
// AllowVirtualNetworkAccess: to.Ptr(true),
// PeeringState: to.Ptr(armnetwork.VirtualNetworkPeeringStateInitiated),
// ProvisioningState: to.Ptr(armnetwork.ProvisioningStateSucceeded),
// RemoteAddressSpace: &armnetwork.AddressSpace{
// AddressPrefixes: []*string{
// to.Ptr("12.0.0.0/8"),
// },
// },
// RemoteBgpCommunities: &armnetwork.VirtualNetworkBgpCommunities{
// RegionalCommunity: to.Ptr("12076:50004"),
// VirtualNetworkCommunity: to.Ptr("12076:20002"),
// },
// RemoteVirtualNetwork: &armnetwork.SubResource{
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/peerTest/providers/Microsoft.Network/virtualNetworks/vnet2"),
// },
// RemoteVirtualNetworkEncryption: &armnetwork.VirtualNetworkEncryption{
// Enabled: to.Ptr(true),
// Enforcement: to.Ptr(armnetwork.VirtualNetworkEncryptionEnforcementAllowUnencrypted),
// },
// UseRemoteGateways: to.Ptr(false),
// },
// },
// }
}
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 specified virtual network peering.
*
* @summary gets the specified virtual network peering.
* x-ms-original-file: 2026-01-01/VirtualNetworkPeeringGetWithRemoteVirtualNetworkEncryption.json
*/
async function getPeeringWithRemoteVirtualNetworkEncryption() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-0000-0000-0000-000000000000";
const client = new NetworkManagementClient(credential, subscriptionId);
const result = await client.virtualNetworkPeerings.get("peerTest", "vnet1", "peer");
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
Sample response
{
"name": "peer",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/peerTest/providers/Microsoft.Network/virtualNetworks/vnet1/virtualNetworkPeerings/peer",
"properties": {
"allowForwardedTraffic": true,
"allowGatewayTransit": false,
"allowVirtualNetworkAccess": true,
"peeringState": "Initiated",
"provisioningState": "Succeeded",
"remoteAddressSpace": {
"addressPrefixes": [
"12.0.0.0/8"
]
},
"remoteBgpCommunities": {
"regionalCommunity": "12076:50004",
"virtualNetworkCommunity": "12076:20002"
},
"remoteVirtualNetwork": {
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/peerTest/providers/Microsoft.Network/virtualNetworks/vnet2"
},
"remoteVirtualNetworkEncryption": {
"enabled": true,
"enforcement": "AllowUnencrypted"
},
"useRemoteGateways": false
}
}
Get subnet peering
Sample request
GET https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/peerTest/providers/Microsoft.Network/virtualNetworks/vnet1/virtualNetworkPeerings/peer?api-version=2026-01-01
/**
* Samples for VirtualNetworkPeerings Get.
*/
public final class Main {
/*
* x-ms-original-file: 2026-01-01/VirtualNetworkSubnetPeeringGet.json
*/
/**
* Sample code: Get subnet peering.
*
* @param manager Entry point to NetworkManager.
*/
public static void getSubnetPeering(com.azure.resourcemanager.network.NetworkManager manager) {
manager.serviceClient().getVirtualNetworkPeerings().getWithResponse("peerTest", "vnet1", "peer",
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 virtual_network_subnet_peering_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="SUBSCRIPTION_ID",
)
response = client.virtual_network_peerings.get(
resource_group_name="peerTest",
virtual_network_name="vnet1",
virtual_network_peering_name="peer",
)
print(response)
# x-ms-original-file: 2026-01-01/VirtualNetworkSubnetPeeringGet.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/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v12"
)
// Generated from example definition: 2026-01-01/VirtualNetworkSubnetPeeringGet.json
func ExampleVirtualNetworkPeeringsClient_Get_getSubnetPeering() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armnetwork.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewVirtualNetworkPeeringsClient().Get(ctx, "peerTest", "vnet1", "peer", 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 = armnetwork.VirtualNetworkPeeringsClientGetResponse{
// VirtualNetworkPeering: armnetwork.VirtualNetworkPeering{
// Name: to.Ptr("peer"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/peerTest/providers/Microsoft.Network/virtualNetworks/vnet1/virtualNetworkPeerings/peer"),
// Properties: &armnetwork.VirtualNetworkPeeringPropertiesFormat{
// AllowForwardedTraffic: to.Ptr(true),
// AllowGatewayTransit: to.Ptr(false),
// AllowVirtualNetworkAccess: to.Ptr(true),
// EnableOnlyIPv6Peering: to.Ptr(false),
// LocalAddressSpace: &armnetwork.AddressSpace{
// AddressPrefixes: []*string{
// to.Ptr("212.0.0.0/16"),
// to.Ptr("2002:2002::/64"),
// },
// },
// LocalSubnetNames: []*string{
// to.Ptr("Subnet1"),
// },
// LocalVirtualNetworkAddressSpace: &armnetwork.AddressSpace{
// AddressPrefixes: []*string{
// to.Ptr("212.0.0.0/16"),
// to.Ptr("2002:2002::/64"),
// },
// },
// PeerCompleteVnets: to.Ptr(false),
// PeeringState: to.Ptr(armnetwork.VirtualNetworkPeeringStateInitiated),
// PeeringSyncLevel: to.Ptr(armnetwork.VirtualNetworkPeeringLevelFullyInSync),
// ProvisioningState: to.Ptr(armnetwork.ProvisioningStateSucceeded),
// RemoteAddressSpace: &armnetwork.AddressSpace{
// AddressPrefixes: []*string{
// to.Ptr("12.0.0.0/8"),
// to.Ptr("2001:2001::/64"),
// },
// },
// RemoteBgpCommunities: &armnetwork.VirtualNetworkBgpCommunities{
// RegionalCommunity: to.Ptr("12076:50004"),
// VirtualNetworkCommunity: to.Ptr("12076:20002"),
// },
// RemoteSubnetNames: []*string{
// to.Ptr("Subnet2"),
// },
// RemoteVirtualNetwork: &armnetwork.SubResource{
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/peerTest/providers/Microsoft.Network/virtualNetworks/vnet2"),
// },
// RemoteVirtualNetworkAddressSpace: &armnetwork.AddressSpace{
// AddressPrefixes: []*string{
// to.Ptr("12.0.0.0/8"),
// to.Ptr("2001:2001::/64"),
// },
// },
// UseRemoteGateways: to.Ptr(false),
// },
// },
// }
}
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 specified virtual network peering.
*
* @summary gets the specified virtual network peering.
* x-ms-original-file: 2026-01-01/VirtualNetworkSubnetPeeringGet.json
*/
async function getSubnetPeering() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-0000-0000-0000-000000000000";
const client = new NetworkManagementClient(credential, subscriptionId);
const result = await client.virtualNetworkPeerings.get("peerTest", "vnet1", "peer");
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
Sample response
{
"name": "peer",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/peerTest/providers/Microsoft.Network/virtualNetworks/vnet1/virtualNetworkPeerings/peer",
"properties": {
"allowForwardedTraffic": true,
"allowGatewayTransit": false,
"allowVirtualNetworkAccess": true,
"enableOnlyIPv6Peering": false,
"localAddressSpace": {
"addressPrefixes": [
"212.0.0.0/16",
"2002:2002::/64"
]
},
"localSubnetNames": [
"Subnet1"
],
"localVirtualNetworkAddressSpace": {
"addressPrefixes": [
"212.0.0.0/16",
"2002:2002::/64"
]
},
"peerCompleteVnets": false,
"peeringState": "Initiated",
"peeringSyncLevel": "FullyInSync",
"provisioningState": "Succeeded",
"remoteAddressSpace": {
"addressPrefixes": [
"12.0.0.0/8",
"2001:2001::/64"
]
},
"remoteBgpCommunities": {
"regionalCommunity": "12076:50004",
"virtualNetworkCommunity": "12076:20002"
},
"remoteSubnetNames": [
"Subnet2"
],
"remoteVirtualNetwork": {
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/peerTest/providers/Microsoft.Network/virtualNetworks/vnet2"
},
"remoteVirtualNetworkAddressSpace": {
"addressPrefixes": [
"12.0.0.0/8",
"2001:2001::/64"
]
},
"useRemoteGateways": false
}
}
Get V6 subnet peering
Sample request
GET https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/peerTest/providers/Microsoft.Network/virtualNetworks/vnet1/virtualNetworkPeerings/peer?api-version=2026-01-01
/**
* Samples for VirtualNetworkPeerings Get.
*/
public final class Main {
/*
* x-ms-original-file: 2026-01-01/VirtualNetworkV6SubnetPeeringGet.json
*/
/**
* Sample code: Get V6 subnet peering.
*
* @param manager Entry point to NetworkManager.
*/
public static void getV6SubnetPeering(com.azure.resourcemanager.network.NetworkManager manager) {
manager.serviceClient().getVirtualNetworkPeerings().getWithResponse("peerTest", "vnet1", "peer",
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 virtual_network_v6_subnet_peering_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="SUBSCRIPTION_ID",
)
response = client.virtual_network_peerings.get(
resource_group_name="peerTest",
virtual_network_name="vnet1",
virtual_network_peering_name="peer",
)
print(response)
# x-ms-original-file: 2026-01-01/VirtualNetworkV6SubnetPeeringGet.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/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v12"
)
// Generated from example definition: 2026-01-01/VirtualNetworkV6SubnetPeeringGet.json
func ExampleVirtualNetworkPeeringsClient_Get_getV6SubnetPeering() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armnetwork.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewVirtualNetworkPeeringsClient().Get(ctx, "peerTest", "vnet1", "peer", 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 = armnetwork.VirtualNetworkPeeringsClientGetResponse{
// VirtualNetworkPeering: armnetwork.VirtualNetworkPeering{
// Name: to.Ptr("peer"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/peerTest/providers/Microsoft.Network/virtualNetworks/vnet1/virtualNetworkPeerings/peer"),
// Properties: &armnetwork.VirtualNetworkPeeringPropertiesFormat{
// AllowForwardedTraffic: to.Ptr(true),
// AllowGatewayTransit: to.Ptr(false),
// AllowVirtualNetworkAccess: to.Ptr(true),
// EnableOnlyIPv6Peering: to.Ptr(true),
// LocalAddressSpace: &armnetwork.AddressSpace{
// AddressPrefixes: []*string{
// to.Ptr("2002:2002::/64"),
// },
// },
// LocalSubnetNames: []*string{
// to.Ptr("Subnet1"),
// },
// LocalVirtualNetworkAddressSpace: &armnetwork.AddressSpace{
// AddressPrefixes: []*string{
// to.Ptr("2002:2002::/64"),
// },
// },
// PeerCompleteVnets: to.Ptr(false),
// PeeringState: to.Ptr(armnetwork.VirtualNetworkPeeringStateInitiated),
// PeeringSyncLevel: to.Ptr(armnetwork.VirtualNetworkPeeringLevelFullyInSync),
// ProvisioningState: to.Ptr(armnetwork.ProvisioningStateSucceeded),
// RemoteAddressSpace: &armnetwork.AddressSpace{
// AddressPrefixes: []*string{
// to.Ptr("2001:2001::/64"),
// },
// },
// RemoteBgpCommunities: &armnetwork.VirtualNetworkBgpCommunities{
// RegionalCommunity: to.Ptr("12076:50004"),
// VirtualNetworkCommunity: to.Ptr("12076:20002"),
// },
// RemoteSubnetNames: []*string{
// to.Ptr("Subnet2"),
// },
// RemoteVirtualNetwork: &armnetwork.SubResource{
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/peerTest/providers/Microsoft.Network/virtualNetworks/vnet2"),
// },
// RemoteVirtualNetworkAddressSpace: &armnetwork.AddressSpace{
// AddressPrefixes: []*string{
// to.Ptr("2001:2001::/64"),
// },
// },
// UseRemoteGateways: to.Ptr(false),
// },
// },
// }
}
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 specified virtual network peering.
*
* @summary gets the specified virtual network peering.
* x-ms-original-file: 2026-01-01/VirtualNetworkV6SubnetPeeringGet.json
*/
async function getV6SubnetPeering() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-0000-0000-0000-000000000000";
const client = new NetworkManagementClient(credential, subscriptionId);
const result = await client.virtualNetworkPeerings.get("peerTest", "vnet1", "peer");
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
Sample response
{
"name": "peer",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/peerTest/providers/Microsoft.Network/virtualNetworks/vnet1/virtualNetworkPeerings/peer",
"properties": {
"allowForwardedTraffic": true,
"allowGatewayTransit": false,
"allowVirtualNetworkAccess": true,
"enableOnlyIPv6Peering": true,
"localAddressSpace": {
"addressPrefixes": [
"2002:2002::/64"
]
},
"localSubnetNames": [
"Subnet1"
],
"localVirtualNetworkAddressSpace": {
"addressPrefixes": [
"2002:2002::/64"
]
},
"peerCompleteVnets": false,
"peeringState": "Initiated",
"peeringSyncLevel": "FullyInSync",
"provisioningState": "Succeeded",
"remoteAddressSpace": {
"addressPrefixes": [
"2001:2001::/64"
]
},
"remoteBgpCommunities": {
"regionalCommunity": "12076:50004",
"virtualNetworkCommunity": "12076:20002"
},
"remoteSubnetNames": [
"Subnet2"
],
"remoteVirtualNetwork": {
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/peerTest/providers/Microsoft.Network/virtualNetworks/vnet2"
},
"remoteVirtualNetworkAddressSpace": {
"addressPrefixes": [
"2001:2001::/64"
]
},
"useRemoteGateways": false
}
}
Definitions
AddressSpace
Object
AddressSpace contains an array of IP address ranges that can be used by subnets of the virtual network.
| Name |
Type |
Description |
|
addressPrefixes
|
string[]
|
A list of address blocks reserved for this virtual network in CIDR notation.
|
|
ipamPoolPrefixAllocations
|
IpamPoolPrefixAllocation[]
|
A list of IPAM Pools allocating IP address prefixes.
|
CloudError
Object
An error response from the service.
CloudErrorBody
Object
An error response from the service.
| Name |
Type |
Description |
|
code
|
string
|
An identifier for the error. Codes are invariant and are intended to be consumed programmatically.
|
|
details
|
CloudErrorBody[]
|
A list of additional details about the error.
|
|
message
|
string
|
A message describing the error, intended to be suitable for display in a user interface.
|
|
target
|
string
|
The target of the particular error. For example, the name of the property in error.
|
IpamPoolPrefixAllocation
Object
IpamPool prefix allocation reference.
| Name |
Type |
Description |
|
allocatedAddressPrefixes
|
string[]
|
List of assigned IP address prefixes in the IpamPool of the associated resource.
|
|
numberOfIpAddresses
|
string
|
Number of IP addresses to allocate.
|
|
pool.id
|
string
(arm-id)
|
Resource id of the associated Azure IpamPool resource.
|
ProvisioningState
Enumeration
Provisioning states of a resource.
| Value |
Description |
|
Failed
|
Failed
|
|
Succeeded
|
Succeeded
|
|
Canceled
|
Canceled
|
|
Creating
|
Creating
|
|
Updating
|
Updating
|
|
Deleting
|
Deleting
|
SubResource
Object
Reference to another subresource.
| Name |
Type |
Description |
|
id
|
string
|
Resource ID.
|
VirtualNetworkBgpCommunities
Object
Bgp Communities sent over ExpressRoute with each route corresponding to a prefix in this VNET.
| Name |
Type |
Description |
|
regionalCommunity
|
string
|
The BGP community associated with the region of the virtual network.
|
|
virtualNetworkCommunity
|
string
|
The BGP community associated with the virtual network.
|
VirtualNetworkEncryption
Object
Indicates if encryption is enabled on virtual network and if VM without encryption is allowed in encrypted VNet.
| Name |
Type |
Description |
|
enabled
|
boolean
|
Indicates if encryption is enabled on the virtual network.
|
|
enforcement
|
VirtualNetworkEncryptionEnforcement
|
If the encrypted VNet allows VM that does not support encryption. This field is for future support, AllowUnencrypted is the only supported value at general availability.
|
VirtualNetworkEncryptionEnforcement
Enumeration
If the encrypted VNet allows VM that does not support encryption. This field is for future support, AllowUnencrypted is the only supported value at general availability.
| Value |
Description |
|
DropUnencrypted
|
DropUnencrypted
|
|
AllowUnencrypted
|
AllowUnencrypted
|
VirtualNetworkPeering
Object
Peerings in a virtual network resource.
| Name |
Type |
Description |
|
etag
|
string
|
A unique read-only string that changes whenever the resource is updated.
|
|
id
|
string
|
Resource ID.
|
|
name
|
string
|
Name of the resource.
|
|
properties.allowForwardedTraffic
|
boolean
|
Whether the forwarded traffic from the VMs in the local virtual network will be allowed/disallowed in remote virtual network.
|
|
properties.allowGatewayTransit
|
boolean
|
If gateway links can be used in remote virtual networking to link to this virtual network.
|
|
properties.allowVirtualNetworkAccess
|
boolean
|
Whether the VMs in the local virtual network space would be able to access the VMs in remote virtual network space.
|
|
properties.doNotVerifyRemoteGateways
|
boolean
|
If we need to verify the provisioning state of the remote gateway.
|
|
properties.enableOnlyIPv6Peering
|
boolean
|
Whether only Ipv6 address space is peered for subnet peering.
|
|
properties.localAddressSpace
|
AddressSpace
|
The local address space of the local virtual network that is peered.
|
|
properties.localSubnetNames
|
string[]
|
List of local subnet names that are subnet peered with remote virtual network.
|
|
properties.localVirtualNetworkAddressSpace
|
AddressSpace
|
The current local address space of the local virtual network that is peered.
|
|
properties.peerCompleteVnets
|
boolean
|
Whether complete virtual network address space is peered.
|
|
properties.peeringState
|
VirtualNetworkPeeringState
|
The status of the virtual network peering.
|
|
properties.peeringSyncLevel
|
VirtualNetworkPeeringLevel
|
The peering sync status of the virtual network peering.
|
|
properties.provisioningState
|
ProvisioningState
|
The provisioning state of the virtual network peering resource.
|
|
properties.remoteAddressSpace
|
AddressSpace
|
The reference to the address space peered with the remote virtual network.
|
|
properties.remoteBgpCommunities
|
VirtualNetworkBgpCommunities
|
The reference to the remote virtual network's Bgp Communities.
|
|
properties.remoteSubnetNames
|
string[]
|
List of remote subnet names from remote virtual network that are subnet peered.
|
|
properties.remoteVirtualNetwork
|
SubResource
|
The reference to the remote virtual network. The remote virtual network can be in the same or different region (preview). See here to register for the preview and learn more (https://docs.microsoft.com/en-us/azure/virtual-network/virtual-network-create-peering).
|
|
properties.remoteVirtualNetworkAddressSpace
|
AddressSpace
|
The reference to the current address space of the remote virtual network.
|
|
properties.remoteVirtualNetworkEncryption
|
VirtualNetworkEncryption
|
The reference to the remote virtual network's encryption
|
|
properties.resourceGuid
|
string
|
The resourceGuid property of the Virtual Network peering resource.
|
|
properties.useRemoteGateways
|
boolean
|
If remote gateways can be used on this virtual network. If the flag is set to true, and allowGatewayTransit on remote peering is also true, virtual network will use gateways of remote virtual network for transit. Only one peering can have this flag set to true. This flag cannot be set if virtual network already has a gateway.
|
|
type
|
string
|
Resource type.
|
VirtualNetworkPeeringLevel
Enumeration
The peering sync status of the virtual network peering.
| Value |
Description |
|
FullyInSync
|
FullyInSync
|
|
RemoteNotInSync
|
RemoteNotInSync
|
|
LocalNotInSync
|
LocalNotInSync
|
|
LocalAndRemoteNotInSync
|
LocalAndRemoteNotInSync
|
VirtualNetworkPeeringState
Enumeration
The status of the virtual network peering.
| Value |
Description |
|
Initiated
|
Initiated
|
|
Connected
|
Connected
|
|
Disconnected
|
Disconnected
|