Skip to content

Commit

Permalink
Updating Linux, Node app default SKU & using the core zip deploy
Browse files Browse the repository at this point in the history
	modified:   index.json
	modified:   webapp/azext_webapp/create_util.py
	modified:   webapp/azext_webapp/custom.py
	modified:   webapp/setup.py
  • Loading branch information
panchagnula committed Aug 7, 2018
1 parent 13af4a7 commit 897aefd
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 56 deletions.
2 changes: 1 addition & 1 deletion src/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@
"metadata_version": "2.0",
"name": "webapp",
"summary": "An Azure CLI Extension to manage appservice resources",
"version": "0.2.6"
"version": "0.2.7"
}
}
],
Expand Down
2 changes: 1 addition & 1 deletion src/webapp/azext_webapp/create_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def get_lang_from_content(src_path):
if os.path.isfile(package_json_file):
runtime_details_dict['language'] = NODE_RUNTIME_NAME
runtime_details_dict['file_loc'] = package_json_file
runtime_details_dict['default_sku'] = 'S1'
runtime_details_dict['default_sku'] = 'B1'
elif package_netlang_glob:
package_netcore_file = os.path.join(src_path, package_netlang_glob[0])
runtime_lang = detect_dotnet_lang(package_netcore_file)
Expand Down
61 changes: 8 additions & 53 deletions src/webapp/azext_webapp/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from azure.mgmt.web.models import (AppServicePlan, SkuDescription, SnapshotRecoveryRequest, SnapshotRecoveryTarget)
from azure.cli.core.commands.client_factory import get_subscription_id
from azure.cli.command_modules.appservice.custom import (
enable_zip_deploy,
create_webapp,
update_app_settings,
_get_site_credential,
Expand Down Expand Up @@ -166,13 +167,13 @@ def create_deploy_webapp(cmd, name, location=None, dryrun=False):

logger.warning("Preparing to deploy %s contents to app.",
'' if is_skip_build else 'and build')
_zip_deploy(cmd, rg_name, name, zip_file_path)
if not is_java:
# Remove the file afer deployment, handling exception if user removed the file manually
try:
os.remove(zip_file_path)
except OSError:
pass
enable_zip_deploy(cmd, rg_name, name, zip_file_path)
# if not is_java:
# # Remove the file afer deployment, handling exception if user removed the file manually
# try:
# os.remove(zip_file_path)
# except OSError:
# pass
else:
logger.warning('No known package (Node, ASP.NET, .NETCORE, Java or Static Html) '
'found skipping zip and deploy process')
Expand Down Expand Up @@ -275,49 +276,3 @@ def _start_tunnel(tunnel_server, remote_debugging_enabled):
if remote_debugging_enabled is False:
logger.warning('SSH is available { username: root, password: Docker! }')
tunnel_server.start_server()


def _zip_deploy(cmd, rg_name, name, zip_path):
user_name, password = _get_site_credential(cmd.cli_ctx, rg_name, name)
scm_url = _get_scm_url(cmd, rg_name, name)
zip_url = scm_url + '/api/zipdeploy?isAsync=true'

import urllib3
authorization = urllib3.util.make_headers(basic_auth='{0}:{1}'.format(user_name, password))
headers = authorization
headers['content-type'] = 'application/octet-stream'

import requests
import os
# Read file content
with open(os.path.realpath(os.path.expanduser(zip_path)), 'rb') as fs:
zip_content = fs.read()
requests.post(zip_url, data=zip_content, headers=headers)
# keep checking for status of the deployment
deployment_url = scm_url + '/api/deployments/latest'
response = requests.get(deployment_url, headers=authorization)
if response.json()['status'] != 4:
logger.warning(response.json()['progress'])
_check_deployment_status(deployment_url, authorization)


def _check_deployment_status(deployment_url, authorization):
num_trials = 1
import requests
while num_trials < 200:
response = requests.get(deployment_url, headers=authorization)
res_dict = response.json()
num_trials = num_trials + 1
if res_dict['status'] == 5:
logger.warning("Zip deployment failed status {}".format(
res_dict['status_text']
))
break
elif res_dict['status'] == 4:
break
logger.warning(res_dict['progress'])
# if the deployment is taking longer than expected
r = requests.get(deployment_url, headers=authorization)
if r.json()['status'] != 4:
logger.warning("""Deployment is taking longer than expected. Please verify status at '{}'
beforing launching the app""".format(deployment_url))
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.2.6"
VERSION = "0.2.7"

CLASSIFIERS = [
'Development Status :: 4 - Beta',
Expand Down

0 comments on commit 897aefd

Please sign in to comment.