Extract Returned values from 'VirtualNetworkPeering object










1















How Can I extract the atrribute values returned from list of peered virtual networks.
I executed this command and I need to extract the Network ID



list_all = network_client.virtual_network_peerings.list(
GROUP_NAME,
VNET_NAME
)


for peer in list_all:



print(peer)



and I get this value for from the print above:



'additional_properties': 'type': 'Microsoft.Network/virtualNetworks/virtualNetworkPeerings', 
'id': '/subscriptions/c70b9b-efd6-497d-98d8-e1e1d497425/resourceGroups/azure-sample-group-virtual-machines/providers/Microsoft.Network/virtualNetworks/azure-sample-vnet/virtualNetworkPeerings/sample-vnetpeer',
'allow_virtual_network_access': True,
'allow_forwarded_traffic': True,
'allow_gateway_transit': False,
'use_remote_gateways': False,
'remote_virtual_network': <azure.mgmt.network.v2018_08_01.models.sub_resource_py3.SubResource object at 0x048D6950>,
'remote_address_space': <azure.mgmt.network.v2018_08_01.models.address_space_py3.AddressSpace object at 0x048D68D0>,
'peering_state': 'Initiated',
'provisioning_state': 'Succeeded',
'name': 'sample-vnetpeer',
'etag': 'W/"653f7f94-3c4e-4275-bfdf-0bbbd9beb6e4"'


How can I get this value "remote_virtual_network"?












share|improve this question




























    1















    How Can I extract the atrribute values returned from list of peered virtual networks.
    I executed this command and I need to extract the Network ID



    list_all = network_client.virtual_network_peerings.list(
    GROUP_NAME,
    VNET_NAME
    )


    for peer in list_all:



    print(peer)



    and I get this value for from the print above:



    'additional_properties': 'type': 'Microsoft.Network/virtualNetworks/virtualNetworkPeerings', 
    'id': '/subscriptions/c70b9b-efd6-497d-98d8-e1e1d497425/resourceGroups/azure-sample-group-virtual-machines/providers/Microsoft.Network/virtualNetworks/azure-sample-vnet/virtualNetworkPeerings/sample-vnetpeer',
    'allow_virtual_network_access': True,
    'allow_forwarded_traffic': True,
    'allow_gateway_transit': False,
    'use_remote_gateways': False,
    'remote_virtual_network': <azure.mgmt.network.v2018_08_01.models.sub_resource_py3.SubResource object at 0x048D6950>,
    'remote_address_space': <azure.mgmt.network.v2018_08_01.models.address_space_py3.AddressSpace object at 0x048D68D0>,
    'peering_state': 'Initiated',
    'provisioning_state': 'Succeeded',
    'name': 'sample-vnetpeer',
    'etag': 'W/"653f7f94-3c4e-4275-bfdf-0bbbd9beb6e4"'


    How can I get this value "remote_virtual_network"?












    share|improve this question


























      1












      1








      1








      How Can I extract the atrribute values returned from list of peered virtual networks.
      I executed this command and I need to extract the Network ID



      list_all = network_client.virtual_network_peerings.list(
      GROUP_NAME,
      VNET_NAME
      )


      for peer in list_all:



      print(peer)



      and I get this value for from the print above:



      'additional_properties': 'type': 'Microsoft.Network/virtualNetworks/virtualNetworkPeerings', 
      'id': '/subscriptions/c70b9b-efd6-497d-98d8-e1e1d497425/resourceGroups/azure-sample-group-virtual-machines/providers/Microsoft.Network/virtualNetworks/azure-sample-vnet/virtualNetworkPeerings/sample-vnetpeer',
      'allow_virtual_network_access': True,
      'allow_forwarded_traffic': True,
      'allow_gateway_transit': False,
      'use_remote_gateways': False,
      'remote_virtual_network': <azure.mgmt.network.v2018_08_01.models.sub_resource_py3.SubResource object at 0x048D6950>,
      'remote_address_space': <azure.mgmt.network.v2018_08_01.models.address_space_py3.AddressSpace object at 0x048D68D0>,
      'peering_state': 'Initiated',
      'provisioning_state': 'Succeeded',
      'name': 'sample-vnetpeer',
      'etag': 'W/"653f7f94-3c4e-4275-bfdf-0bbbd9beb6e4"'


      How can I get this value "remote_virtual_network"?












      share|improve this question
















      How Can I extract the atrribute values returned from list of peered virtual networks.
      I executed this command and I need to extract the Network ID



      list_all = network_client.virtual_network_peerings.list(
      GROUP_NAME,
      VNET_NAME
      )


      for peer in list_all:



      print(peer)



      and I get this value for from the print above:



      'additional_properties': 'type': 'Microsoft.Network/virtualNetworks/virtualNetworkPeerings', 
      'id': '/subscriptions/c70b9b-efd6-497d-98d8-e1e1d497425/resourceGroups/azure-sample-group-virtual-machines/providers/Microsoft.Network/virtualNetworks/azure-sample-vnet/virtualNetworkPeerings/sample-vnetpeer',
      'allow_virtual_network_access': True,
      'allow_forwarded_traffic': True,
      'allow_gateway_transit': False,
      'use_remote_gateways': False,
      'remote_virtual_network': <azure.mgmt.network.v2018_08_01.models.sub_resource_py3.SubResource object at 0x048D6950>,
      'remote_address_space': <azure.mgmt.network.v2018_08_01.models.address_space_py3.AddressSpace object at 0x048D68D0>,
      'peering_state': 'Initiated',
      'provisioning_state': 'Succeeded',
      'name': 'sample-vnetpeer',
      'etag': 'W/"653f7f94-3c4e-4275-bfdf-0bbbd9beb6e4"'


      How can I get this value "remote_virtual_network"?









      azure-sdk-python






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 15 '18 at 7:45









      Ketan Yekale

      1,28221424




      1,28221424










      asked Nov 15 '18 at 2:45









      SamrSamr

      173




      173






















          2 Answers
          2






          active

          oldest

          votes


















          0














          My feeling is that your question is actually more a Python question than an Azure question. Assuming in your application this field is set with values, then remote_virtual_network is a SubResource meaning it only has one attribute: id



          for peer in list_all:
          remote_virtual_network_id = peer.remote_virtual_network.id


          This guy is an actual virtual network, so if you want details about it you need to get it with network_client.virtual_networks.get:
          https://docs.microsoft.com/en-us/python/api/azure-mgmt-network/azure.mgmt.network.v2018_08_01.operations.virtualnetworksoperations?view=azure-python#get



          The tricky part is you get an ID, but VNet get asks for a RG name and VNet name, you can use the ARM ID parser for that:



          https://docs.microsoft.com/en-us/python/api/msrestazure/msrestazure.tools?view=azure-python#parse-resource-id






          share|improve this answer























          • Thanks Laurent, That what I was looking for a python question how I would retrieve the value, adding the id did it

            – Samr
            Nov 16 '18 at 18:57


















          0














          'remote_virtual_network': ,
          'remote_address_space':



          I will try this out and get back:



          This command is analogous to "get-azurermvirtualnetworkpeering -ResourceGroupName -VirtualNetworkName -Name" on Azure PowerShell.



          remote_virtual_network you don't have one. You will only get this if you have Remote Gateway enabled and the Peer will learn the IP address of the Remote (On-premise site) that you are trying to connect.



          To get this value, deploy a gateway in the Vnet and connect it to Say "Vnet-S2S-test" with a gateway deployed there as well.



          Once, the Site-to-site between the Vnets are up. You can execute the command and you should see those fields populated with the local network gateway details.






          share|improve this answer






















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53311687%2fextract-returned-values-from-virtualnetworkpeering-object%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            My feeling is that your question is actually more a Python question than an Azure question. Assuming in your application this field is set with values, then remote_virtual_network is a SubResource meaning it only has one attribute: id



            for peer in list_all:
            remote_virtual_network_id = peer.remote_virtual_network.id


            This guy is an actual virtual network, so if you want details about it you need to get it with network_client.virtual_networks.get:
            https://docs.microsoft.com/en-us/python/api/azure-mgmt-network/azure.mgmt.network.v2018_08_01.operations.virtualnetworksoperations?view=azure-python#get



            The tricky part is you get an ID, but VNet get asks for a RG name and VNet name, you can use the ARM ID parser for that:



            https://docs.microsoft.com/en-us/python/api/msrestazure/msrestazure.tools?view=azure-python#parse-resource-id






            share|improve this answer























            • Thanks Laurent, That what I was looking for a python question how I would retrieve the value, adding the id did it

              – Samr
              Nov 16 '18 at 18:57















            0














            My feeling is that your question is actually more a Python question than an Azure question. Assuming in your application this field is set with values, then remote_virtual_network is a SubResource meaning it only has one attribute: id



            for peer in list_all:
            remote_virtual_network_id = peer.remote_virtual_network.id


            This guy is an actual virtual network, so if you want details about it you need to get it with network_client.virtual_networks.get:
            https://docs.microsoft.com/en-us/python/api/azure-mgmt-network/azure.mgmt.network.v2018_08_01.operations.virtualnetworksoperations?view=azure-python#get



            The tricky part is you get an ID, but VNet get asks for a RG name and VNet name, you can use the ARM ID parser for that:



            https://docs.microsoft.com/en-us/python/api/msrestazure/msrestazure.tools?view=azure-python#parse-resource-id






            share|improve this answer























            • Thanks Laurent, That what I was looking for a python question how I would retrieve the value, adding the id did it

              – Samr
              Nov 16 '18 at 18:57













            0












            0








            0







            My feeling is that your question is actually more a Python question than an Azure question. Assuming in your application this field is set with values, then remote_virtual_network is a SubResource meaning it only has one attribute: id



            for peer in list_all:
            remote_virtual_network_id = peer.remote_virtual_network.id


            This guy is an actual virtual network, so if you want details about it you need to get it with network_client.virtual_networks.get:
            https://docs.microsoft.com/en-us/python/api/azure-mgmt-network/azure.mgmt.network.v2018_08_01.operations.virtualnetworksoperations?view=azure-python#get



            The tricky part is you get an ID, but VNet get asks for a RG name and VNet name, you can use the ARM ID parser for that:



            https://docs.microsoft.com/en-us/python/api/msrestazure/msrestazure.tools?view=azure-python#parse-resource-id






            share|improve this answer













            My feeling is that your question is actually more a Python question than an Azure question. Assuming in your application this field is set with values, then remote_virtual_network is a SubResource meaning it only has one attribute: id



            for peer in list_all:
            remote_virtual_network_id = peer.remote_virtual_network.id


            This guy is an actual virtual network, so if you want details about it you need to get it with network_client.virtual_networks.get:
            https://docs.microsoft.com/en-us/python/api/azure-mgmt-network/azure.mgmt.network.v2018_08_01.operations.virtualnetworksoperations?view=azure-python#get



            The tricky part is you get an ID, but VNet get asks for a RG name and VNet name, you can use the ARM ID parser for that:



            https://docs.microsoft.com/en-us/python/api/msrestazure/msrestazure.tools?view=azure-python#parse-resource-id







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 15 '18 at 23:00









            Laurent MazuelLaurent Mazuel

            2,039818




            2,039818












            • Thanks Laurent, That what I was looking for a python question how I would retrieve the value, adding the id did it

              – Samr
              Nov 16 '18 at 18:57

















            • Thanks Laurent, That what I was looking for a python question how I would retrieve the value, adding the id did it

              – Samr
              Nov 16 '18 at 18:57
















            Thanks Laurent, That what I was looking for a python question how I would retrieve the value, adding the id did it

            – Samr
            Nov 16 '18 at 18:57





            Thanks Laurent, That what I was looking for a python question how I would retrieve the value, adding the id did it

            – Samr
            Nov 16 '18 at 18:57













            0














            'remote_virtual_network': ,
            'remote_address_space':



            I will try this out and get back:



            This command is analogous to "get-azurermvirtualnetworkpeering -ResourceGroupName -VirtualNetworkName -Name" on Azure PowerShell.



            remote_virtual_network you don't have one. You will only get this if you have Remote Gateway enabled and the Peer will learn the IP address of the Remote (On-premise site) that you are trying to connect.



            To get this value, deploy a gateway in the Vnet and connect it to Say "Vnet-S2S-test" with a gateway deployed there as well.



            Once, the Site-to-site between the Vnets are up. You can execute the command and you should see those fields populated with the local network gateway details.






            share|improve this answer



























              0














              'remote_virtual_network': ,
              'remote_address_space':



              I will try this out and get back:



              This command is analogous to "get-azurermvirtualnetworkpeering -ResourceGroupName -VirtualNetworkName -Name" on Azure PowerShell.



              remote_virtual_network you don't have one. You will only get this if you have Remote Gateway enabled and the Peer will learn the IP address of the Remote (On-premise site) that you are trying to connect.



              To get this value, deploy a gateway in the Vnet and connect it to Say "Vnet-S2S-test" with a gateway deployed there as well.



              Once, the Site-to-site between the Vnets are up. You can execute the command and you should see those fields populated with the local network gateway details.






              share|improve this answer

























                0












                0








                0







                'remote_virtual_network': ,
                'remote_address_space':



                I will try this out and get back:



                This command is analogous to "get-azurermvirtualnetworkpeering -ResourceGroupName -VirtualNetworkName -Name" on Azure PowerShell.



                remote_virtual_network you don't have one. You will only get this if you have Remote Gateway enabled and the Peer will learn the IP address of the Remote (On-premise site) that you are trying to connect.



                To get this value, deploy a gateway in the Vnet and connect it to Say "Vnet-S2S-test" with a gateway deployed there as well.



                Once, the Site-to-site between the Vnets are up. You can execute the command and you should see those fields populated with the local network gateway details.






                share|improve this answer













                'remote_virtual_network': ,
                'remote_address_space':



                I will try this out and get back:



                This command is analogous to "get-azurermvirtualnetworkpeering -ResourceGroupName -VirtualNetworkName -Name" on Azure PowerShell.



                remote_virtual_network you don't have one. You will only get this if you have Remote Gateway enabled and the Peer will learn the IP address of the Remote (On-premise site) that you are trying to connect.



                To get this value, deploy a gateway in the Vnet and connect it to Say "Vnet-S2S-test" with a gateway deployed there as well.



                Once, the Site-to-site between the Vnets are up. You can execute the command and you should see those fields populated with the local network gateway details.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 15 '18 at 18:13









                Capt. Cherry ex- MSFTCapt. Cherry ex- MSFT

                311




                311



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53311687%2fextract-returned-values-from-virtualnetworkpeering-object%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Use pre created SQLite database for Android project in kotlin

                    Darth Vader #20

                    Ondo