[App Service] Add deployment guidance, warnings, and container image fix for Linux web apps#33088
[App Service] Add deployment guidance, warnings, and container image fix for Linux web apps#33088vageorge00 wants to merge 5 commits intoAzure:devfrom
Conversation
…Linux Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Validation for Azure CLI Full Test Starting...
Thanks for your contribution! |
|
Hi @vageorge00, |
|
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>
|
| type: command | ||
| short-summary: Get a URL for a git repository endpoint to clone and push to for web app deployment. | ||
| long-summary: | | ||
| Note: The default deployment branch is 'master'. If your local branch is 'main', |
There was a problem hiding this comment.
| site_config = get_site_configs(cmd, resource_group_name, name, slot) | ||
| site_config.scm_type = 'LocalGit' | ||
| _generic_site_operation(cmd.cli_ctx, resource_group_name, name, 'create_or_update_configuration', slot, site_config) | ||
| logger.warning("Note: The default deployment branch is 'master'. If your local branch is 'main', " |
| linux_fx = getattr(site_config, 'linux_fx_version', '') or '' | ||
| stack_prefix = linux_fx.split('|')[0].upper() if '|' in linux_fx else '' | ||
| if stack_prefix in ('PYTHON', 'NODE', 'PHP'): | ||
| logger.warning( |
There was a problem hiding this comment.
If we add this warning log:
Pros:
Helps with deployment confusion when --help is not read
Cons:
- Logs even if SCM_DO_BUILD_DURING_DEPLOYMENT is already set. Could check app settings (extra API call) to suppress, but could add some latency.
- If WEBSITE_RUN_FROM_PACKAGE=1 is also set, it overrides SCM_DO_BUILD_DURING_DEPLOYMENT and Oryx won't run. The warning's guidance would be misleading in that case.
- Also logs when --type is not specified (artifact_type=None), which could include non-zip deploys. The stack check (PYTHON/NODE/PHP) mitigates most false positives since Java/.NET stacks won't match.
Open to removing the runtime warning and keeping only the help text guidance if the noise is a concern.
| Suggested next steps after creation: | ||
| - Deploy your code: | ||
| az webapp deploy -g MyResourceGroup -n MyAppName --src-path app.zip --type zip | ||
| - For apps loading large models or dependencies at startup, increase the container |
There was a problem hiding this comment.
This is only relevant to linux apps, we should specify that here
| az webapp create -g MyResourceGroup -p MyPlan -n MyUniqueAppName --end-to-end-encryption-enabled true --min-tls-version 1.2 | ||
| - name: Create a Linux Python web app with a custom startup command. | ||
| text: > | ||
| az webapp create -g MyResourceGroup -p MyLinuxPlan -n MyUniqueAppName --runtime "PYTHON:3.12" --startup-file "gunicorn --bind=0.0.0.0 app:app" |
There was a problem hiding this comment.
Does this may sense to include in a create command when there is no code deployed?
| az webapp up -n MyApp --runtime "PYTHON:3.12" --plan MyPlan --sku P1v3 | ||
| - name: Deploy a .NET app to Linux (must specify --os-type linux). | ||
| text: > | ||
| az webapp up -n MyDotnetApp --runtime "DOTNETCORE:8.0" --os-type linux --plan MyPlan |
There was a problem hiding this comment.
Can we pick the latest LTS runtime versions for each of these?
There was a problem hiding this comment.
Pull request overview
Improves the Azure CLI App Service module UX for Linux web app deployments by adding contextual help/warnings and fixing a container image normalization bug that could generate invalid image paths.
Changes:
- Fixes container image name “registry host doubling” when
--container-image-namealready includes the registry host (webapp + slot creation). - Adds new warning messages in key flows (
webapp create,webapp delete,webapp up,webapp deploy,config-local-git, plan create) to guide next steps and clarify defaults/limitations. - Expands command help text for
az webapp create,az webapp deploy,az webapp up, and related commands with deployment guidance and conventions.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
src/azure-cli/azure/cli/command_modules/appservice/custom.py |
Container image normalization fix + multiple new runtime/defaulting/deployment guidance warnings. |
src/azure-cli/azure/cli/command_modules/appservice/_params.py |
Refines parameter help text for plan scaling, startup command guidance, and webapp up defaults. |
src/azure-cli/azure/cli/command_modules/appservice/_help.py |
Adds/extends long summaries and examples to clarify deployment flows and conventions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if language: | ||
| if not version_used_create or version_used_create == '-': | ||
| logger.warning("No --runtime specified. Could not auto-detect a valid %s version. " | ||
| "Please specify --runtime explicitly. " | ||
| "Use 'az webapp list-runtimes' for available options.", language.upper()) | ||
| else: | ||
| logger.warning("No --runtime specified. Using %s version: %s.", language, version_used_create) |
There was a problem hiding this comment.
For static site detection (language == "static"), get_runtime_version_details returns "-" and this new warning will incorrectly tell users to specify --runtime. Consider excluding STATIC_RUNTIME_NAME from this warning (and possibly skipping the message whenever version_used_create == "-") to avoid misleading guidance for --html/static deployments.
| # Warn interpreted-language Linux apps that zip deploy won't auto-build | ||
| if params.is_linux_webapp and artifact_type in (None, 'zip'): | ||
| try: | ||
| site_config = get_site_configs(cmd, resource_group_name, name, slot) | ||
| linux_fx = getattr(site_config, 'linux_fx_version', '') or '' | ||
| stack_prefix = linux_fx.split('|')[0].upper() if '|' in linux_fx else '' | ||
| if stack_prefix in ('PYTHON', 'NODE', 'PHP'): |
There was a problem hiding this comment.
This warning condition treats artifact_type=None as equivalent to zip, but artifact_type is inferred later from src_path (_update_artifact_type). As a result, deploying a non-zip artifact without --type (e.g., a static file) can still trigger the "zip deploy won't auto-build" warning. Consider determining the effective artifact type first (call the inference helper earlier or check src_path extension) and only warn when the final type is zip.
|
|
||
| _enable_basic_auth(cmd, name, None, resource_group_name, basic_auth.lower()) | ||
| if not using_webapp_up: | ||
| logger.warning("Webapp '%s' created. Deploy your code with: az webapp deploy or az webapp up", name) |
There was a problem hiding this comment.
The post-create message always says the webapp was "created", but this function also runs when the app name already exists (it logs that earlier and then does a create_or_update). This is misleading for update scenarios; consider conditioning the message on name_validation.name_available or changing it to "created or updated".
| logger.warning("Webapp '%s' created. Deploy your code with: az webapp deploy or az webapp up", name) | |
| logger.warning("Webapp '%s' created or updated. Deploy your code with: az webapp deploy or az webapp up", name) |
There was a problem hiding this comment.
It's run from az webapp create. Keep wording.
| os_type = 'Linux' if is_linux else 'Windows' | ||
| logger.warning("App Service Plan '%s' created (%s).", name, os_type) | ||
|
|
There was a problem hiding this comment.
This log is emitted immediately after the create/update request is started, before poller.result() completes, and it always says "created" even when the plan already exists (create-or-update semantics) or when the LRO later fails. Consider moving this message after a successful result and wording it as "created or updated" (and/or including the resulting provisioning state).
| local_context_attribute=LocalContextAttribute(name='web_name', actions=[LocalContextAction.SET], | ||
| scopes=['webapp', 'cupertino'])) | ||
| c.argument('startup_file', help="Linux only. The web's startup file") | ||
| c.argument('startup_file', help="Linux only. The web's startup file. " |
There was a problem hiding this comment.
This is really the startup command, not really a file, maybe slightly to reflect that
| short-summary: Allows management operations for webjobs on a web app. | ||
| long-summary: | | ||
| To create WebJobs, use the Azure portal. For more information and other options, | ||
| see: https://learn.microsoft.com/azure/app-service/webjobs-create |
There was a problem hiding this comment.
This might be linux specific guidance, I assume windows would work if the command exists. If webjob management via CLI is not supported for linux then we may want to take action to not allow it at all.
| urlparse(container_registry_url).hostname, | ||
| container_image_name[1:] if container_image_name.startswith('/') else container_image_name) | ||
| if container_registry_url: | ||
| registry_host = urlparse(container_registry_url).hostname |
There was a problem hiding this comment.
There is a bunch of legacy stuff with old app settings. Which problem are we trying to solve here? I don't want to mistakenly break something, and maybe we can push people in a better direction?
| "storage_mounts": storage_mounts, | ||
| }) | ||
|
|
||
| os_type = 'Linux' if is_linux else 'Windows' |
There was a problem hiding this comment.
just making sure, are we possibly missing xenon? I have no idea how that shows up. It may also be "windows"
| stack_prefix = linux_fx.split('|')[0].upper() if '|' in linux_fx else '' | ||
| if stack_prefix in ('PYTHON', 'NODE', 'PHP'): | ||
| logger.warning( | ||
| "Note: 'az webapp deploy' does not install dependencies (pip install, npm install, " |
There was a problem hiding this comment.
Nit: this sentence az webapp deploy' does not install dependencies (pip install, npm install, etc.) for Linux web apps. is not exactly correct. We don't unless the app setting is set.
I guess maybe just rephrase slightly to make it very clear
Good point - no ruby Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@vageorge00 please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
… static site fix, container warning, startup command clarification Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Related command
az webapp create,az webapp deploy,az webapp up,az webapp delete,az webapp deployment source config-local-git,az appservice plan updateDescription
Fixes https://github.com/serverless-paas-balam/tuxedo/issues/119
Improves the Azure CLI experience for deploying Linux web apps by adding help text, runtime warnings, and a container image bug fix.
Help text: Added deployment guidance to
az webapp create, SCM_DO_BUILD_DURING_DEPLOYMENT guidance toaz webapp deploy, OS/runtime/plan defaults toaz webapp up, branch convention toconfig-local-git, and scale up vs scale out toaz appservice plan update.Code: Fixed container image path doubling in
create_webapp/create_webapp_slotwhen--container-image-nameincludes the registry host. Added runtime warnings for zip deploy on Python/Node/PHP, OS type defaulting, runtime auto-detection, plan auto-generation, delete plan warning, and local-git branch convention.Testing Guide
End-to-end agent tests across Python, .NET, Java, and containers confirmed all warnings fire correctly.
Manual end-end tests:
Testing container image bug fix


Normal case:
Image name is just nginx:latest (no registry host). CLI prepends the host: index.docker.io/nginx:latest.
Test case (bug fix):


Image name already includes the registry host (docker.io/). Before fix, CLI would prepend it again:
docker.io/docker.io/nginx:latest (broken).
After our fix, CLI strips the duplicate: docker.io/nginx:latest (correct).
Testing some logging changes

az webapp deployment source config-local-git -g test-container-rg -n test-container-app2
We get log about branch info
az webapp delete -g test-container-rg -n test-container-app3

We get warning about plan being deleted
We get added help info:

az webapp deploy --help
az webapp create --help

param check:

History Notes
[App Service]
az webapp create: Add post-creation deployment guidance and startup command examples[App Service]
az webapp deploy: Add dependency installation guidance for Linux zip deployments[App Service]
az webapp up: Add logging for OS type, runtime auto-detection, and plan auto-generation[App Service] Fix container image path doubling when
--container-image-nameincludes registry host[App Service]
az webapp delete: Add warning about App Service Plan deletionThe PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.
I adhere to the Error Handling Guidelines.
@microsoft-github-policy-service agree company="Microsoft"