diff --git a/managed/devops/opscli/ybops/cloud/azure/utils.py b/managed/devops/opscli/ybops/cloud/azure/utils.py index f813784d5fcd..5c0a83033a35 100644 --- a/managed/devops/opscli/ybops/cloud/azure/utils.py +++ b/managed/devops/opscli/ybops/cloud/azure/utils.py @@ -890,9 +890,9 @@ def create_or_update_vm(self, vm_name, zone, num_vols, private_key_file, volume_ # Otherwise, we try to extract this info from the purchase plan # or identifier of the image definition. if (image_tags is not None - and image_tags['PlanPublisher'] is not None - and image_tags['PlanProduct'] is not None - and image_tags['PlanInfo'] is not None): + and image_tags.get('PlanPublisher', None) is not None + and image_tags.get('PlanProduct', None) is not None + and image_tags.get('PlanInfo', None) is not None): plan = { "publisher": image_tags['PlanPublisher'], "product": image_tags['PlanProduct'], @@ -916,9 +916,9 @@ def create_or_update_vm(self, vm_name, zone, num_vols, private_key_file, volume_ image_identifier = gallery_image.as_dict().get('identifier') logging.info("Gallery Image identifier = " + str(image_identifier)) if (image_identifier is not None - and image_identifier["publisher"] is not None - and image_identifier["offer"] is not None - and image_identifier["sku"] is not None): + and image_identifier.get("publisher", None) is not None + and image_identifier.get("offer", None) is not None + and image_identifier.get("sku", None) is not None): plan = { "publisher": image_identifier["publisher"], "product": image_identifier["offer"],