Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@

/src/eventhubs/ @v-ajnava

/src/webapps/ @panchagnula
/src/webapp/ @panchagnula

/src/aem/ @yugangw-msft
/src/aem/ @yugangw-msft
45 changes: 45 additions & 0 deletions src/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,51 @@
"version": "0.0.1"
}
}
],
"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",
"metadata": {
"classifiers": [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Intended Audience :: System Administrators",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"License :: OSI Approved :: MIT License"
],
"extensions": {
"python.details": {
"contacts": [
{
"email": "[email protected]",
"name": "Sisira Panchagnula",
"role": "author"
}
],
"document_names": {
"description": "DESCRIPTION.rst"
},
"project_urls": {
"Home": "https://github.com/Azure/azure-cli-extensions"
}
}
},
"generator": "bdist_wheel (0.29.0)",
"license": "MIT",
"metadata_version": "2.0",
"name": "webapp",
"summary": "An Azure CLI Extension to manage appservice resources",
"version": "0.0.6"
}
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,30 @@

# pylint: disable=unused-import

import azext_webapps._help
import azext_webapp._help


class WebappsExtCommandLoader(AzCommandsLoader):
class WebappExtCommandLoader(AzCommandsLoader):

def __init__(self, cli_ctx=None):
from azure.cli.core.commands import CliCommandType
webapps_custom = CliCommandType(
operations_tmpl='azext_webapps.custom#{}')
super(WebappsExtCommandLoader, self).__init__(cli_ctx=cli_ctx,
custom_command_type=webapps_custom,
min_profile="2017-03-10-profile")
webapp_custom = CliCommandType(
operations_tmpl='azext_webapp.custom#{}')
super(WebappExtCommandLoader, self).__init__(cli_ctx=cli_ctx,
custom_command_type=webapp_custom,
min_profile="2017-03-10-profile")

def load_command_table(self, _):
with self.command_group('webapp') as g:
g.custom_command('quickstart', 'create_deploy_webapp')
g.custom_command('new', 'create_deploy_webapp')
return self.command_table

def load_arguments(self, _):
with self.argument_context('webapp quickstart') as c:
with self.argument_context('webapp new') as c:
c.argument('name', options_list=['--name', '-n'], help='name of the new webapp')
c.argument('dryrun',
help="shows summary of the create and deploy operation instead of executing it",
default=False, action='store_true')


COMMAND_LOADER_CLS = WebappsExtCommandLoader
COMMAND_LOADER_CLS = WebappExtCommandLoader
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
from knack.help_files import helps


helps['webapp quickstart'] = """
helps['webapp new'] = """
type: command
short-summary: Create and deploy a node web app
examples:
- name: Create a web app with the default configuration.
text: >
az webapp quickstart -n MyUniqueAppName
az webapp new -n MyUniqueAppName --dryrun \n
az webapp new -n MyUniqueAppName -l locationName
"""
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def create_deploy_webapp(cmd, name, location=None, dryrun=False):
loc_name = location.replace(" ", "")

asp = "appsvc_asp_{}_{}".format(os_val, loc_name)
rg = "appsvc_rg_{}_{}".format(os_val, loc_name)
rg_name = "appsvc_rg_{}_{}".format(os_val, loc_name)

# the code to deploy is expected to be the current directory the command is running from
src_dir = os.getcwd()
Expand All @@ -75,15 +75,15 @@ def create_deploy_webapp(cmd, name, location=None, dryrun=False):

# Resource group: check if default RG is set
default_rg = cmd.cli_ctx.config.get('defaults', 'group', fallback=None)
if (default_rg and check_resource_group_supports_linux(cmd, default_rg, location)):
rg = default_rg
if default_rg and check_resource_group_supports_linux(cmd, default_rg, location):
rg_name = default_rg
rg_mssg = "[Using default Resource group]"
else:
rg_mssg = ""

runtime_version = "{}|{}".format(language, version_used_create)
src_path = "{} {}".format(src_dir.replace("\\", "\\\\"), str_no_contents_warn)
rg_str = "{} {}".format(rg, rg_mssg)
rg_str = "{} {}".format(rg_name, rg_mssg)

dry_run_str = r""" {
"name" : "%s",
Expand All @@ -101,46 +101,45 @@ def create_deploy_webapp(cmd, name, location=None, dryrun=False):

create_json = json.dumps(json.loads(dry_run_str), indent=4, sort_keys=True)
if dryrun:
logger.warning("""
Web app will be created with the below configuration,
re-run command without the --dryrun flag to create & deploy a new app
""")
logger.warning("Web app will be created with the below configuration,re-run command "
"without the --dryrun flag to create & deploy a new app")
logger.warning(create_json)
return None

# create RG if the RG doesn't already exist
if not check_resource_group_exists(cmd, rg):
logger.warning("Creating Resource group '%s' ...", rg)
create_resource_group(cmd, rg, location)
if not check_resource_group_exists(cmd, rg_name):
logger.warning("Creating Resource group '%s' ...", rg_name)
create_resource_group(cmd, rg_name, location)
logger.warning("Resource group creation complete")
else:
logger.warning("Resource group '%s' already exists.", rg)
logger.warning("Resource group '%s' already exists.", rg_name)

# create asp
if not check_if_asp_exists(cmd, rg, asp):
if not check_if_asp_exists(cmd, rg_name, asp):
logger.warning("Creating App service plan '%s' ...", asp)
sku_def = SkuDescription(tier=full_sku, name=sku, capacity=1)
plan_def = AppServicePlan(loc_name, app_service_plan_name=asp,
sku=sku_def, reserved=True)
client.app_service_plans.create_or_update(rg, asp, plan_def)
client.app_service_plans.create_or_update(rg_name, asp, plan_def)
logger.warning("App service plan creation complete")
else:
logger.warning("App service plan '%s' already exists.", asp)

# create the Linux app
logger.warning("Creating app '%s' ....", name)
create_webapp(cmd, rg, name, asp, runtime_version)
create_webapp(cmd, rg_name, name, asp, runtime_version)
logger.warning("Webapp creation complete")

# setting to build after deployment
logger.warning("Updating app settings to enable build after deployment")
update_app_settings(cmd, rg, name, ["SCM_DO_BUILD_DURING_DEPLOYMENT=true"])
update_app_settings(cmd, rg_name, name, ["SCM_DO_BUILD_DURING_DEPLOYMENT=true"])

# 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, zip_file_path)
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
File renamed without changes.
4 changes: 2 additions & 2 deletions src/webapps/setup.py → 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.4"
VERSION = "0.0.6"

CLASSIFIERS = [
'Development Status :: 4 - Beta',
Expand All @@ -27,7 +27,7 @@
DEPENDENCIES = []

setup(
name='webapps',
name='webapp',
version=VERSION,
description='An Azure CLI Extension to manage appservice resources',
long_description='An Azure CLI Extension to manage appservice resources',
Expand Down