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.52k stars 2.76k forks source link

Issue with Python SDK to create Azure VM #36490

Closed EmmaZhang0626 closed 3 weeks ago

EmmaZhang0626 commented 1 month ago

Describe the bug When using the Python SDK to create a VM from an image in the Azure compute gallery, there is no resource group check during the deployment process. This means that even if the wrong resource group name is provided (a random name that does not exist under the specified subscription), the VM can still be successfully created. This can lead to the VM being associated with an incorrect image reference.

To Reproduce Steps to reproduce the behavior: 1.Use the Python SDK to create a VM with an image from the Azure compute gallery. SIG.txt

2.Provide a random, non-existent resource group name in the image reference.

3.Deploy the VM. image image

Expected behavior We want to know if the resource group no check is by design. The deployment process should validate the resource group name and fail if the specified resource group does not exist or does not contain the desired image gallery. The VM should only be created if the correct resource group name is provided.

Additional context After the VM is created, we checked the JSON file of the new VM and found that the image reference is pointing to the wrong resource group. This issue can lead to inconsistencies and potential problems in managing VM resources.

github-actions[bot] commented 1 month ago

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

Drewm3 commented 1 month ago

For the group, I am working with Emma on this offline. I will update this issue once we have more details on the issue.

Drewm3 commented 1 month ago

@TravisCragg-MSFT, could you work with Emma to debug this issue. At first, I thought that maybe there were two images, one in the RG "repro" and one in the RG "abc-test" that maybe Emma just forgot about. But she confirmed that the RG abc-test does not exist. So that means that she is inputting a URI to an image that is completely bogus and CRP proceeds to create a VM using some other image, and then returns in the GET response for that new VM that the image URI is the completely non-existent image.

Furthermore, Emma shared that this only reproduces when using the Python SDK, and it will not repro with PowerShell, CLI or the portal. So, I think we need to debug this from the server side to see what payload CRP is actually getting in the repro scenario, and how it is actually creating a VM using an image that doesn't exist.... Something seems very odd here.

EmmaZhang0626 commented 1 month ago

Hi @Travis @.***>,

Greetings of the day and hope you are doing well.

Thank you very much for your help on the below issue: Issue with Python SDK to create Azure VM · Issue #36490 · Azure/azure-sdk-for-python (github.com)https://github.com/Azure/azure-sdk-for-python/issues/36490

Issue:

When using the Python SDK to create a VM from an image in the Azure compute gallery, we found that even if the wrong resource group name is provided (a random name that does not exist under the specified subscription, such as 'test-abc'), the VM vm-base-1 can still be successfully created. This can lead to the VM being associated with an incorrect image reference.

[cid:afa60a73-c33e-4840-9b9e-a54ff9ce9bb1]

[cid:c8f1e66d-50da-4d61-ab87-8fd1bb275cf6]

Looking forward to your reply!

Best regards,

Emma Zhang

Tech Support Eng SE | Azure Virtual Machine

+86 (21) 6188 9521 / @.**@.>

Working Hours: 7:00am - 4:00pm UTC+8, Mon – Fri

Manager: Steven Xiao / @.**@.>

Can’t reach me? Email – Azure Backup | @.**@.>

[cid:d24072d9-f59c-4e23-b5f5-3324e492ea06]


From: Drew McDaniel @.> Sent: Wednesday, July 17, 2024 2:26 PM To: Azure/azure-sdk-for-python @.> Cc: Emma Zhang @.>; Author @.> Subject: Re: [Azure/azure-sdk-for-python] Issue with Python SDK to create Azure VM (Issue #36490)

@TravisCragg-MSFThttps://github.com/TravisCragg-MSFT, could you work with Emma to debug this issue. At first, I thought that maybe there were two images, one in the RG "repro" and one in the RG "abc-test" that maybe Emma just forgot about. But she confirmed that the RG abc-test does not exist. So that means that she is inputting a URI to an image that is completely bogus and CRP proceeds to create a VM using some other image, and then returns in the GET response for that new VM that the image URI is the completely non-existent image.

Furthermore, Emma shared that this only reproduces when using the Python SDK, and it will not repro with PowerShell, CLI or the portal. So, I think we need to debug this from the server side to see what payload CRP is actually getting in the repro scenario, and how it is actually creating a VM using an image that doesn't exist.... Something seems very odd here.

— Reply to this email directly, view it on GitHubhttps://github.com/Azure/azure-sdk-for-python/issues/36490#issuecomment-2232524728, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BJ3WB2KHV5A26YJS5LIV6E3ZMYFCFAVCNFSM6AAAAABK5VQ4QGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMZSGUZDINZSHA. You are receiving this because you authored the thread.

TravisCragg-MSFT commented 3 weeks ago

@EmmaZhang0626 Thank you for informing us, we will be adding this validation ASAP, and further tracking will be done internally.