Introducing a new way to review your PRs.

Read the announcement

azure / azure-cli

Azure Command-Line Interface

View on GitHub

13 documents · Updated Nov 16, 2026

docs / app-hosting-container-commands

Application Hosting and Container Command Modules

Overview

This doc covers the Azure CLI command modules that expose application hosting, container, registry, service-linking, and bot commands:

  • src/azure-cli/azure/cli/command_modules/appservice/**
  • src/azure-cli/azure/cli/command_modules/containerapp/**
  • src/azure-cli/azure/cli/command_modules/container/**
  • src/azure-cli/azure/cli/command_modules/acs/**
  • src/azure-cli/azure/cli/command_modules/acr/**
  • src/azure-cli/azure/cli/command_modules/serviceconnector/**
  • src/azure-cli/azure/cli/command_modules/botservice/**

Routing starts in each module's commands.py, where load_command_table maps Azure CLI command groups to either SDK operation groups or module-level custom functions. Argument shape is mostly centralized in each module's _params.py, validation in _validators.py, clients in _client_factory.py or local REST client wrappers, and behavior in custom.py plus focused helper files. Help text is organized in _help.py files, and scenario/live tests are kept under each module's tests/ subtree (usually tests/latest/).

App Service, Functions, Logic Apps, and Static Web Apps

src/…/commands.py registers the largest surface: webapp, functionapp, logicapp, appservice plan, appservice ase, appservice domain, and staticwebapp. It mixes SDK operation templates for azure.mgmt.web (cf_web_client, cf_plans, cf_webapps from appservice/_client_factory.py) with custom command handlers in appservice/custom.py, appservice/static_sites.py, appservice/access_restrictions.py, appservice/appservice_environment.py, appservice/appservice_domains.py, appservice/…/custom.py, appservice/webapp_exec.py, and appservice/network_capture.py.

appservice/custom.py implements web and function app lifecycle behavior rather than just forwarding to SDK calls. For example, create_webapp resolves the App Service plan, validates Linux/runtime/container option combinations, creates or reuses site configuration, applies VNet integration, sets container image settings, enables deployment source control, applies identities, and emits troubleshooting hints. Deployment commands such as zip deploy and OneDeploy also live in this file and interact with Kudu/SCM endpoints. App settings, connection strings, SSL, custom domains, slots, hybrid connections, backup/snapshot, webjobs, function keys, flex-migration, and Function Flex Consumption config commands all route through the same custom module.

appservice/static_sites.py owns staticwebapp commands. It obtains the WebSiteManagementClient.static_sites operation group, resolves resource groups by listing static sites when needed, creates repository-linked static web apps using GitHub or Azure DevOps tokens, redacts app settings in outputs, manages hostnames/environments/users/secrets, links user-provided functions/backends, and toggles enterprise edge after registering Microsoft.CDN when requested. Static Web App commands are registered from appservice/commands.py under staticwebapp, not in a separate top-level command module.

appservice/_params.py contains much of the user-facing contract. It defines common app/plan/resource-group defaults, plan and managed-instance arguments, webapp creation runtime/container/sitecontainers flags, Function Flex migration/config flags, and loops over webapp, functionapp, and logicapp for shared deployment/appsetting/SSL arguments. Validators imported from appservice/_validators.py enforce plan creation, VNet integration, Static Web App SKU/function-linking, function-on-container-app restrictions, Flex-only settings, and deployment parameter combinations.

Azure Container Apps

src/…/commands.py registers containerapp, containerapp env, containerapp job, ingress, revision, registry, secret, Dapr, auth providers, SSL/hostname, compose, workload profile, HTTP route config, and premium ingress groups. Almost all commands target containerapp/custom.py; command output uses transformers from containerapp/_transformers.py, and errors are normalized by containerapp/_client_factory.py.

Container Apps does not rely only on generated SDK operation groups. containerapp/_clients.py defines REST wrappers such as ContainerAppClient and ManagedEnvironmentClient that build management URLs for Microsoft.App resources with CURRENT_API_VERSION = "2025-07-01", call send_raw_request, and manually poll azure-asyncoperation or location headers. This is the stateful transport layer for app/env/job/certificate/storage/revision operations.

containerapp/custom.py is the orchestration layer. It parses YAML, normalizes properties under properties, deserializes through local SDK model definitions, strips read-only/additional attributes, preserves secret values during updates, and builds patch payloads for container, scale, ingress, registry, identity, Dapr, auth, domain, logs, jobs, and environment operations. containerapp/containerapp_decorator.py, containerapp/containerapp_env_decorator.py, containerapp/containerapp_job_decorator.py, containerapp/containerapp_auth_decorator.py, and containerapp/containerapp_job_registry_decorator.py encapsulate create/update payload construction. containerapp/_params.py defines the command contract for YAML, ingress, registry identity, Dapr, secrets, env vars, workload profiles, jobs, auth providers, and compose imports.

Azure Container Instances

src/…/commands.py registers the compact container surface: list/create/show/delete/logs/exec/export/attach/start/stop/restart plus container container-group-profile and profile revisions. SDK clients come from container/_client_factory.py, which wraps ContainerInstanceManagementClient operation groups and related Log Analytics, Resource, and MSI clients.

container/custom.py constructs ContainerGroup and ContainerGroupProfile model objects directly. create_container supports image registry credentials or ACR identity, Azure File and secret volumes, Git repo volumes, Log Analytics diagnostics, system/user-assigned identity, VNet/subnet creation or delegation for Microsoft.ContainerInstance/containerGroups, standby pool/profile references, zones, Spot/Regular priority, confidential compute SKU, and security context. YAML input is handled by _create_update_from_file, which sends the loaded definition through ARM resources.begin_create_or_update instead of the typed container group client. Runtime operations stream logs, open websocket exec sessions with terminal handling, and export scrubbed YAML. container/_params.py mirrors these model-building choices with argument groups for network, image registry, volumes, managed identity, confidential container groups, Log Analytics, group profiles, and standby pools.

AKS / Container Service

src/…/commands.py registers the aks command surface. It uses CliCommandType wrappers over azure.mgmt.containerservice operation groups from acs/_client_factory.py: managed clusters, agent pools, machines, maintenance configurations, managed namespaces, snapshots, trusted access, identity bindings, and related resources. It also injects custom AAZ safeguards commands directly into self.command_table using classes in acs/custom.py.

acs/custom.py is the high-level orchestration layer for cluster creation/update, nodepool operations, credentials, browse/run-command flows, add-ons, maintenance configurations, managed namespaces, snapshots, trusted access, app routing, service mesh, Azure Monitor, and many feature toggles. aks_create and aks_update capture the raw parameter dictionary and delegate profile construction to decorators such as acs/managed_cluster_decorator.py; nodepool behavior follows the same pattern through acs/agentpool_decorator.py. Kubeconfig merging, kubectl invocation, and browser/proxy flows are implemented locally. acs/_params.py is the definitive command contract for the large AKS option matrix, including networking, identities, ACR attachment, add-ons, Azure Monitor, nodepool settings, storage, service mesh, app routing, gateway API, and node provisioning.

Azure Container Registry

src/…/commands.py registers registry management plus data-plane-ish and build surfaces: acr, acr credential, repository/manifest, cache and credential-set, webhook, replication, build/run/pack, task/taskrun, config policies, helm, network rules, health checks, scope-map/token, agentpool, private endpoint connections, identity/encryption, connected registry, and artifact streaming. Client factories in acr/_client_factory.py split between ResourceType.MGMT_CONTAINERREGISTRY and ResourceType.MGMT_CONTAINERREGISTRYTASKS.

acr/custom.py implements registry lifecycle and authentication behavior. acr_create validates SKU/network constraints, configures public network access, customer-managed keys, metadata search, domain-name label scope, ABAC/RBAC mode, regional endpoints, data endpoints, export policy, trusted services, and optional diagnostic settings. acr_login either returns an exposed refresh token or invokes Docker/Podman after validating that the executable did not resolve from the current working directory. Build, import, repository, manifest, task, run, policy, helm, cache, connected registry, token/scope map, and webhook behaviors are split across focused files such as acr/build.py, acr/run.py, acr/task.py, acr/repository.py, acr/manifest.py, acr/policy.py, acr/cache.py, acr/connected_registry.py, and acr/webhook.py. acr/_params.py wires the extensive argument surface, including secret build args, task identities/triggers, regional endpoints, network rules, CMK, repository/manifest positional parsing, cache credentials, and token/scope-map permissions.

Service Connector

src/…/commands.py dynamically generates command groups from resource matrices in serviceconnector/_resource_config.py. Source resources include Web App, Function App, AKS, Container App, and extension-backed Spring variants. For each source it registers {source} connection list/show/delete/list-configuration/validate/list-support-types/wait plus nested {source} connection create {target} and {source} connection update {target} commands. It also registers local connection commands using Connector operations.

serviceconnector/_resource_config.py is the routing and compatibility table. It defines source and target resource ID templates, parameter metadata, supported auth types, supported client types, target network-solution support, deprecated targets, local connection metadata, and special cases such as Confluent Kafka and Container App-to-Container App null auth. serviceconnector/_params.py uses that matrix to add or ignore command arguments per source/target pair, so adding a source, target, auth type, or client type usually requires updating the matrix rather than one static command registration.

serviceconnector/custom.py builds Linker/Connector payloads. It resolves source/target type from the running command, derives auth info, optionally delegates passwordless flows to the serviceconnector-passwordless extension, creates Key Vault/App Configuration helper connections when needed, sets user-token headers for OBO-dependent operations, supports service endpoint/private link flags, provisions new add-on targets through AddonFactory, validates service state, and supports no-recreate semantics. Local connections use a similar payload shape but target ConnectorOperations with subscription/resource-group/location parameters.

Bot Service

src/…/commands.py registers bot creation/update/show/delete plus source publish/download/prepare commands, bot authsetting, and preview channel groups for Facebook, email, Teams, Skype, Kik, Direct Line, Telegram, SMS, and Slack. It uses Bot Service SDK operation groups from botservice/_client_factory.py and custom operation modules for creation/publish/channel behavior.

botservice/custom.py creates Azure Bot resources after name and GUID validation, manages auth settings, downloads bot source through Kudu, prepares deployment files for Node.js/TypeScript/C# bots, publishes zip packages through Kudu, and updates bot metadata including endpoint, Application Insights fields, icon URL, SKU, and CMK settings. botservice/web_app_operations.py is the App Service coupling layer: it uses WebSiteManagementClient.web_apps to read app settings, SCM hostnames, and publishing credentials for bots hosted on Web Apps. Channel-specific operations live in botservice/channel_operations.py, while botservice/kudu_client.py, botservice/bot_publish_prep.py, templates, and web.config files support deployment workflows.

Coupling

Risks

  • src/…/_clients.py manually implements REST polling. If the Microsoft.App API changes its polling headers or returns terminal status in a different shape, ContainerAppClient/ManagedEnvironmentClient operations can hang, return stale JSON, or raise misleading ResourceNotFoundError even though the control-plane operation succeeded.
  • src/…/custom.py contains many shared helpers for Web Apps, Function Apps, Logic Apps, and Flex Consumption. A fix in a shared helper such as app settings, zip deploy, container settings, or site configuration can unintentionally change multiple command groups registered in appservice/commands.py.
  • src/…/_resource_config.py is a high-impact matrix. A wrong supported-auth/client-type entry can generate valid-looking commands in serviceconnector/commands.py that build invalid Linker payloads in serviceconnector/custom.py, or can hide a supported source/target combination entirely.
  • src/…/custom.py executes local Docker/Podman for acr login. The path-safety checks reduce current-directory execution risk, but changes around _resolve_docker_command, _validate_command_path, or _perform_registry_login can reintroduce unsafe binary resolution or break Cloud Shell/WSL fallback behavior.
  • src/…/custom.py invokes external kubectl for browse/proxy flows and writes temporary kubeconfig files. Changes around which, aks_browse, or credential merge paths can either execute the wrong binary or leak/overwrite kubeconfig state.