From 3cd68cc351138bfdac99ab00ce96bea7b58fe2e3 Mon Sep 17 00:00:00 2001 From: Sisira Panchagnula Date: Tue, 6 Feb 2018 15:23:38 -0800 Subject: [PATCH] Adding a call to scm to warm up kudu for zipdeploy updating index.json --- src/index.json | 8 ++++---- src/webapp/azext_webapp/create_util.py | 8 ++++++++ src/webapp/azext_webapp/custom.py | 24 ++++++++++++++++++++---- src/webapp/setup.py | 2 +- 4 files changed, 33 insertions(+), 9 deletions(-) diff --git a/src/index.json b/src/index.json index 9796a381ace..3077eaa8792 100644 --- a/src/index.json +++ b/src/index.json @@ -370,9 +370,9 @@ ], "webapp": [ { - "filename": "webapp-0.0.6-py2.py3-none-any.whl", - "sha256Digest": "65ffc1f0c34bb4b7b3fa0e3d3b3c49b745d8b46d04c2653ae0e0a22d01329669", - "downloadUrl": "https://github.com/panchagnula/azure-cli-extensions/raw/sisirap-extensions-whl/dist/webapp-0.0.6-py2.py3-none-any.whl", + "filename": "webapp-0.0.7-py2.py3-none-any.whl", + "sha256Digest": "a80346e84390a17dde170efa7ad09934b0c3079ba377aa16e68f74423b24592b", + "downloadUrl": "https://github.com/panchagnula/azure-cli-extensions/raw/sisirap-extensions-whl/dist/webapp-0.0.7-py2.py3-none-any.whl", "metadata": { "classifiers": [ "Development Status :: 4 - Beta", @@ -409,7 +409,7 @@ "metadata_version": "2.0", "name": "webapp", "summary": "An Azure CLI Extension to manage appservice resources", - "version": "0.0.6" + "version": "0.0.7" } } ] diff --git a/src/webapp/azext_webapp/create_util.py b/src/webapp/azext_webapp/create_util.py index fdb85a4af39..df5ed2b89c9 100644 --- a/src/webapp/azext_webapp/create_util.py +++ b/src/webapp/azext_webapp/create_util.py @@ -83,3 +83,11 @@ def check_if_asp_exists(cmd, rg_name, asp_name): if item.name == asp_name: return True return False + + +def check_app_exists(cmd, rg_name, app_name): + client = web_client_factory(cmd.cli_ctx) + for item in list(client.web_apps.list_by_resource_group(rg_name)): + if item.name == app_name: + return True + return False diff --git a/src/webapp/azext_webapp/custom.py b/src/webapp/azext_webapp/custom.py index 1665994e07b..93c07cbefaa 100644 --- a/src/webapp/azext_webapp/custom.py +++ b/src/webapp/azext_webapp/custom.py @@ -12,6 +12,8 @@ enable_zip_deploy, create_webapp, update_app_settings, + _get_site_credential, + _get_scm_url, _get_sku_name) from .create_util import ( @@ -22,6 +24,7 @@ check_resource_group_exists, check_resource_group_supports_linux, check_if_asp_exists, + check_app_exists, web_client_factory ) @@ -126,16 +129,29 @@ def create_deploy_webapp(cmd, name, location=None, dryrun=False): logger.warning("App service plan '%s' already exists.", asp) # create the Linux app - logger.warning("Creating app '%s' ....", name) - create_webapp(cmd, rg_name, name, asp, runtime_version) - logger.warning("Webapp creation complete") + if not check_app_exists(cmd, rg_name, name): + logger.warning("Creating app '%s' ....", name) + create_webapp(cmd, rg_name, name, asp, runtime_version) + logger.warning("Webapp creation complete") + else: + logger.warning("App '%s' already exists", name) # setting to build after deployment logger.warning("Updating app settings to enable build after deployment") update_app_settings(cmd, rg_name, name, ["SCM_DO_BUILD_DURING_DEPLOYMENT=true"]) + # work around until the timeout limits issue for linux is investigated & fixed + # wakeup kudu, by making an SCM call + + import requests + # work around until the timeout limits issue for linux is investigated & fixed + user_name, password = _get_site_credential(cmd.cli_ctx, rg_name, name) + scm_url = _get_scm_url(cmd, rg_name, name) + import urllib3 + authorization = urllib3.util.make_headers(basic_auth='{0}:{1}'.format(user_name, password)) + requests.get(scm_url + '/api/settings', headers=authorization) - # zip contents & deploy logger.warning("Creating zip with contents of dir %s ...", src_dir) + # zip contents & deploy zip_file_path = zip_contents_from_dir(src_dir) logger.warning("Deploying and building contents to app." diff --git a/src/webapp/setup.py b/src/webapp/setup.py index c2cdff2b61c..bedccd9e4da 100644 --- a/src/webapp/setup.py +++ b/src/webapp/setup.py @@ -8,7 +8,7 @@ from codecs import open from setuptools import setup, find_packages -VERSION = "0.0.6" +VERSION = "0.0.7" CLASSIFIERS = [ 'Development Status :: 4 - Beta',