Skip to content

Set file upload at hub creation when certificate management is on - #455

Merged
Ewerton Scaboro da Silva (ewertons) merged 2 commits into
masterfrom
ewertons/cert-mgmt-file-upload
Oct 1, 2026
Merged

Ewerton Scaboro da Silva (ewertons) merged 2 commits into
masterfrom
ewertons/cert-mgmt-file-upload

Conversation

@ewertons

@ewertons Ewerton Scaboro da Silva (ewertons) commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Problem

provision-e2e-resources fails when enable-certificate-management and enable-file-upload are both 'true':

ERROR: ADR properties are only supported for Generation2 IoT Hub SKUs.
ERROR: "Updating Azure IoT Hub file upload settings" failed (exit code 1)

After the ADR link the S1 hub reports properties.deviceRegistry. The azure-iot CLI extension's az iot hub update rejects any non-GEN2 hub carrying it, client-side, before sending a request. Latest extension (0.33.0b1) has the same check. The action's --fileupload-notifications true update would fail the same way.

Fix (certificate management only)

  • Storage account/container created before the hub; storageEndpoints.$default (PT1H SAS TTL) and enableFileUploadNotifications sent in the hub create PUT.
  • After the ADR link, the hub is read back; provisioning fails unless storage account, container, SAS TTL and notifications all match.
  • Both az iot hub update calls skipped.
  • Hub and DPS create PUTs also retry IH400097 ("Unable to fetch credentials"), returned while a new system-assigned identity is being issued. Seen on DPS create in [.NET] Pin e2e provisioning action to fix file upload with certificate management azure-iot-sdk#340's first run.

Without certificate management the az calls are unchanged.

Tests

New tests/Test-FileUploadProvisioning.ps1 runs the action script and module with a stubbed az, now part of validate-actions:

  • master: 14 failures, including the error above;
  • this branch: passes; no-cert-mgmt az calls identical to master (24/24).

Validate-Module.ps1, validate-actions.mjs, actionlint: pass.

Azure: in Azure/azure-iot-sdk#340 the hub create PUT with storage settings succeeded; that run then hit the transient IH400097 on DPS create, now retried. Full end-to-end validation pending.

Once a hub is linked to an ADR namespace, `az iot hub update` (azure-iot
extension) fails on S1 hubs with "ADR properties are only supported for
Generation2 IoT Hub SKUs.", because the hub then reports
properties.deviceRegistry. This broke provisioning with both
enable-certificate-management and enable-file-upload.

With certificate management:
- create the storage account before the hub and put storageEndpoints.$default
  and enableFileUploadNotifications in the hub create PUT;
- after the ADR link, read the hub back and fail if those settings are gone;
- skip both `az iot hub update` calls (module and action).

Without certificate management the az calls are unchanged.

Adds tests/Test-FileUploadProvisioning.ps1 (stubbed az, no Azure) and runs it
in validate-actions.

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.

Copilot review overview

🟡 Changes recommended

The post-link validation does not verify the storage connection string or SAS TTL.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Configures IoT Hub file upload before ADR linking to avoid rejected post-link CLI updates.

Changes:

  • Adds file-upload settings to the certificate-management hub creation request.
  • Skips incompatible post-link updates and validates resulting settings.
  • Adds stub-based provisioning tests to CI.
File Description
scripts/​AzIotSdkTest/​parts/​Provisioning.ps1 Moves storage setup into hub creation for ADR.
actions/​provision-e2e-resources/​action.yml Skips the notification update for ADR hubs.
tests/​Test-FileUploadProvisioning.ps1 Tests ADR and non-ADR provisioning paths.
.github/​workflows/​validate-actions.yml Runs the new provisioning test.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread scripts/AzIotSdkTest/parts/Provisioning.ps1 Outdated
…create

- Post-link check also compares the storage account (from the connection
  string; the hub masks the key) and the PT1H SAS TTL.
- Hub and DPS create PUTs retry IH400097 "Unable to fetch credentials",
  returned while the new system-assigned identity is being issued.
- Test: stub masks AccountKey on GET; new scenarios for a changed SAS TTL,
  a changed storage account, and a transient IH400097 on DPS create.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Ewerton Scaboro da Silva (ewertons) added a commit to Azure/azure-iot-sdk that referenced this pull request Oct 1, 2026
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.

Copilot review overview

🔵 Needs a closer look

Azure control-plane behavior still needs full end-to-end validation, and one test assertion does not verify container creation.

Review effort: Balanced
Findings: None

Resolved since last review (1)
Previously missed (1)

In code that hasn't changed since last review

Medium severity Require container creation before hub update

tests/​Test-FileUploadProvisioning.ps1:256

This assertion does not require the container-create call to exist: Find-Call returns -1, and -1 -lt $HubPut still passes. A regression that omits container creation could therefore satisfy this ordering check even though the hub points to a nonexistent container. Require $Container -ge 0 as well.

@ewertons
Ewerton Scaboro da Silva (ewertons) merged commit b96d2aa into master Oct 1, 2026
6 checks passed
Ewerton Scaboro da Silva (ewertons) added a commit to Azure/azure-iot-sdk that referenced this pull request Oct 1, 2026
… b96d2aa

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Ewerton Scaboro da Silva (ewertons) added a commit to Azure/azure-iot-sdk that referenced this pull request Oct 2, 2026
…e management (#340)

Fixes ci-dotnet provisioning with `enable-certificate-management` +
`enable-file-upload`, which failed with:

```
ERROR: ADR properties are only supported for Generation2 IoT Hub SKUs.
ERROR: "Updating Azure IoT Hub file upload settings" failed (exit code 1)
```

Change: `provision-e2e-resources` pin `5734267` (v1.0.0) -> `b96d2aa`
(iot-sdks-e2e-fx master, merge of Azure/iot-sdks-e2e-fx#455).

Validated: ci-dotnet run 36938847847 at #455 head `2ec07f6`
(action/module identical to `b96d2aa`) passed provisioning, e2e on
ubuntu-latest and windows-latest, and teardown.

Targets `timtay/certificates` (#297).

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Ewerton Scaboro da Silva (ewertons) added a commit to Azure/azure-iot-sdk that referenced this pull request Oct 2, 2026
Pins e2e provisioning in `ci-c-e2e`, `ci-c-e2e-csr` and `ci-dotnet` to
Azure/iot-sdks-e2e-fx **v1.0.1** (`b96d2aa`), replacing v1.0.0.

Since v1.0.0:
- Azure/iot-sdks-e2e-fx#454: retries transient ARM failures during
certificate-management provisioning (gateway errors on hub/DPS create;
`409 ResourceProvisioningInProgress` on ADR link re-submit). Fixes the
`setup (provision)` failures in `ci-c-e2e-csr` run 36681736303.
- Azure/iot-sdks-e2e-fx#455: sets file upload at hub creation when
certificate management is on (needed by `ci-dotnet` with certificate
management, #297).
- Azure/iot-sdks-e2e-fx#453: default location `eastus2euap` (already set
explicitly here).

**Validation**
- actionlint 1.7.12: clean. zizmor 1.30.1 (online): no findings; a wrong
version comment is reported, so `ref-version-mismatch` is checked.
- v1.0.1 commit: iot-sdks-e2e-fx module checks and `horton-gate-build`
pass.
- #454 content verified end to end earlier (runs 36683896318,
36689775583).
- PR runs of `ci-c-e2e` / `ci-c-e2e-csr` use the shared environments and
skip provisioning; full-provisioning runs are dispatched on this branch
for both. `ci-dotnet` provisions in its PR run.

Co-authored-by: ewertons <12401690+ewertons@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants