Skip to content

ci: use --hostname-type classic for the IoT Hub connection string in e2e pipelines - #1270

Merged
Carter Tinney (cartertinney) merged 3 commits into
mainfrom
maximsemenov/e2e-use-classic-iothub-host
Nov 17, 2026
Merged

Carter Tinney (cartertinney) merged 3 commits into
mainfrom
maximsemenov/e2e-use-classic-iothub-host

Conversation

@maximsemenov80

@maximsemenov80 Maxim Semenov (maximsemenov80) commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The DPS e2e (def 331) and Python E2E (def 426) pipelines fail on main since 2026-11-10 with HttpOperationError: ... 'Bad Request' on IoT Hub registry calls (get_device, create_device_with_sas). The same commit (3c779496) passed on 2026-10-27.

Root cause

These pipelines install the azure-iot Azure CLI extension on demand (The command requires the extension azure-iot. It will be installed first) and get the latest stable; nothing pins it, and the Azure CLI itself comes from the hosted image. azure-iot 1.0.0 (released 2026-11-05) lists a breaking change in its release history: "Hub connection-string/SAS and DPS linked-Hub creation commands default to automatic hostname selection."

So az iot hub connection-string show now returns HostName=<hub>.device.azure-devices.net (the device endpoint, TLS 1.3 preview) instead of <hub>.azure-devices.net. The test helpers and the azure-iot-hub registry manager take the host from that connection string and send registry (service) calls to the device endpoint, which answers 400. In the failing DPS run the earlier asserts pass (registration is assigned to the right hub); only the registry lookup fails.

Fix

Pass --hostname-type classic (supported by azure-iot 1.0.0; confirmed in --help for both commands):

  • az iot hub connection-string show ... --pn iothubowner --hostname-type classic in dps-e2e.yaml, python-e2e.yaml and python-nightly.yaml.
  • az iot dps linked-hub create ... --hostname-type classic in dps-e2e.yaml, so DPS links the classic host and the assigned hub it reports matches the test's linked hub.

The event hub connection string (--eh) is an sb:// endpoint and is left unchanged. (An earlier revision of this PR rewrote the host with a bash substitution; replaced by the supported option.)

Verification

Queued on this branch (commit 085be58e):

Pipeline Build Result
DPS e2e (def 331) 166255 20 passed, 4 skipped (was 20 failed on main, build 166137); the setup log shows only <hub>.azure-devices.net
Python E2E (def 426) 166256 all jobs succeeded
Python nightly (def 520) 166257 hub and DPS setup succeeded; all 11 test legs failed before running any test with ERROR: Unknown marker(s) in '-m' expression: x, which is unrelated to this PR (see below)

Not covered

  • Nightly test legs were not exercised. python-nightly.yaml runs pytest ... -m "not x". pytest 9.2.0 (2026-10-27) now validates marker names in -m expressions when strict_markers is on, so this fails on main too, independent of this change. Removing -m "not x" (it selects everything) is a separate fix.
  • The horton e2e gates use templates from Azure/iot-sdks-e2e-fx; they may need the same change there.
  • This does not test the Python device SDK against a .device. endpoint, which real users may now get from az iot hub connection-string show and the portal.

Also included: nightly marker fix (was #1271)

python-nightly is a gate on this PR and was failing with Unknown marker(s) in '-m' expression: x: pytest 9.2.0 validates marker names in -m under --strict-markers. -m "not x" is changed to -m "stress or not stress", which still runs every test, including the stress tests that pytest.ini deselects by default. Dropping -m would silently skip them.

It is combined here because neither change can pass the PR gates alone: the hostname fix needs the nightly gate green, and the marker fix needs the hub setup fixed. Verified together on python-nightly build 166372 (all 11 legs passed, 112 passed / 20 skipped each).

Hubs created since 2026-11-10 report the device endpoint
(<hub>.device.azure-devices.net) in the connection string returned by
`az iot hub connection-string show`. That endpoint does not serve registry
(service) operations: the DPS e2e helper and the azure-iot-hub registry
manager get HTTP 400 on get_device / create_device_with_sas, which broke the
DPS e2e and Python E2E pipelines on main (same commit passed on 2026-10-27).

Rewrite the host in IOTHUB_CONNECTION_STRING to the classic
<hub>.azure-devices.net right after it is generated, in the three pipelines
that create a hub. In the DPS pipeline this happens before the hub is linked
to DPS, so the assigned hub reported by DPS still matches the test's linked
hub.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

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.

🟢 Approval recommended

No active review issues remain for the pipeline hostname-normalization changes.

No open issues 🎉

What changed in this PR

Restores IoT Hub registry/service calls in the Python and DPS pipelines by normalizing generated connection strings to the classic hostname.

Changes:

  • Replaces .device.azure-devices.net with .azure-devices.net in three pipeline setup scripts without requiring newer CLI flags.
  • Applies the rewrite before DPS hub linking so the assigned hostname matches the tests’ expected hostname.
File Description
vsts/​python-nightly.yaml Normalizes the IoT Hub hostname for nightly service calls.
vsts/​python-e2e.yaml Normalizes the IoT Hub hostname for Python end-to-end service calls.
vsts/​dps-e2e.yaml Normalizes the hostname before service calls and DPS hub linking.

Review effort: Balanced

…tring

Use the supported azure-iot option rather than a string rewrite: pass
--hostname-type classic to `az iot hub connection-string show` (all three
pipelines) and to `az iot dps linked-hub create` (DPS e2e). The extension is
installed on demand at its latest stable version in these pipelines, which
supports the option, so there is no older version to accommodate.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@maximsemenov80 Maxim Semenov (maximsemenov80) changed the title ci: use the classic IoT Hub host for e2e service calls ci: use --hostname-type classic for the IoT Hub connection string in e2e pipelines Nov 12, 2026
The nightly passes -m "not x" so that it runs every test, including the stress
tests that tests/e2e/iothub_e2e/pytest.ini deselects by default (addopts -m "not
stress"); a command-line -m replaces that default. "x" is not a registered
marker, and pytest 9.2.0 (2026-10-27) now validates marker names in -m
expressions when --strict-markers is on, so every test leg fails with "Unknown
marker(s) in '-m' expression: x" before running a test.

Use "stress or not stress" instead: it selects every test and only references a
registered marker. Simply dropping -m would silently stop running the stress
tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

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.

🟢 Approval recommended

No active review issues remain for the pipeline hostname and nightly test-selection updates.

No open issues 🎉

Review effort: Balanced

@cartertinney
Carter Tinney (cartertinney) merged commit 7e7ddd9 into main Nov 17, 2026
42 checks passed
@cartertinney
Carter Tinney (cartertinney) deleted the maximsemenov/e2e-use-classic-iothub-host branch November 17, 2026 17:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants