Skip to content

Commit 0300fad

Browse files
vageorge00Copilot
andcommitted
Save in-progress exec-execute changes
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 8a7c84d commit 0300fad

14 files changed

Lines changed: 238 additions & 12 deletions

File tree

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,4 @@
6767
/src/azure-cli/azure/cli/command_modules/util/ @jiasli @zhoxing-ms @evelyn-ys
6868
/src/azure-cli/azure/cli/command_modules/vm/ @zhoxing-ms @jsntcy @wangzelin007 @yanzhudd @Drewm3 @TravisCragg-MSFT @nikhilpatel909 @sandeepraichura @hilaryw29 @GabstaMSFT @ramankumarlive @ushnaarshadkhan
6969
/src/azure-cli/azure/cli/command_modules/containerapp/ @zhoxing-ms @yanzhudd @ruslany @sanchitmehta @ebencarek @JennyLawrance @howang-ms @vinisoto @chinadragon0515 @vturecek @torosent @pagariyaalok @Juliehzl @jijohn14 @Greedygre @ShichaoQiu
70+
/src/azure-cli/azure/cli/command_modules/webapp/ @vageorge00

doc/sphinx/azhelpgen/doc_source_map.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,6 @@
7777
"term": "src/azure-cli/azure/cli/command_modules/marketplaceordering/_help.py",
7878
"util": "src/azure-cli/azure/cli/command_modules/util/_help.py",
7979
"vm": "src/azure-cli/azure/cli/command_modules/vm/_help.py",
80-
"vmss": "src/azure-cli/azure/cli/command_modules/vm/_help.py"
80+
"vmss": "src/azure-cli/azure/cli/command_modules/vm/_help.py",
81+
"webapp": "src/azure-cli/azure/cli/command_modules/webapp/_help.py"
8182
}

src/azure-cli/azure/cli/command_modules/appservice/_help.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1919,24 +1919,24 @@
19191919

19201920
helps['webapp exec'] = """
19211921
type: command
1922-
short-summary: Execute a command in a web app container.
1922+
short-summary: Execute a shell command in a web app container.
19231923
long-summary: >
1924-
Execute commands remotely in your web app container. The command runs asynchronously
1925-
and returns immediately without command output. Requires SCM Basic Auth Publishing
1926-
Credentials to be enabled.
1924+
Execute shell commands remotely in your web app container. The command returns immediately
1925+
after being accepted, without waiting for completion or output. Redirect to a file to capture results (see examples).
1926+
Requires SCM Basic Auth Publishing Credentials to be enabled.
19271927
examples:
1928-
- name: Execute a simple command on a web app
1928+
- name: Execute a simple command on a web app and redirect output to a log file
19291929
text: >
1930-
az webapp exec -g MyResourceGroup -n MyWebapp --cmd "ls -la /home"
1930+
az webapp exec -g MyResourceGroup -n MyWebapp --command "(ls -l) > output.log 2>&1"
19311931
- name: Execute a command in a specific working directory on a specific instance
19321932
text: >
1933-
az webapp exec -g MyResourceGroup -n MyWebapp --cmd "npm install" --cwd /home/site/wwwroot --instance MyInstanceId
1933+
az webapp exec -g MyResourceGroup --name MyWebapp --command "npm install" --cwd /home/site/wwwroot --instance MyInstanceId
19341934
- name: Execute a command on all instances
19351935
text: >
1936-
az webapp exec -g MyResourceGroup -n MyWebapp --cmd "systemctl restart nginx" --instance all
1936+
az webapp exec -g MyResourceGroup -n MyWebapp --command "systemctl restart nginx" --instance all
19371937
- name: Execute a command on a deployment slot
19381938
text: >
1939-
az webapp exec -g MyResourceGroup -n MyWebapp -s staging --cmd "python manage.py migrate"
1939+
az webapp exec -g MyResourceGroup -n MyWebapp -s staging --command "python manage.py migrate"
19401940
"""
19411941

19421942
helps['webapp delete'] = """

src/azure-cli/azure/cli/command_modules/appservice/_params.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,12 +1504,12 @@ def load_arguments(self, _):
15041504
c.argument("no_register", help="Don't try to register the Microsoft.CDN provider. Registration can be done manually with: az provider register --wait --namespace Microsoft.CDN. For more details, please review the documentation available at https://go.microsoft.com/fwlink/?linkid=2184995 .", default=False)
15051505
with self.argument_context('webapp exec') as c:
15061506
c.argument('name', arg_type=webapp_name_arg_type, id_part=None)
1507-
c.argument('command', options_list=['--command', '--cmd'], help='The command to execute in the container.')
1507+
c.argument('command', options_list=['--command'], help='The command to execute in the container.')
15081508
c.argument('mode',
15091509
help='Execution mode. \'execute\': Starts command execution and returns immediately without returning command output.',
15101510
arg_type=get_enum_type(['execute']), default='execute')
15111511
c.argument('working_directory', options_list=['--working-directory', '--cwd'],
1512-
help='Working directory for command execution')
1512+
help='Working directory for command execution. Defaults to the container\'s working directory (typically /home/site/wwwroot for App Service images).'')
15131513
c.argument('instance', options_list=['--instance', '-i'],
15141514
help='Webapp instance(s) to target. Specify a comma-separated list of instance IDs (use "az webapp list-instances" to get IDs) or "all" for all instances. Defaults to a random instance.')
15151515
c.argument('slot', options_list=['--slot', '-s'],
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
# --------------------------------------------------------------------------------------------
5+
6+
from azure.cli.core import AzCommandsLoader
7+
8+
from azure.cli.command_modules.webapp._help import helps # pylint: disable=unused-import
9+
10+
11+
class WebappCommandsLoader(AzCommandsLoader):
12+
13+
def __init__(self, cli_ctx=None):
14+
from azure.cli.core.commands import CliCommandType
15+
from azure.cli.command_modules.webapp._client_factory import cf_webapp
16+
webapp_custom = CliCommandType(
17+
operations_tmpl='azure.cli.command_modules.webapp.custom#{}',
18+
client_factory=cf_webapp)
19+
super(WebappCommandsLoader, self).__init__(cli_ctx=cli_ctx,
20+
custom_command_type=webapp_custom)
21+
22+
def load_command_table(self, args):
23+
from azure.cli.command_modules.webapp.commands import load_command_table
24+
load_command_table(self, args)
25+
return self.command_table
26+
27+
def load_arguments(self, command):
28+
from azure.cli.command_modules.webapp._params import load_arguments
29+
load_arguments(self, command)
30+
31+
32+
COMMAND_LOADER_CLS = WebappCommandsLoader
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
# --------------------------------------------------------------------------------------------
5+
6+
def cf_webapp(cli_ctx, *_):
7+
8+
from azure.cli.core.commands.client_factory import get_mgmt_service_client
9+
# TODO: Replace CONTOSO with the appropriate label and uncomment
10+
# from azure.mgmt.CONTOSO import CONTOSOManagementClient
11+
# return get_mgmt_service_client(cli_ctx, CONTOSOManagementClient)
12+
return None
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
5+
# --------------------------------------------------------------------------------------------
6+
7+
from knack.help_files import helps # pylint: disable=unused-import
8+
9+
10+
helps['webapp'] = """
11+
type: group
12+
short-summary: Commands to manage Webapps.
13+
"""
14+
15+
helps['webapp create'] = """
16+
type: command
17+
short-summary: Create a Webapp.
18+
"""
19+
20+
helps['webapp list'] = """
21+
type: command
22+
short-summary: List Webapps.
23+
"""
24+
25+
# helps['webapp delete'] = """
26+
# type: command
27+
# short-summary: Delete a Webapp.
28+
# """
29+
30+
# helps['webapp show'] = """
31+
# type: command
32+
# short-summary: Show details of a Webapp.
33+
# """
34+
35+
# helps['webapp update'] = """
36+
# type: command
37+
# short-summary: Update a Webapp.
38+
# """
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
# --------------------------------------------------------------------------------------------
5+
# pylint: disable=line-too-long
6+
7+
from knack.arguments import CLIArgumentType
8+
9+
10+
def load_arguments(self, _):
11+
12+
from azure.cli.core.commands.parameters import tags_type
13+
from azure.cli.core.commands.validators import get_default_location_from_resource_group
14+
15+
webapp_name_type = CLIArgumentType(options_list='--webapp-name-name', help='Name of the Webapp.', id_part='name')
16+
17+
with self.argument_context('webapp') as c:
18+
c.argument('tags', tags_type)
19+
c.argument('location', validator=get_default_location_from_resource_group)
20+
c.argument('webapp_name', webapp_name_type, options_list=['--name', '-n'])
21+
22+
with self.argument_context('webapp list') as c:
23+
c.argument('webapp_name', webapp_name_type, id_part=None)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
# --------------------------------------------------------------------------------------------
5+
6+
7+
def example_name_or_id_validator(cmd, namespace):
8+
# Example of a storage account name or ID validator.
9+
# See: https://github.com/Azure/azure-cli/blob/dev/doc/authoring_command_modules/authoring_commands.md#supporting-name-or-id-parameters
10+
from azure.cli.core.commands.client_factory import get_subscription_id
11+
from msrestazure.tools import is_valid_resource_id, resource_id
12+
if namespace.storage_account:
13+
if not is_valid_resource_id(namespace.RESOURCE):
14+
namespace.storage_account = resource_id(
15+
subscription=get_subscription_id(cmd.cli_ctx),
16+
resource_group=namespace.resource_group_name,
17+
namespace='Microsoft.Storage',
18+
type='storageAccounts',
19+
name=namespace.storage_account
20+
)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
# --------------------------------------------------------------------------------------------
5+
6+
# pylint: disable=line-too-long
7+
from azure.cli.core.commands import CliCommandType
8+
from azure.cli.command_modules.webapp._client_factory import cf_webapp
9+
10+
11+
def load_command_table(self, _):
12+
13+
# TODO: Add command type here
14+
# webapp_sdk = CliCommandType(
15+
# operations_tmpl='<PATH>.operations#.{}',
16+
# client_factory=cf_webapp)
17+
18+
19+
with self.command_group('webapp') as g:
20+
g.custom_command('create', 'create_webapp')
21+
# g.command('delete', 'delete')
22+
g.custom_command('list', 'list_webapp')
23+
# g.show_command('show', 'get')
24+
# g.generic_update_command('update', setter_name='update', custom_func_name='update_webapp')
25+
26+
27+
with self.command_group('webapp', is_preview=True):
28+
pass
29+

0 commit comments

Comments
 (0)