@@ -76,18 +76,22 @@ def select_latest_verified_vm_image_with_node_agent_sku(
7676 :return: (node agent sku id to use, vm image ref to use)
7777 """
7878 # get verified vm image list and node agent sku ids from service
79- node_agent_skus = batch_client .account .list_node_agent_skus ()
79+ options = batchmodels .AccountListSupportedImagesOptions (
80+ filter = "verificationType eq 'verified'" )
81+ images = batch_client .account .list_supported_images (
82+ account_list_supported_images_options = options )
83+
8084 # pick the latest supported sku
8185 skus_to_use = [
82- (sku , image_ref ) for sku in node_agent_skus for image_ref in sorted (
83- sku .verified_image_references , key = lambda item : item .sku )
84- if image_ref .publisher .lower () == publisher .lower () and
85- image_ref .offer .lower () == offer .lower () and
86- image_ref .sku .startswith (sku_starts_with )
86+ (image .node_agent_sku_id , image .image_reference ) for image in images
87+ if image .image_reference .publisher .lower () == publisher .lower () and
88+ image .image_reference .offer .lower () == offer .lower () and
89+ image .image_reference .sku .startswith (sku_starts_with )
8790 ]
88- # skus are listed in reverse order, pick first for latest
89- sku_to_use , image_ref_to_use = skus_to_use [0 ]
90- return (sku_to_use .id , image_ref_to_use )
91+
92+ # pick first
93+ agent_sku_id , image_ref_to_use = skus_to_use [0 ]
94+ return (agent_sku_id , image_ref_to_use )
9195
9296
9397def wait_for_tasks_to_complete (batch_client , job_id , timeout ):
@@ -527,14 +531,15 @@ def wait_for_job_under_job_schedule(batch_client, job_schedule_id, timeout):
527531 :param timeout: The maximum amount of time to wait.
528532 :type timeout: `datetime.timedelta`
529533 """
530- cloud_job_schedule = batch_client .job_schedule .get (
531- job_schedule_id = job_schedule_id )
532-
533534 time_to_timeout_at = datetime .datetime .now () + timeout
534535
535536 while datetime .datetime .now () < time_to_timeout_at :
537+ cloud_job_schedule = batch_client .job_schedule .get (
538+ job_schedule_id = job_schedule_id )
539+
536540 print ("Checking if job exists..." )
537- if cloud_job_schedule .execution_info .recent_job .id is not None :
541+ if (cloud_job_schedule .execution_info .recent_job ) and (
542+ cloud_job_schedule .execution_info .recent_job .id is not None ):
538543 return cloud_job_schedule .execution_info .recent_job .id
539544 time .sleep (1 )
540545
@@ -550,11 +555,10 @@ def wait_for_job_schedule_to_complete(batch_client, job_schedule_id, timeout):
550555 :param timeout: The maximum amount of time to wait.
551556 :type timeout: `datetime.datetime`
552557 """
553-
554- cloud_job_schedule = batch_client .job_schedule .get (
555- job_schedule_id = job_schedule_id )
556-
557558 while datetime .datetime .now () < timeout :
559+ cloud_job_schedule = batch_client .job_schedule .get (
560+ job_schedule_id = job_schedule_id )
561+
558562 print ("Checking if job schedule is complete..." )
559563 state = cloud_job_schedule .state
560564 if state == batchmodels .JobScheduleState .completed :
0 commit comments