Azure / azure-sdk-for-python

This repository is for active development of the Azure SDK for Python. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/python/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-python.
MIT License
4.62k stars 2.83k forks source link

Vnet Peering example #1208

Closed madhukargilla closed 2 years ago

madhukargilla commented 7 years ago

HI,

Can you point us to a Vnet peering example, using the Python SDK please.

Thanks

lmazuel commented 7 years ago

Hi @madhukargilla

We unfortunately don't have a Python sample right now. I will create a task for that and keep this issue open until it's done. Thank you,

ecgg commented 7 years ago

If this could help, I got it working like this somehow:

Assumes RG1 with VNET1 and RG2 with VNET21 There's a VPN gateway in VNET2 for which we'll allow traffic from VNET1

from azure.mgmt.network import NetworkManagementClient
from azure.mgmt.network.models import SubResource
from azure.mgmt.network.models import VirtualNetworkPeering
from azure.mgmt.resource import ResourceManagementClient

res1 = resource_client.resources.get("rg1", "Microsoft.Network", "", "virtualNetworks", "vnet1", "2017-06-01")
res2 = resource_client.resources.get("rg2", "Microsoft.Network", "", "virtualNetworks", "vnet2", "2017-06-01")

subres1 = SubResource(id=res1.id)
subres2 = SubResource(id=res2.id)

peering_params1 =  VirtualNetworkPeering(allow_virtual_network_access=True, use_remote_gateways=True, remote_virtual_network=subres1)
peering_params2 =  VirtualNetworkPeering(allow_virtual_network_access=True, use_remote_gateways=False, allow_gateway_transit=True, remote_virtual_network=subres2)

poller1 = network_client.virtual_network_peerings.create_or_update("rg2", "vnet2", "rg2-rg1-peering", peering_params1)
poller2 = network_client.virtual_network_peerings.create_or_update("rg1", "vnet1", "rg1-rg2-peering", peering_params2)
lmazuel commented 7 years ago

Thanks @ecgg !

ghost commented 4 years ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @aznetsuppgithub.

xiangyan99 commented 2 years ago

@madhukargilla could you check if this works for you?

ghost commented 2 years ago

Hi, we're sending this friendly reminder because we haven't heard back from you in a while. We need more information about this issue to help address it. Please be sure to give us your input within the next 7 days. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!

ghost commented 2 years ago

Hi @madhukargilla. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text “/unresolve” to remove the “issue-addressed” label and continue the conversation.

ghost commented 2 years ago

Hi @madhukargilla, since you haven’t asked that we “/unresolve” the issue, we’ll close this out. If you believe further discussion is needed, please add a comment “/unresolve” to reopen the issue.