From 3cd68cc351138bfdac99ab00ce96bea7b58fe2e3 Mon Sep 17 00:00:00 2001 From: Sisira Panchagnula Date: Tue, 6 Feb 2018 15:23:38 -0800 Subject: [PATCH 1/5] 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', From 088df7088efd1c11a84dbce4374f03234cca78b2 Mon Sep 17 00:00:00 2001 From: Sisira Panchagnula Date: Tue, 6 Feb 2018 16:48:49 -0800 Subject: [PATCH 2/5] Adding a fix to skip zip & deploy if we detect the contents are not node app --- src/index.json | 2 +- src/webapp/azext_webapp/custom.py | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/index.json b/src/index.json index 3077eaa8792..27d20601566 100644 --- a/src/index.json +++ b/src/index.json @@ -371,7 +371,7 @@ "webapp": [ { "filename": "webapp-0.0.7-py2.py3-none-any.whl", - "sha256Digest": "a80346e84390a17dde170efa7ad09934b0c3079ba377aa16e68f74423b24592b", + "sha256Digest": "3c1d3c83111a1e68555877af8db0647afd52ff7096b15fa831d0799341977128", "downloadUrl": "https://github.com/panchagnula/azure-cli-extensions/raw/sisirap-extensions-whl/dist/webapp-0.0.7-py2.py3-none-any.whl", "metadata": { "classifiers": [ diff --git a/src/webapp/azext_webapp/custom.py b/src/webapp/azext_webapp/custom.py index 93c07cbefaa..c371f373e06 100644 --- a/src/webapp/azext_webapp/custom.py +++ b/src/webapp/azext_webapp/custom.py @@ -150,12 +150,16 @@ def create_deploy_webapp(cmd, name, location=None, dryrun=False): authorization = urllib3.util.make_headers(basic_auth='{0}:{1}'.format(user_name, password)) requests.get(scm_url + '/api/settings', headers=authorization) - logger.warning("Creating zip with contents of dir %s ...", src_dir) - # zip contents & deploy - zip_file_path = zip_contents_from_dir(src_dir) + if package_json_path == '': + 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." + "This operation can take some time to finish...") + enable_zip_deploy(cmd, rg_name, name, zip_file_path) + else: + logger.warning("No package.json found, skipping zip and deploy process") - logger.warning("Deploying and building contents to app." - "This operation can take some time to finish...") - enable_zip_deploy(cmd, rg_name, name, zip_file_path) logger.warning("All done. %s", create_json) return None From 6c0beb2d398777114fa1ec7c792bd5f9d032c9f9 Mon Sep 17 00:00:00 2001 From: Sisira Panchagnula Date: Tue, 6 Feb 2018 16:58:08 -0800 Subject: [PATCH 3/5] index.json update --- src/index.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.json b/src/index.json index 27d20601566..3ba736d3d5e 100644 --- a/src/index.json +++ b/src/index.json @@ -371,7 +371,7 @@ "webapp": [ { "filename": "webapp-0.0.7-py2.py3-none-any.whl", - "sha256Digest": "3c1d3c83111a1e68555877af8db0647afd52ff7096b15fa831d0799341977128", + "sha256Digest": "1a202a6b13b03b3982fb17e8272c55c52255f92efe5159834d3ea2a3a52f07d2", "downloadUrl": "https://github.com/panchagnula/azure-cli-extensions/raw/sisirap-extensions-whl/dist/webapp-0.0.7-py2.py3-none-any.whl", "metadata": { "classifiers": [ From 492c96940db2de8ca106b5987dc2473d3a97392c Mon Sep 17 00:00:00 2001 From: Sisira Panchagnula Date: Tue, 6 Feb 2018 17:08:13 -0800 Subject: [PATCH 4/5] style fixes plus index update --- src/index.json | 2 +- src/webapp/azext_webapp/custom.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.json b/src/index.json index 3ba736d3d5e..0b72b84c0ca 100644 --- a/src/index.json +++ b/src/index.json @@ -371,7 +371,7 @@ "webapp": [ { "filename": "webapp-0.0.7-py2.py3-none-any.whl", - "sha256Digest": "1a202a6b13b03b3982fb17e8272c55c52255f92efe5159834d3ea2a3a52f07d2", + "sha256Digest": "21cec56998325b4041c3127b28246def819c9d50dc6b8cd9df8e5c669c462ad8", "downloadUrl": "https://github.com/panchagnula/azure-cli-extensions/raw/sisirap-extensions-whl/dist/webapp-0.0.7-py2.py3-none-any.whl", "metadata": { "classifiers": [ diff --git a/src/webapp/azext_webapp/custom.py b/src/webapp/azext_webapp/custom.py index c371f373e06..0cbfd8156db 100644 --- a/src/webapp/azext_webapp/custom.py +++ b/src/webapp/azext_webapp/custom.py @@ -156,7 +156,7 @@ def create_deploy_webapp(cmd, name, location=None, dryrun=False): zip_file_path = zip_contents_from_dir(src_dir) logger.warning("Deploying and building contents to app." - "This operation can take some time to finish...") + "This operation can take some time to finish...") enable_zip_deploy(cmd, rg_name, name, zip_file_path) else: logger.warning("No package.json found, skipping zip and deploy process") From b445db142c6b0ee36c4c59a3495c358dd106186a Mon Sep 17 00:00:00 2001 From: Sisira Panchagnula Date: Tue, 6 Feb 2018 17:34:27 -0800 Subject: [PATCH 5/5] bug fix --- src/index.json | 2 +- src/webapp/azext_webapp/custom.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.json b/src/index.json index 0b72b84c0ca..2aaaea0c6e9 100644 --- a/src/index.json +++ b/src/index.json @@ -371,7 +371,7 @@ "webapp": [ { "filename": "webapp-0.0.7-py2.py3-none-any.whl", - "sha256Digest": "21cec56998325b4041c3127b28246def819c9d50dc6b8cd9df8e5c669c462ad8", + "sha256Digest": "11090b2d19d2082f86249bbf06566bd3924e4c976ac47c95e34ecd82541944c8", "downloadUrl": "https://github.com/panchagnula/azure-cli-extensions/raw/sisirap-extensions-whl/dist/webapp-0.0.7-py2.py3-none-any.whl", "metadata": { "classifiers": [ diff --git a/src/webapp/azext_webapp/custom.py b/src/webapp/azext_webapp/custom.py index 0cbfd8156db..08a2c74afb1 100644 --- a/src/webapp/azext_webapp/custom.py +++ b/src/webapp/azext_webapp/custom.py @@ -150,7 +150,7 @@ def create_deploy_webapp(cmd, name, location=None, dryrun=False): authorization = urllib3.util.make_headers(basic_auth='{0}:{1}'.format(user_name, password)) requests.get(scm_url + '/api/settings', headers=authorization) - if package_json_path == '': + if package_json_path != '': logger.warning("Creating zip with contents of dir %s ...", src_dir) # zip contents & deploy zip_file_path = zip_contents_from_dir(src_dir)