[AppService] az webapp log startup: Add commands to list and view Linux container startup logs#33256
[AppService] az webapp log startup: Add commands to list and view Linux container startup logs#33256faditawfik21 wants to merge 2 commits intoAzure:devfrom
az webapp log startup: Add commands to list and view Linux container startup logs#33256Conversation
|
Validation for Azure CLI Full Test Starting...
Thanks for your contribution! |
|
Hi @faditawfik21, |
|
Validation for Breaking Change Starting...
Thanks for your contribution! |
|
Thank you for your contribution! We will review the pull request and get back to you soon. |
|
The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR. Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions). pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>
|
63bc370 to
f797f87
Compare
There was a problem hiding this comment.
Pull request overview
Adds new preview commands under az webapp log startup to retrieve Linux container startup logs from the KuduLite /api/startuplogs endpoint, and surfaces a troubleshooting hint when deployments fail to start.
Changes:
- Added
az webapp log startup listandaz webapp log startup show(preview) command registrations + args/help. - Implemented
list_startup_logsandshow_startup_loginappservice/custom.pywith graceful 404 handling. - Appended a “TIP” hint to deployment runtime failure/timeout errors pointing users to
az webapp log startup show.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/azure-cli/azure/cli/command_modules/appservice/custom.py |
Implements startup log retrieval and adds deployment error hints. |
src/azure-cli/azure/cli/command_modules/appservice/commands.py |
Registers the new webapp log startup preview command group and commands. |
src/azure-cli/azure/cli/command_modules/appservice/_params.py |
Adds parameters for startup list/show (slot/outcome/instance/filename). |
src/azure-cli/azure/cli/command_modules/appservice/_help.py |
Adds help entries and examples for the new commands. |
src/azure-cli/azure/cli/command_modules/appservice/tests/latest/test_webapp_commands_thru_mock.py |
Adds mocked unit tests for list/show behavior and the new error hint text. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
f797f87 to
71645db
Compare
71645db to
32e8341
Compare
|
I think one thing which is very important here is discoverability, for both humans and agents. Here are some ideas from copilot to think about here. One idea would be to create a failing test site and see how you/your agent does at finding the logs without any prompting. You would ideally want to configure your test site to not enable container logs to the filesystem so that without accessing startup logs, they would be blind. For humans:
For AI agents: 4. Richer --help long-summary — agents discover commands via az webapp log startup --help. The current Concrete suggestion for this PR The cheapest high-value addition would be enriching the help text for agent discoverability: helps['webapp log startup'] = """ The extra symptom keywords (fails to start, crashes, times out, 502/503) make it much more likely an agent will find this |
|
Another copilot-assisted comment/something to look into: |
It seems like the |
…inux container startup logs
32e8341 to
ad4e6d0
Compare
| deployment_properties.get('numberOfInstancesInProgress'), | ||
| deployment_properties.get('numberOfInstancesSuccessful'), | ||
| deployment_properties.get('numberOfInstancesFailed')) | ||
| tip_cmd = "az webapp log startup show -n {} -g {}".format(webapp_name, resource_group_name) |
There was a problem hiding this comment.
Is this being recommended for all app types? This is currently only available for Linux so want to make sure it's not also being presented for Windows
There was a problem hiding this comment.
Good question. This is already scoped to Linux only. The _poll_deployment_runtime_status function is only reachable from the Linux code path. The caller gates on is_linux_webapp(app) at line ~8510, so Windows apps and slot deployments go through _check_zip_deployment_status instead, which doesn't include the hint.
| c.argument('resource_group', arg_type=resource_group_name_type) | ||
| c.argument('slot', options_list=['--slot', '-s'], help="the name of the slot. Default to the productions slot if not specified") | ||
|
|
||
| with self.argument_context('webapp log startup list') as c: |
There was a problem hiding this comment.
Is there any way to reduce the duplication here. IE the prefix of the commands webapp log startup have name, resource, and slot in common. This is a nit so if there is not a clean way to do this, that's ok
There was a problem hiding this comment.
Good call. Refactored to define name, resource_group, slot, and instance once under a parent argument_context('webapp log startup') block. The child contexts now only define their unique params (outcome for list, filename for show).
| arg_type=get_enum_type(['success', 'failure'])) | ||
| c.argument('instance', options_list=['--instance'], help='Filter by worker instance name.') | ||
|
|
||
| with self.argument_context('webapp log startup show') as c: |
There was a problem hiding this comment.
Should the show also have an instance param? Currently, if a customer is running on 3+ worker, what is considered the "lastest log"? Sometimes the application fails on one specific worker, so if I were a customer I would want to see the latest on the failing worker v. the successful worker for comparison
There was a problem hiding this comment.
Great suggestion. Added --instance to the show command. The KuduLite StartupLogsController already supports ?latest=true&instance=X (the instance param is accepted independently alongside latest), so /api/startuplogs?latest=true&instance=lw0sdlwk000002 returns the most recent log for that specific worker. Also added a unit test and a help example for it.
Description
Adds new
az webapp log startup listandaz webapp log startup showcommands (preview) that retrieve container startup logs from the KuduLite/api/startuplogsendpoint for Linux web apps.Commands
az webapp log startup list— List startup log files with metadata (date, instance, outcome, size)az webapp log startup show— Show the latest/most relevant startup log (prefers failures)az webapp log startup show --filename <f>— Show a specific log file by nameFeatures
is_preview=Trueduring server-side rolloutaz webapp up/az webapp deployon RuntimeFailed or timeoutTesting
azdev test appservice --no-exitfirst)azdev style appservicecleanFixes AB#37627870