Azure-sdk-for-python: Using AzureOperationPoller to poll for status

Created on 2 Dec 2016  路  7Comments  路  Source: Azure/azure-sdk-for-python

I am working on the code to create Virtual Machine Scale sets by the following method:
_result = compute_client.virtual_machine_scale_sets.create_or_update(resource_group, scale_set_name, vm_scale_set)_

Now the result of that is an AzureOperationPoller instance, I was initially using the 'done' method to sleep until the creation of the scale sets but somehow it does not work well for me now, because it considers the operation as done but the resource creation has not been completed yet.

To use the __poll(self, update_cmd_) method, I need to pass the update_cmd, which I am not sure how to get hold of. Would there be something I would be getting as a part of the AzureOperationPoller response that I could use to check for the update_cmd or the status?

ARM Service Attention question

Most helpful comment

@tmarballi @lmazuel you could create a an inbound NAT pool which maps a range of incoming ports on the load balancer to a destination port on the scale set VMs. If you only wanted a subset of VMs to be reachable you could define a limited range or use a network security group to limit incoming ports (there may be other ways to limit it but these are the first that come to mind).

All 7 comments

Using the 2.0.0rc6 SDK version

Hi @tmarballi

On an AzureOperationPoller, the only two operations you want to call are wait or result.

  • wait : poll until the async operation is finished and return None (usually for async DELETE)
  • result : poll until the async operation is finished and return the object (usually PUT/PATCH)

If you are in a situation where one of these methods return, but the operation is actually not done, this can be a bug in the poller or a RestAPI issue on the status.

Could you confirm you still have the bad behavior using these two methods before I try to dig deeper?

Thank you,

FYI @annatisch

@lmazuel : Thanks for your response, I was able to use wait and result the way you mentioned. I did not have any trouble with the operation not being completed as I had faced with the 'done' method.

Another question I had @lmazuel and I hope you don't mind me asking within this same ticket.

With scalesets, how can I associate atleast one VM with a public IP, because for my purposes I need one of the VMs to be the entry point and after that rest can talk amongst themselves using private IP.

@tmarballi I'm not a VMSS expert, but this might help you:
https://docs.microsoft.com/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-overview#vm-scale-set-scenarios

@gbowerman do you know the response to this question? Thanks :)

@tmarballi @lmazuel you could create a an inbound NAT pool which maps a range of incoming ports on the load balancer to a destination port on the scale set VMs. If you only wanted a subset of VMs to be reachable you could define a limited range or use a network security group to limit incoming ports (there may be other ways to limit it but these are the first that come to mind).

Thanks @gbowerman @lmazuel ... I was able to follow your instructions and create the load balancer. So closing this issue! Thanks for your help!

Was this page helpful?
0 / 5 - 0 ratings