Skip to content

Commit

Permalink
webapp: fix broken 'log' and 'zip deployment' commands (Azure#5335)
Browse files Browse the repository at this point in the history
  • Loading branch information
yugangw-msft authored Jan 18, 2018
1 parent 0820976 commit 4a46eab
Show file tree
Hide file tree
Showing 7 changed files with 153 additions and 136 deletions.
4 changes: 4 additions & 0 deletions src/command_modules/azure-cli-appservice/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
Release History
===============
0.1.25
++++++
* fix broken webapp log tail/download
* relieve the 'kind' check on webapp/functionapp

0.1.24
++++++
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from azure.cli.core.util import empty_on_404

from ._client_factory import cf_web_client, cf_plans, cf_webapps
from ._validators import validate_existing_function_app, validate_existing_web_app


def output_slots_in_table(slots):
Expand Down Expand Up @@ -70,8 +69,7 @@ def load_command_table(self, _):
with self.command_group('webapp', webapp_sdk) as g:
g.custom_command('create', 'create_webapp', exception_handler=ex_handler_factory())
g.custom_command('list', 'list_webapp', table_transformer=transform_web_list_output)
g.custom_command('show', 'show_webapp', validator=validate_existing_web_app,
exception_handler=empty_on_404, table_transformer=transform_web_output)
g.custom_command('show', 'show_webapp', exception_handler=empty_on_404, table_transformer=transform_web_output)
g.custom_command('delete', 'delete_webapp')
g.custom_command('stop', 'stop_webapp')
g.custom_command('start', 'start_webapp')
Expand Down Expand Up @@ -174,8 +172,7 @@ def load_command_table(self, _):
with self.command_group('functionapp') as g:
g.custom_command('create', 'create_function')
g.custom_command('list', 'list_function_app', table_transformer=transform_web_list_output)
g.custom_command('show', 'show_webapp', validator=validate_existing_function_app,
exception_handler=empty_on_404, table_transformer=transform_web_output)
g.custom_command('show', 'show_webapp', exception_handler=empty_on_404, table_transformer=transform_web_output)
g.custom_command('delete', 'delete_function_app')
g.custom_command('stop', 'stop_webapp')
g.custom_command('start', 'start_webapp')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,22 +132,21 @@ def update_webapp(instance, client_affinity_enabled=None):


def list_webapp(cmd, resource_group_name=None):
from ._validators import WEB_APP_TYPES
return _list_app(cmd.cli_ctx, WEB_APP_TYPES, resource_group_name)
result = _list_app(cmd.cli_ctx, resource_group_name)
return [r for r in result if 'function' not in r.kind]


def list_function_app(cmd, resource_group_name=None):
from ._validators import FUNCTION_APP_TYPES
return _list_app(cmd.cli_ctx, FUNCTION_APP_TYPES, resource_group_name)
result = _list_app(cmd.cli_ctx, resource_group_name)
return [r for r in result if 'function' in r.kind]


def _list_app(cli_ctx, app_types, resource_group_name=None):
def _list_app(cli_ctx, resource_group_name=None):
client = web_client_factory(cli_ctx)
if resource_group_name:
result = list(client.web_apps.list_by_resource_group(resource_group_name))
else:
result = list(client.web_apps.list())
result = [x for x in result if x.kind in app_types]
for webapp in result:
_rename_server_farm_props(webapp)
return result
Expand Down Expand Up @@ -1219,7 +1218,7 @@ def get_streaming_log(cmd, resource_group_name, name, provider=None, slot=None):
if provider:
streaming_url += ('/' + provider.lstrip('/'))

user, password = _get_site_credential(resource_group_name, name, slot)
user, password = _get_site_credential(cmd.cli_ctx, resource_group_name, name, slot)
t = threading.Thread(target=_get_log, args=(streaming_url, user, password))
t.daemon = True
t.start()
Expand All @@ -1231,13 +1230,13 @@ def get_streaming_log(cmd, resource_group_name, name, provider=None, slot=None):
def download_historical_logs(cmd, resource_group_name, name, log_file=None, slot=None):
scm_url = _get_scm_url(cmd, resource_group_name, name, slot)
url = scm_url.rstrip('/') + '/dump'
user_name, password = _get_site_credential(resource_group_name, name, slot)
user_name, password = _get_site_credential(cmd.cli_ctx, resource_group_name, name, slot)
_get_log(url, user_name, password, log_file)
logger.warning('Downloaded logs to %s', log_file)


def _get_site_credential(resource_group_name, name, slot=None):
creds = _generic_site_operation(resource_group_name, name, 'list_publishing_credentials', slot)
def _get_site_credential(cli_ctx, resource_group_name, name, slot=None):
creds = _generic_site_operation(cli_ctx, resource_group_name, name, 'list_publishing_credentials', slot)
creds = creds.result()
return (creds.publishing_user_name, creds.publishing_password)

Expand Down Expand Up @@ -1527,7 +1526,7 @@ def create_function(cmd, resource_group_name, name, storage_account, plan=None,
poller = client.web_apps.create_or_update(resource_group_name, name, functionapp_def)
functionapp = LongRunningOperation(cmd.cli_ctx)(poller)

_set_remote_or_local_git(functionapp, resource_group_name, name, deployment_source_url,
_set_remote_or_local_git(cmd, functionapp, resource_group_name, name, deployment_source_url,
deployment_source_branch, deployment_local_git)

return functionapp
Expand Down Expand Up @@ -1601,9 +1600,9 @@ def list_locations(cmd, sku, linux_workers_enabled=None):
return client.list_geo_regions(full_sku, linux_workers_enabled)


def enable_zip_deploy(resource_group_name, name, src, slot=None):
user_name, password = _get_site_credential(resource_group_name, name, slot)
scm_url = _get_scm_url(resource_group_name, name, slot)
def enable_zip_deploy(cmd, resource_group_name, name, src, slot=None):
user_name, password = _get_site_credential(cmd.cli_ctx, resource_group_name, name, slot)
scm_url = _get_scm_url(cmd, resource_group_name, name, slot)
zip_url = scm_url + '/api/zipdeploy'

import urllib3
Expand Down
Loading

0 comments on commit 4a46eab

Please sign in to comment.