Skip to content

[App Service] az webapp config egress: Add egress configuration and connection management - #34249

Merged
Ethan Yang (necusjz) merged 11 commits into
Azure:devfrom
cmriachi:feature-egress-config-commands
Nov 4, 2026
Merged

Ethan Yang (necusjz) merged 11 commits into
Azure:devfrom
cmriachi:feature-egress-config-commands

Conversation

@cmriachi

@cmriachi cmriachi commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

🤖 PR Validation — ⚠️ Review suggested

Breaking Changes Tests Suppressions
⚠️ None ️✔️ 130/130 ⚠️ 1 added
⚠️AzureCLI-BreakingChangeTest
⚠️appservice
rule cmd_name rule_message suggest_message
⚠️ 1011 - SubgroupAdd webapp config egress sub group webapp config egress added

This PR adds warning or check suppressions. Fix the underlying warning where possible and justify each remaining suppression in a code comment or the PR description.

1 added suppression
File Line Kind Code
src/azure-cli/azure/cli/command_modules/appservice/tests/latest/test_webapp_egress.py 42 pylint client._request.side_effect = self._make_request # pylint: disable=protected-access

Related command

az webapp config egress set
az webapp config egress show
az webapp config egress connection add
az webapp config egress connection show
az webapp config egress connection remove

Description

Add preview egress configuration and named connection management for web apps and deployment slots.

  • set reads the existing configuration, applies optional --enabled true/false, and writes it back while preserving all connection definitions. Boolean values map to the backend's existing Enabled/Disabled strings. Omitting the flag preserves the existing state; a bare --enabled means true. set does not accept connection definitions and cannot replace or clear the connection collection.
  • show returns the complete egress configuration. connection add/show/remove manage individual connections, including case-insensitive upsert and lookup, while preserving unrelated connections and the enabled state. There is no connection delete alias.
  • Connection arguments reference existing AppSettings or ConnectionStrings names, not their secret values. Support includes explicit managed identity token scopes, assigned user identity overrides, protocol/authentication choices, and HTTP credential header/format injection.
  • The handwritten custom layer supplies the public UX. Four unregistered generated AAZ GET/PUT helpers implement app and slot serialization/transport; no additional web site command surface is exposed.

Companion command models: Azure/aaz#1134.

Validation gaps

Production helpers intentionally remain on API 2026-09-01. That API version was not registered in the test region during validation, so native API09 service compatibility is not validated. The genuine app-and-slot recording uses API 2026-08-01 through an explicitly labeled, test-local scoped override of only the four GET/PUT query properties. The cassette honestly records API08 URLs; neither production code nor recorded URLs implement a fallback. Native API09 service validation and recording remain outstanding before this is ready to ship.

For the first connection, connection add preserves the enabled value returned by GET. If GET omits it, the PUT also omits it rather than assuming Disabled. Compatibility of that initial-state behavior with the target backend's state-validation contract remains to be confirmed; the API08 evidence does not establish API09 compatibility.

The public --identity-scope help does not claim that the platform infers the token scope. The companion AAZ PR tracks the remaining misleading generated-help wording.

Testing Guide

Examples below assume that the app, referenced settings, and required identities already exist:

az webapp config egress set --resource-group MyRG --name MyApp --enabled true
az webapp config egress set --resource-group MyRG --name MyApp --slot staging --enabled false
az webapp config egress show --resource-group MyRG --name MyApp
az webapp config egress connection add --resource-group MyRG --name MyApp --connection-name orders-db --protocol Tds --auth ManagedIdentity --source ConnectionStrings --value-setting OrdersDb --identity-scope https://database.windows.net/.default
az webapp config egress connection show --resource-group MyRG --name MyApp --connection-name ORDERS-DB
az webapp config egress connection remove --resource-group MyRG --name MyApp --connection-name orders-db

Configuration-management tests use synthetic, non-secret setting values and real assigned identities. They do not test outbound application traffic or provision SQL/Storage backends, grants, or firewall changes.

Latest post-upstream-sync checks:

Check Result
azdev style appservice Passed, exit 0: pylint and flake8.
azdev linter appservice --ci-exclusions Passed, exit 0: 22 rule results and no violations. Fifteen existing placeholder-subscription warnings were non-failing.
azdev latest-index verify --cli <checkout> Passed, exit 0: latest packaged indices are current; no regeneration was needed.
Focused offline runner below Passed, exit 0: 33 tests in 11.946 seconds: one genuine API08 app-and-slot playback, 22 egress unit tests, five output-transformer tests, and five App Service plan-default tests.
az webapp config egress set --help Passed, exit 0: optional true/false enabled flag, no connection arguments, preservation semantics and updated examples.
git diff --check and merged first-parent diff whitespace check Passed, exit 0.

azdev cmdcov appservice was also run earlier: exit 0, all five egress commands attributed, with 206/312 module commands covered (66.026%) and 106 non-egress baseline gaps. Those counts predate the final SET workflow and upstream sync; command coverage was not rerun after those changes, and is not a claim of full argument/example coverage.

The full appservice test suite was not run. No live tests or recording changes were performed for PR publication.
The bot-managed validation block above is preserved verbatim from the existing PR and refers to older commit f16acd0a9b1c6e8ff2a87bf11a4998ff12d313f9. Its 130/130 result is not fresh validation of current head c9ed500bafd16b3701c13d4fdc4d9096ce1e2e62.

The focused offline verification used the following selectors in the same process, with a fresh credential-free config, socket connections blocked, and only the unrelated CLI update notifier suppressed. Reproduce from the checkout root in the existing development environment:

$env:AZURE_TEST_RUN_LIVE = $null
$env:AZURE_EGRESS_TEST_SUBSCRIPTION_ID = $null
$env:AZURE_CORE_COLLECT_TELEMETRY = 'false'
$env:AZURE_LOGGING_ENABLE_LOG_FILE = 'false'
@'
import hashlib
import os
import socket
import sys
import tempfile
import unittest
from pathlib import Path
from unittest.mock import patch

root = Path.cwd()
tests = root / "src" / "azure-cli" / "azure" / "cli" / "command_modules" / "appservice" / "tests" / "latest"
cassette = tests / "recordings" / "test_webapp_egress_api08_app_and_slot.yaml"
assert cassette.is_file(), "Missing recording: do not fall through to live mode."
before = hashlib.sha256(cassette.read_bytes()).digest()
sys.path.insert(0, str(tests))

def deny_network(*args, **kwargs):
    raise AssertionError("Real network access is forbidden during offline verification.")

with tempfile.TemporaryDirectory() as config:
    with patch.dict(os.environ, {"AZURE_CONFIG_DIR": config, "AZURE_EXTENSION_DIR": str(Path(config) / "extensions")}), \
            patch.object(socket.socket, "connect", deny_network), \
            patch.object(socket.socket, "connect_ex", deny_network), \
            patch("azure.cli.core.util.show_updates_available"):
        suite = unittest.defaultTestLoader.loadTestsFromNames([
            "test_webapp_egress_api08.WebappEgressApi08ScenarioTest.test_webapp_egress_api08_app_and_slot",
            "test_webapp_egress",
            "test_webapp_commands_thru_mock.TestWebappOutputTransformers",
            "test_webapp_commands_thru_mock.TestCreateAppServicePlanDefaults",
        ])
        assert suite.countTestCases() == 33
        result = unittest.TextTestRunner(verbosity=2).run(suite)
assert hashlib.sha256(cassette.read_bytes()).digest() == before
raise SystemExit(not result.wasSuccessful())
'@ | python -B -u -

The 22 egress unit tests exercise parser-to-wire true/false/bare/omitted behavior, rejection of removed connection arguments before HTTP, GET-then-PUT ordering, app/slot routes, complete nested connection preservation, missing/empty configurations, error propagation, and connection add/show/remove validation and regressions. All four original API09 metadata/resource/query properties were additionally verified after the test-local API08 override had been restored.

The earlier explicitly authorized live re-recording ran only this selected scenario:

# Select an explicitly approved disposable test subscription before recording.
$env:AZURE_TEST_RUN_LIVE = 'true'
$env:AZURE_EGRESS_TEST_SUBSCRIPTION_ID = '<approved-test-subscription-id>'
python -B -u -m unittest discover -s 'src\azure-cli\azure\cli\command_modules\appservice\tests\latest' -p 'test_webapp_egress_api08.py' -v

Result: one scenario passed, exit 0, in 195.076 seconds. It created its own temporary resource group, one Linux S1 plan, app, staging slot, and assigned identities; cleanup was confirmed. No pre-existing manual test app was modified.

The sanitized cassette contains 118 genuine HTTP interactions, including 94 egress interactions and 14 SET GET/PUT preservation pairs across app and slot paths. It covers all five commands, explicit managed identity scope and UAMI override, both setting sources, credential injection, case-insensitive names without duplicates, missing-name failures without mutation, remove-last, and parent/slot isolation. Standard HTTP matchers are retained and request-body matching is additionally required. No fabricated interactions, API-version URL rewriting, or skipped assertions were used. Testsdk processors sanitize credentials and identity metadata; the cassette remained byte-unchanged through offline playback.

History Notes

[App Service] az webapp config egress: Add enabled-state updates and configuration queries for web apps and deployment slots
[App Service] az webapp config egress connection: Add named connection add/show/remove with setting references and managed identity options


This checklist is used to make sure that common guidelines for a pull request are followed.

cmriachi and others added 3 commits October 19, 2026 10:43
Add genuine app-and-slot configuration-management recording and scoped test-only API08 verification. Keep production API09 helpers unchanged; API09 release validation and re-recording remain outstanding.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 2f1db4a1-7534-4e3e-ac09-81448337f9ad
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@microsoft-github-policy-service microsoft-github-policy-service Bot added the customer-reported Issues that are reported by GitHub users external to the Azure organization. label Oct 20, 2026
@microsoft-github-policy-service

Copy link
Copy Markdown
Contributor

Thank you for your contribution cmriachi! We will review the pull request and get back to you soon.

@x-engineering-agent

Copy link
Copy Markdown
Contributor

Hi cmriachi,
Since the current milestone time is less than 7 days, this pr will be reviewed in the next milestone.

@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

cmriachi and others added 2 commits October 27, 2026 14:58
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 2f1db4a1-7534-4e3e-ac09-81448337f9ad
@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

@cmriachi
cmriachi marked this pull request as ready for review October 27, 2026 22:25
Copilot AI balanced review requested due to automatic review settings October 27, 2026 22:25
@cmriachi cmriachi changed the title Feature egress config commands [App Service] az webapp config egress: Add egress configuration and connection management Oct 27, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Enabling an empty configuration sends a deletion-shaped request, and service-backed coverage bypasses the production API version.

2 open issues
What changed in this PR

Adds preview az webapp config egress commands to the App Service module for managing virtualized backend connections on apps and deployment slots.

Changes:

  • Adds configuration show/set and named connection add/remove/show commands, with validation and help examples.
  • Introduces private generated helpers for app and slot egress operations using API version 2026-09-01.
  • Adds mocked command tests and an API08 app-and-slot scenario.

All paths below are relative to src/azure-cli/azure/cli/command_modules/appservice/.

File Description
tests/​latest/​test_webapp_egress.py Tests command behavior, validation, serialization, and errors.
tests/​latest/​test_webapp_egress_api08.py Adds API08 scenario coverage and recording sanitization.
custom.py Implements configuration and connection handlers.
commands.py Registers preview egress commands.
aaz/​latest/​web/​site/​slot/​config/​egress/​_show.py Reads slot egress configuration.
aaz/​latest/​web/​site/​slot/​config/​egress/​_create.py Writes slot egress configuration.
aaz/​latest/​web/​site/​slot/​config/​egress/​__init__.py Exports slot egress helpers.
aaz/​latest/​web/​site/​slot/​config/​egress/​__cmd_group.py Defines the private slot egress group.
aaz/​latest/​web/​site/​slot/​config/​__init__.py Initializes the slot configuration package.
aaz/​latest/​web/​site/​slot/​config/​__cmd_group.py Defines the private slot configuration group.
aaz/​latest/​web/​site/​slot/​__init__.py Initializes the slot package.
aaz/​latest/​web/​site/​slot/​__cmd_group.py Defines the private slot group.
aaz/​latest/​web/​site/​config/​egress/​_show.py Reads app egress configuration.
aaz/​latest/​web/​site/​config/​egress/​_create.py Writes app egress configuration.
aaz/​latest/​web/​site/​config/​egress/​__init__.py Exports app egress helpers.
aaz/​latest/​web/​site/​config/​egress/​__cmd_group.py Defines the private app egress group.
aaz/​latest/​web/​site/​config/​__init__.py Initializes the app configuration package.
aaz/​latest/​web/​site/​config/​__cmd_group.py Defines the private app configuration group.
aaz/​latest/​web/​site/​__init__.py Initializes the site package.
aaz/​latest/​web/​site/​__cmd_group.py Defines the private site group.
aaz/​latest/​web/​__init__.py Initializes the web helper package.
aaz/​latest/​web/​__cmd_group.py Defines the private web group.
_params.py Defines public egress command arguments.
_help.py Documents commands and usage examples.
_constants.py Defines supported protocols, authentication types, and sources.

Review effort: Balanced

Comment on lines +90 to +91
stack.enter_context(patch.object(
operation, 'query_parameters', _api08_query_parameters(operation.query_parameters)))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

our api changes have not yet been deployed everywhere for 2026-09-01, but our backend service accepts servicing requests with the latest/most up-to-date api version if the explicit api version is not found

hence why i had to make the testing use 2026-08-01

question: can we set the production az cli commands to also use 2026-08-01 under the hood even as the azure-rest-api-specs pr is not merged yet (due to not having been deployed everywhere yet)?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As these are aaz generated commands we do not provide any escape latches to override the api version. If you want to target 2026-08-01. you would need to regenerate the commands starting from the aaz models.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed the recording tests to use 2026-09-01 against brazilus arm endpoint (since for now that is where we have deployed our api version, we are in the process of deploying it further)

@cmriachi

Copy link
Copy Markdown
Contributor Author

another concern: i was told by a sister team of ours that you do not allow checking in azure cli commands unless the azure-rest-api-spec PR is merged in. We cannot merge the PR in yet because the code backing up the API is not yet deployed everywhere. Is there a solution for this timeline?

@JaysonTaiMicrosoft

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

@JaysonTaiMicrosoft

Copy link
Copy Markdown
Contributor

cmriachi please fix the merge conflicts.

@cmriachi

cmriachi commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

mansoor sarfraz (@msarfraz) Naga Nandyala (@naga-nandyala) we are targeting the nov 11 milestone to get these changes in, waiting on full arm deployment of our api version 2026-09-01 before merging of course, but in the meantime we would like reviews for correctness to be ready to merge this in directly when the time comes (close to nov 11)

@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

@yonzhan

Copy link
Copy Markdown
Collaborator

Please fix CI issues

@yonzhan
Yong Zhang (yonzhan) requested a review from a team November 2, 2026 22:17
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

@naga-nandyala Naga Nandyala (naga-nandyala) added the Request X Engineering Agent Ask the agent to triage this issue or review this PR label Nov 4, 2026
@x-engineering-agent

Copy link
Copy Markdown
Contributor

X Engineering Agent Pull request review: In progress

In progress — X Engineering Agent is reviewing this PR at f7dd425. This comment will be updated with the results.

X Engineering Agent · React with +1 or -1 to train the agent

@necusjz

Copy link
Copy Markdown
Member

lgtm

@necusjz
Ethan Yang (necusjz) merged commit d166c61 into Azure:dev Nov 4, 2026
55 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

customer-reported Issues that are reported by GitHub users external to the Azure organization. Request X Engineering Agent Ask the agent to triage this issue or review this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants