Skip to content

Run Python E2E, python-nightly and dps-e2e against hubs with local auth disabled - #1278

Merged
Ewerton Scaboro da Silva (ewertons) merged 6 commits into
mainfrom
python-e2e-disable-local-auth
Dec 4, 2026
Merged

Ewerton Scaboro da Silva (ewertons) merged 6 commits into
mainfrom
python-e2e-disable-local-auth

Conversation

@ewertons

@ewertons Ewerton Scaboro da Silva (ewertons) commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Change

Python E2E (vsts/python-e2e.yaml), python-nightly (vsts/python-nightly.yaml) and Azure.azure-iot-sdk-python-dps-e2e (vsts/dps-e2e.yaml) now create their per-run IoT Hub with local authentication disabled, so they no longer use IoT Hub or Event Hub connection strings.

  • Provisioning (vsts/templates/steps-create-iothub-e2e-resources.yaml): New-AzIotTestEnvironment -NoDps -DisableLocalAuth -RouteTelemetryToEventHub from the AzIotSdkTest module of Azure/iot-sdks-e2e-fx, pinned to commit c8c4e99e8dd99b8fe47896f833f49d1fee7747a8 (AzIotSdkTest 1.11.1; a full SHA, as tags are mutable). The built-in Event Hub-compatible endpoint takes only shared access keys, so device telemetry goes to an Event Hub with local auth disabled (consumer groups cg1..cgN, one per parallel job). A twin-change-events route now targets that Event Hub. The module grants the service connection IoT Hub Data Contributor and Azure Event Hubs Data Receiver.
  • Tests (vsts/templates/steps-run-iothub-e2e-tests.yaml): pytest runs in an AzureCLI@2 task. It waits until the Event Hub role assignments apply, then reads IOTHUB_E2E_IOTHUB_HOSTNAME, IOTHUB_E2E_EVENTHUB_FULLY_QUALIFIED_NAMESPACE, IOTHUB_E2E_EVENTHUB_NAME and IOTHUB_E2E_EVENTHUB_CONSUMER_GROUP.
  • Credentials (dev_utils/service_credential.py):
    • In Azure Pipelines, AzurePipelinesCredential for the task's service connection. It refreshes tokens, so legs that outlast one access token are covered.
    • Elsewhere, DefaultAzureCredential.
    • ServiceHelper/ServiceHelperSync, device_identity_helper and the sdklab tools use it through IoTHubRegistryManager.from_token_credential and EventHubConsumerClient(fully_qualified_namespace=..., credential=...).
  • dps-e2e: the hub and DPS come from New-AzIotTestEnvironment -DisableLocalAuth, which links DPS to the hub with its system-assigned identity. The provisioning tests check and delete registered devices with IoTHubRegistryManager.from_token_credential (reads IOTHUB_E2E_IOTHUB_HOSTNAME). Registry requests time out after 10 seconds instead of msrest's 100, so a read the hub leaves unanswered is retried by msrest rather than outlasting the test timeout. The vendored iothubservice20180630 client is removed. DPS keeps its shared access policy: provisioningserviceclient creates enrollments with the DPS connection string.
  • Devices keep their symmetric keys, SAS tokens and X.509 certificates.
  • New dependency in the e2e group: azure-identity>=1.17.0.

Python Canary (vsts/python-canary.yaml) still passes IOTHUB_CONNECTION_STRING/EVENTHUB_CONNECTION_STRING for a shared hub, which test_env no longer reads. That definition is disabled, and re-enabling it needs its hub set up the same way.

Validation

  • ruff passes. tests/e2e/iothub_e2e/test_service_helper.py and test_wait_helpers.py pass; provisioning e2e tests collect.
  • Python E2E and dps-e2e run on this PR. python-nightly passed on this PR's merge ref (13 legs, longest 35 min, so within one token lifetime).

Both pipelines now create their IoT Hub with the AzIotSdkTest module of
Azure/iot-sdks-e2e-fx (pinned to 72c8b95) with local authentication
disabled. Device telemetry and twin change events are routed to an Event
Hub that accepts only Microsoft Entra ID, since the built-in Event
Hub-compatible endpoint takes only shared access keys.

The iothub_e2e tests and sdklab tools reach the hub and that Event Hub
with a token credential instead of connection strings: in Azure
Pipelines, AzurePipelinesCredential for the task's service connection,
which keeps issuing tokens for the whole run; elsewhere,
DefaultAzureCredential. The tests read IOTHUB_E2E_IOTHUB_HOSTNAME,
IOTHUB_E2E_EVENTHUB_FULLY_QUALIFIED_NAMESPACE, IOTHUB_E2E_EVENTHUB_NAME
and IOTHUB_E2E_EVENTHUB_CONSUMER_GROUP. Devices still use their own keys.
@ewertons

Copy link
Copy Markdown
Contributor Author

/azp run Python E2E

@azure-pipelines

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

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.

🔵 Needs a closer look

Missing Azure E2E and full-duration Windows nightly results leave federation, RBAC, routed telemetry/twin delivery, and token renewal beyond one hour unverified.

No open issues 🎉

What changed in this PR

Migrates Python E2E and nightly service-side authentication to Microsoft Entra ID, using per-run resources with local authentication disabled. Device SAS authentication remains unchanged.

Changes:

  • Shares provisioning and test-running templates across both pipelines.
  • Uses token credentials for IoT Hub service operations and a dedicated Event Hub for telemetry and twin changes.
  • Updates test helpers, sdklab tools, environment settings, and dependencies.
File Description
vsts/​templates/​steps-run-iothub-e2e-tests.yaml Runs tests with service-connection authentication after a role-propagation wait.
vsts/​templates/​steps-create-iothub-e2e-resources.yaml Provisions resources and routes with local authentication disabled.
vsts/​python-nightly.yaml Adopts shared templates and endpoint variables.
vsts/​python-e2e.yaml Adopts shared templates for Windows and Linux.
uv.lock Locks Azure Identity and supporting dependencies.
tests/​e2e/​iothub_e2e/​sync/​conftest.py Passes token credentials to synchronous fixtures.
tests/​e2e/​iothub_e2e/​device_identity_helper.py Uses token authentication for device management.
tests/​e2e/​iothub_e2e/​aio/​conftest.py Passes token credentials to asynchronous fixtures.
sdklab/​simple_stress/​simple_send_message_bulk.py Updates stress-tool service authentication.
sdklab/​fuzzing/​fuzz_send_message.py Updates fuzzing-tool service authentication.
pyproject.toml Adds Azure Identity to E2E dependencies.
dev_utils/​dev_utils/​test_env.py Reads endpoint settings instead of service connection strings.
dev_utils/​dev_utils/​service_helper.py Forwards endpoints and credentials to the synchronous helper.
dev_utils/​dev_utils/​service_helper_sync.py Creates token-authenticated service clients.
dev_utils/​dev_utils/​service_credential.py Selects and caches pipeline or default Azure credentials.

Review effort: Balanced

The provisioning e2e tests read and delete the devices DPS registers with
azure-iot-hub's IoTHubRegistryManager and a Microsoft Entra ID token
credential (dev_utils.service_credential) instead of the hub connection
string. The pipeline creates the hub and DPS with AzIotSdkTest
New-AzIotTestEnvironment -DisableLocalAuth, which links DPS to the hub with
its system-assigned identity. Removes the vendored iothubservice20180630
client, now unused. DPS keeps its own shared access policy for enrollments.
@ewertons Ewerton Scaboro da Silva (ewertons) changed the title Run Python E2E and python-nightly against a hub with local auth disabled Run Python E2E, python-nightly and dps-e2e against hubs with local auth disabled Dec 3, 2026
Same commit as before (72c8b95).
msrest waits 100 seconds by default, so a request the hub leaves unanswered
outlasts the test timeout. A read that times out is retried by msrest.
…cal-auth

# Conflicts:
#	tests/e2e/provisioning_e2e/service_helper.py
@ewertons
Ewerton Scaboro da Silva (ewertons) merged commit b6c7a75 into main Dec 4, 2026
42 checks passed
@ewertons
Ewerton Scaboro da Silva (ewertons) deleted the python-e2e-disable-local-auth branch December 4, 2026 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants