While using "begin_create_or_update" getting error related to location property
mehulrjangale opened this issue · 10 comments
Type of issue
Code doesn't work
Description
[Enter feedback here]
I'm using azure-mgmt-compute==30.4.0 and above version. I'm facing the following issue. I tried to add the location parameter manually, but that doesn't work either. The document doesn't call it out clearly.
_Failed
Traceback (most recent call last):
File "/usr/src/tmp/acbbf3f2-fbdc-4ecf-b209-00c26e01e385/runbooks/rotateVm.py", line 42, in
compute_client.virtual_machines.begin_create_or_update(resource_group_name, vm_name, update_vm)
File "C:\userenv\lib\site-packages\azure\core\tracing\decorator.py", line 78, in wrapper_use_tracer
return func(*args, **kwargs)
File "C:\userenv\lib\site-packages\azure\mgmt\compute\v2024_03_01\operations_operations.py", line 15291, in begin_create_or_update
raw_result = self._create_or_update_initial(
File "C:\userenv\lib\site-packages\azure\mgmt\compute\v2024_03_01\operations_operations.py", line 15158, in create_or_update_initial
raise HttpResponseError(response=response, error_format=ARMErrorFormat)
azure.core.exceptions.HttpResponseError: (LocationRequired) The location property is required for this definition.
Code: LocationRequired
Message: The location property is required for this definition.
Page URL
https://learn.microsoft.com/en-us/python/api/overview/azure/mgmt-compute-readme?view=azure-python
Content source URL
Document Version Independent Id
c377eb24-55a2-545b-6b53-ba4d375c4134
Article author
Metadata
- ID: c21ea709-4437-2046-f254-acaba8943cb4
- Service: compute
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @amjads1 @avirishuv @Drewm3 @Vaibhav-Agar.
Hi @mehulrjangale - It looks like the parameters
parameter of begin_create_or_update takes either an IO[bytes] or VirtualMachine.
VirtualMachine takes location as a required keyword argument.
The argument update_vm
passed in to parameters
should include location
. Example.
Thanks!
Hi @mehulrjangale. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue.
Hi @swathipil,
I've the following code:
vm.os_profile.admin_password = new_password
**update_vm** = **VirtualMachineUpdate**(os_profile=vm.os_profile)
compute_client.virtual_machines.begin_create_or_update(resource_group_name, vm_name, update_vm)
The problem is I think VirtualMachineUpdate does not have location parameter.
[https://learn.microsoft.com/en-us/python/api/azure-mgmt-compute/azure.mgmt.compute.v2024_03_01.models.virtualmachineupdate?view=azure-python]
Hi @swathipil,
I've the following code:
vm.os_profile.admin_password = new_password **update_vm** = **VirtualMachineUpdate**(os_profile=vm.os_profile) compute_client.virtual_machines.begin_create_or_update(resource_group_name, vm_name, update_vm)
The problem is I think VirtualMachineUpdate does not have location parameter. [https://learn.microsoft.com/en-us/python/api/azure-mgmt-compute/azure.mgmt.compute.v2024_03_01.models.virtualmachineupdate?view=azure-python]
Hi, please use the model VirtualMachine
instead of VirtualMachineUpdate
from azure.mgmt.compute.models import VirtualMachine
update_vm = VirtualMachine(location="eastus", tags={'1':'2'})
@ChenxiJiang333 @swathipil Will it work if I want to update the VM ?
@ChenxiJiang333 @swathipil Will it work if I want to update the VM ?
It works for both to create or update the VM.
It worked, thanks!
Hi @mehulrjangale. 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.