How to check resource creation success in Azure Python SDK
I'm creating several resources in Azure using python SDK but i'm confused how to check whether the resource is successfully created or not ?
Documentation says the poller has multiple methods - done(), wait(), result() etc to check status of the resource but what is the safe way to check status on creation of a resource ?
I have checked samples from here but they only have wait() and do not check on the status
ex:
try:
resource = client.virual_machines.begin_create_or_update(...)# option 1
count = 1
while not resource.done(): #done() returns true or false
time.sleep(timeout)
if count > 10:
raise
count += 1# option 2
response = resource.result() # result() returns the object of the corresponding resource
if not isinstance(response, VirtualMachine):
raise# option 3
resource.wait(timeout)
# check the status() function and based on the status of
# ('inprogress', 'done', 'provisioning', 'succedded')
# add a manual check and raise exceptionexcept Exception as e:
what is the best option/way to handle/check resource creation ?
or is there any way to handle it properly ?
Thanks in advance !