Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List VNET through python returns null #24130

Closed
3 tasks
satya5186 opened this issue Apr 21, 2022 · 5 comments
Closed
3 tasks

List VNET through python returns null #24130

satya5186 opened this issue Apr 21, 2022 · 5 comments
Assignees
Labels
customer-reported Issues that are reported by GitHub users external to the Azure organization. Mgmt This issue is related to a management-plane library. needs-author-feedback Workflow: More information is needed from author to address the issue. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team no-recent-activity There has been no recent activity on this issue. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Resources

Comments

@satya5186
Copy link

Describe the bug
List VNET through python returns null

Exception or Stack Trace
No stack trace but value returns NULL

To Reproduce
Steps to reproduce the behavior:

  1. Just create a VNET
  2. execute this simple block of code

Code Snippet
Add the code snippet that causes the issue.

from azure.identity import AzureCliCredential
from azure.mgmt.resource import ResourceManagementClient

create env variables for below:

export AZURE_CLIENT_ID="" / thi is name in the sp

export AZURE_CLIENT_SECRET="" / thi is password in the sp

export AZURE_TENANT_ID="" / thi is the tenant in the sp

credential = AzureCliCredential()
subscription = "91b48fa1-bfc1-481a-b30e-c063117e7e79"

def azure_vnet_list():
for resource_list in ResourceManagementClient(credential, subscription).resources.list():
if resource_list.type == "Microsoft.Compute/virtualMachines":
print(resource_list.name)

def main():
azure_vnet_list()

if name == "main":
main()

Expected behavior
A clear and concise description of what you expected to happen.

It should list the newly created VNET

Screenshots
If applicable, add screenshots to help explain your problem.

Setup (please complete the following information):

  • Python Version: [e.g. Python 3.8]
  • SDK Version: [e.g. azure-mgmt-resource-15.0.0b1]

Additional context
Add any other context about the problem here.

Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

  • Bug Description Added
  • Repro Steps Added
  • Setup information Added
@satya5186 satya5186 added the Mgmt This issue is related to a management-plane library. label Apr 21, 2022
@ghost ghost added customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Apr 21, 2022
@ghost ghost added the needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team label May 20, 2022
@BigCat20196
Copy link
Contributor

Hi @satya5186, thanks for your feedback! After investigation, if you want to list Vnet, you should use Microsoft.Network/virtualNetworks type instead of Microsoft.Compute/virtualMachines.

We prefer to use a dedicated SDK to manage resources, such as azure-mgmt-network and azure-mgmt-compute. You could easily install them by pip.
fyr: https://github.com/Azure-Samples/azure-samples-python-management/blob/main/samples/compute/manage_virtual_machine.py

https://github.com/Azure-Samples/azure-samples-python-management/blob/main/samples/network/virtual_network/manage_virtual_network.py

@satya5186
Copy link
Author

satya5186 commented May 23, 2022 via email

@BigCat20196
Copy link
Contributor

Hi @satya5186, could you please use followed code to try?

from azure.identity import DefaultAzureCredential
from azure.mgmt.resource import ResourceManagementClient

credential = AzureCliCredential()
subscription = "91b48fa1-bfc1-481a-b30e-c063117e7e79"

def azure_vnet_list():
    for resource_list in ResourceManagementClient(credential, subscription).resources.list():
        if resource_list.type == "Microsoft.Network/virtualNetworks":
            print(f"{resource_list.name}")

def main():
    azure_vnet_list()

if __name__ == '__main__':
    main()

In addition, which version of azure-mgmt-resource do you use?

@satya5186
Copy link
Author

satya5186 commented May 24, 2022 via email

@xiangyan99 xiangyan99 added the needs-author-feedback Workflow: More information is needed from author to address the issue. label Jun 17, 2022
@ghost ghost added the no-recent-activity There has been no recent activity on this issue. label Jun 24, 2022
@ghost
Copy link

ghost commented Jun 24, 2022

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 ghost closed this as completed Jul 9, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Apr 11, 2023
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
customer-reported Issues that are reported by GitHub users external to the Azure organization. Mgmt This issue is related to a management-plane library. needs-author-feedback Workflow: More information is needed from author to address the issue. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team no-recent-activity There has been no recent activity on this issue. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Resources
Projects
None yet
Development

No branches or pull requests

4 participants