Skip to content

Commit

Permalink
[webapp] Adding a work around for calling kudu to warm up (#48)
Browse files Browse the repository at this point in the history
* Adding a call to scm to warm up kudu for zipdeploy

updating index.json

* Adding a fix to skip zip & deploy if we detect the contents are not node
app

* index.json update

* style fixes plus index update

* bug fix
  • Loading branch information
panchagnula authored and derekbekoe committed Feb 7, 2018
1 parent 132c063 commit 3bb73ab
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 15 deletions.
8 changes: 4 additions & 4 deletions src/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "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": [
"Development Status :: 4 - Beta",
Expand Down Expand Up @@ -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"
}
}
]
Expand Down
8 changes: 8 additions & 0 deletions src/webapp/azext_webapp/create_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
40 changes: 30 additions & 10 deletions src/webapp/azext_webapp/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -22,6 +24,7 @@
check_resource_group_exists,
check_resource_group_supports_linux,
check_if_asp_exists,
check_app_exists,
web_client_factory
)

Expand Down Expand Up @@ -126,20 +129,37 @@ 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)

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")

# zip contents & deploy
logger.warning("Creating zip with contents of dir %s ...", src_dir)
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)
logger.warning("All done. %s", create_json)
return None
2 changes: 1 addition & 1 deletion src/webapp/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 3bb73ab

Please sign in to comment.