@@ -7425,6 +7425,25 @@ def _build_onedeploy_arm_url(params):
74257425 return params .cmd .cli_ctx .cloud .endpoints .resource_manager + base_url
74267426
74277427
7428+ def _build_onedeploy_arm_url_with_instance (params , instance_id ):
7429+ from azure .cli .core .commands .client_factory import get_subscription_id
7430+ client = web_client_factory (params .cmd .cli_ctx )
7431+ sub_id = get_subscription_id (params .cmd .cli_ctx )
7432+ if not params .slot :
7433+ base_url = (
7434+ f"subscriptions/{ sub_id } /resourceGroups/{ params .resource_group_name } /providers/Microsoft.Web/sites/"
7435+ f"{ params .webapp_name } /instances/{ instance_id } /extensions/"
7436+ f"onedeploy?api-version={ client .DEFAULT_API_VERSION } "
7437+ )
7438+ else :
7439+ base_url = (
7440+ f"subscriptions/{ sub_id } /resourceGroups/{ params .resource_group_name } /providers/Microsoft.Web/sites/"
7441+ f"{ params .webapp_name } /slots/{ params .slot } /instances/{ instance_id } /extensions/onedeploy"
7442+ f"?api-version={ client .DEFAULT_API_VERSION } "
7443+ )
7444+ return params .cmd .cli_ctx .cloud .endpoints .resource_manager + base_url
7445+
7446+
74287447def _build_deploymentstatus_url (cmd , resource_group_name , webapp_name , slot , deployment_id ):
74297448 from azure .cli .core .commands .client_factory import get_subscription_id
74307449 client = web_client_factory (cmd .cli_ctx )
@@ -7593,16 +7612,19 @@ def _make_onedeploy_request(params):
75937612 # For debugging purposes only, you can change the async deployment into a sync deployment by polling the API status
75947613 # For that, set poll_async_deployment_for_debugging=True
75957614 logger .info ("Deployment API: %s" , deploy_url )
7615+ logger .warning ("Warming up Kudu before deployment." )
7616+ cookies = _warmup_kudu_and_get_cookie_internal (params .cmd , params .resource_group_name ,
7617+ params .webapp_name , params .slot )
7618+ cookies_present = True
7619+ if cookies is None :
7620+ cookies_present = False
7621+ logger .info ("Failed to fetch affinity cookie for Kudu. "
7622+ "Deployment will proceed without pre-warming a Kudu instance." )
75967623 if not params .src_url : # use SCM endpoint
75977624 # if linux webapp and not function app, then warmup kudu and use warmed up kudu for deployment
75987625 if params .is_linux_webapp and not params .is_functionapp and params .enable_kudu_warmup :
75997626 try :
7600- logger .warning ("Warming up Kudu before deployment." )
7601- cookies = _warmup_kudu_and_get_cookie_internal (params .cmd , params .resource_group_name ,
7602- params .webapp_name , params .slot )
7603- if cookies is None :
7604- logger .info ("Failed to fetch affinity cookie for Kudu. "
7605- "Deployment will proceed without pre-warming a Kudu instance." )
7627+ if not cookies_present :
76067628 response = requests .post (deploy_url , data = body , headers = headers ,
76077629 verify = not should_disable_connection_verify ())
76087630 else :
@@ -7618,7 +7640,19 @@ def _make_onedeploy_request(params):
76187640 verify = not should_disable_connection_verify ())
76197641 poll_async_deployment_for_debugging = True
76207642 else :
7621- response = send_raw_request (params .cmd .cli_ctx , "PUT" , deploy_url , body = body )
7643+ if params .is_linux_webapp and not params .is_functionapp and params .enable_kudu_warmup :
7644+ try :
7645+ if not cookies_present :
7646+ response = send_raw_request (params .cmd .cli_ctx , "PUT" , deploy_url , body = body )
7647+ else :
7648+ deploy_arm_url = _build_onedeploy_arm_url_with_instance (params , cookies .get ("ARRAffinity" ))
7649+ response = send_raw_request (params .cmd .cli_ctx , "PUT" , deploy_arm_url , body = body )
7650+ except Exception as ex : # pylint: disable=broad-except
7651+ logger .info ("Failed to deploy using instances endpoint. "
7652+ "Deployment will proceed without pre-warming a Kudu instance. Ex: %s" , ex )
7653+ response = send_raw_request (params .cmd .cli_ctx , "PUT" , deploy_url , body = body )
7654+ else :
7655+ send_raw_request (params .cmd .cli_ctx , "PUT" , deploy_url , body = body )
76227656 poll_async_deployment_for_debugging = False
76237657
76247658 # check the status of deployment
0 commit comments