Skip to content

Add Azure IoT Hub routing endpoint health and diagnostics tools - #3894

Merged
jichang1 merged 9 commits into
microsoft:mainfrom
vineetkalki:iothub/routing-endpoint-health
Oct 28, 2026
Merged

jichang1 merged 9 commits into
microsoft:mainfrom
vineetkalki:iothub/routing-endpoint-health

Conversation

@vineetkalki

@vineetkalki vineetkalki commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds two read-only Azure IoT Hub message-routing troubleshooting tools to the Azure MCP Server, building on the IoT Hub toolset from #3074 and #3180. They let an agent answer "are my routing destinations healthy?" and "why were messages to this destination failing?" from the services' own evidence, without the tools inferring conclusions.

Tool Command Returns
iothub_routing_endpoint-health azmcp iothub routing endpoint-health endpoints: the current IoT Hub-reported routingEndpointsHealth snapshot for one or all custom endpoints (endpointId, endpointName, healthStatus, lastKnownError, lastKnownErrorTime, lastSuccessfulSendAttemptTime, lastSendAttemptTime). Point in time only; no time-range options.
iothub_routing_endpoint-diagnostics azmcp iothub routing endpoint-diagnostics observationWindow plus endpoints: per-endpoint IoT Hub RoutingDeliveries/RoutingDeliveryLatency metrics, current target existence from ARM, and target-resource Azure Monitor metrics for Event Hubs, Service Bus queues/topics, Blob Storage containers, and Cosmos DB SQL containers. Paired --start-time/--end-time (default: previous 24 hours) and --interval (default PT1H, at most 720 buckets).

iothub_hub_get also returns an additive routingEndpoints field listing the hub's configured custom endpoints (non-secret fields only; connection strings and keys are never deserialized).

Implementation follows the existing IoT Hub toolset patterns:

  • Layout and naming. IoTHubRoutingEndpointHealthCommand/IoTHubRoutingEndpointDiagnosticsCommand and their options sit under Commands/Routing and Options/Routing, inherit BaseIoTHubCommand, and register a routing command group. Routing domain logic (endpoint mapping, metric evidence building, observation-window rules) lives in src/Routing, mirroring src/Query. Result and wire models are public records and classes in Models.
  • Dedicated service. IIoTHubRoutingService keeps routing orchestration separate from the hub and device services; hub get and routing share endpoint conversion through RoutingEndpointMapper.
  • Evidence, not verdicts. Both tools return native service data (REST health fields; Azure Monitor metric names, dimensions, and aggregations) and never synthesize a health verdict, confidence score, or root cause. Missing metric values are reported through per-metric availability metadata rather than as zero. Routing targets are resolved only from an endpoint's endpointUri; key-based Event Hubs, Service Bus, and Storage endpoints have none and report an unresolved target rather than a guessed one.
  • Raw ARM reads. routingEndpointsHealth and target existence checks use an Azure.Core pipeline over the factory-created HttpClient (SDK-default retries, recorded-test playback). Rooted ARM paths resolve against the configured cloud's ARM endpoint, and every request and nextLink is checked against the arm endpoint allow-list with IAzureService.ValidateAzureServiceEndpoint before a credential is resolved, following URL validation for Postgres, Pricing, Quota, Resource Health, Search, Service Bus, Service Fabric, and Speech tools #3740 and Add URL validation for all ArmClient uses and add DNS->IP address resolution SSRF protections. #3884.
  • Resource names. Hub and resource group names are checked against the Azure naming rules before any credential or network work, so a value such as rg1/../rg2 can't redirect an ARM request to a different resource group. The check covers both routing tools and IoTHubService, which serves hub get and the device and query tools. Routing targets built from the hub's endpoint configuration are reported as unresolved unless each name is a single path segment.
  • Bounded operations. Each routing operation has a 100-second budget; expiry returns HTTP 408 while caller cancellation is preserved. Per-source failures are reported as partial evidence instead of failing the whole call.
  • Operation plane. endpoint-health is Control (IoT Hub routingEndpointsHealth ARM operation). endpoint-diagnostics is Both: Azure Monitor metric evidence (classified Data, as for monitor metrics query) plus current target existence read from ARM.
  • Consolidated mode. Each routing tool has its own consolidated entry, matching the other IoT Hub tools.
  • Live and recorded tests. test-resources.bicep deploys a Service Bus namespace, queue, and topic with a routing identity. test-resources-post.ps1 then adds the identity-based routing endpoints, retrying until the identity's Service Bus role takes effect, and creates the test devices over Microsoft Entra ID instead of the azure-iot CLI extension, which can't be installed on network-isolated pipeline agents. Both routing live tests are recorded.

Documentation:

Validation:

  • dotnet test --project tools/Azure.Mcp.Tools.IoTHub/tests/Azure.Mcp.Tools.IoTHub.Tests/Azure.Mcp.Tools.IoTHub.Tests.csproj -c Release --filter-not-trait TestType=Live (Windows): passed, 244/244.
  • CI mcp - pullrequest on the PR merge ref (build 6994390): the IoT Hub test assembly passed 248/248 on both Linux x64 and Windows x64 (the 244 unit tests plus the 4 recorded tests in playback).
  • CI mcp - pullrequest - live on ca2e181 (build 6963792): the 4 IoT Hub live tests passed in both stdio and HTTP modes.
  • dotnet test --project tools/Azure.Mcp.Tools.IoTHub/tests/Azure.Mcp.Tools.IoTHub.Tests/Azure.Mcp.Tools.IoTHub.Tests.csproj -c Debug --filter-trait TestType=Live (Playback): passed, 4/4 (routing endpoint health, routing endpoint diagnostics, hub get, device list).
  • The same 4 tests in Live mode against a fresh deployment of test-resources.bicep and test-resources-post.ps1 in a separate subscription: passed, 4/4.
  • dotnet test --project core/Azure.Mcp.Core/tests/Azure.Mcp.Core.Tests/Azure.Mcp.Core.Tests.csproj -c Release --filter-class Azure.Mcp.Core.Tests.Areas.Server.CommandOperationPlaneTests --filter-class *ConsolidatedToolDiscoveryStrategyTests --filter-class *ToolsListCommandTests: passed, 31/31.
  • dotnet test --project servers/Azure.Mcp.Server/tests/Azure.Mcp.Server.Tests/Azure.Mcp.Server.Tests.csproj -c Release --filter-class *ConsolidatedToolMetadataTests: passed, 8/8.
  • dotnet format --verify-no-changes on the IoT Hub src and test projects: passed.
  • .\eng\common\spelling\Invoke-Cspell.ps1 on all changed files: passed, 0 issues in 57 files.
  • ./eng/scripts/Update-AzCommandsMetadata.ps1: passed, no changes.
  • ./eng/scripts/Process-PackageReadMe.ps1 -Command validate -InputReadMePath servers/Azure.Mcp.Server/README.md: passed.
  • ./eng/scripts/Compile-Changelog.ps1 -ChangelogPath servers/Azure.Mcp.Server/CHANGELOG.md -DryRun: passed.
  • ToolDescriptionEvaluator: passed. Every prompt for the new and modified tools ranks Update README.md #1 of 406 tools with a score of at least 0.586. Command: dotnet run --project eng/tools/ToolDescriptionEvaluator/src -- --area iothub --server-exe <this branch's Release azmcp.exe>, with an Azure OpenAI text-embedding-3-large deployment and the IoT Hub prompts in e2eTestPrompts.md.
Tool Prompt Rank Score Next-best tool (score)
iothub_hub_get Get details for IoT Hub <hub_name> in resource group <resource_group_name> 1 0.797 iotoperations_instance_get (0.558)
iothub_hub_get Show IoT Hub <hub_name> in resource group <resource_group_name> for subscription <subscription_id> 1 0.730 iothub_device_list (0.548)
iothub_hub_get Retrieve IoT Hub <hub_name> metadata from resource group <resource_group_name> 1 0.697 eventhubs_eventhub_consumergroup_get (0.501)
iothub_routing_endpoint-diagnostics Show routing endpoint diagnostics evidence for IoT Hub <hub_name> in resource group <resource_group_name> 1 0.660 iothub_hub_get (0.627)
iothub_routing_endpoint-diagnostics Get routing endpoint diagnostics metrics for IoT Hub <hub_name> from <start_time> through <end_time> 1 0.719 iothub_routing_endpoint-health (0.588)
iothub_routing_endpoint-diagnostics Check whether routing endpoint <endpoint_name> on IoT Hub <hub_name> has a missing target, unavailable metrics, or observed delivery failures in the past six hours 1 0.669 iothub_routing_endpoint-health (0.567)
iothub_routing_endpoint-diagnostics Show which routing metrics returned no data for IoT Hub <hub_name> without assuming the hub is idle or healthy 1 0.586 iothub_routing_endpoint-health (0.531)
iothub_routing_endpoint-health Show routing endpoint health for IoT Hub <hub_name> in resource group <resource_group_name> 1 0.718 iothub_hub_get (0.643)
iothub_routing_endpoint-health Get the current routing endpoint health for endpoint <endpoint_name> on IoT Hub <hub_name> 1 0.726 iothub_routing_endpoint-diagnostics (0.570)

Across all 22 IoT Hub prompts, 22/22 score at least 0.4 and 16/22 rank first. The 6 that don't rank first belong to existing tools (device show, device twin get, query run). A baseline run with upstream's hub get description and without the routing tools gives identical ranks and scores for those 6, so this PR doesn't change them. With the longer description, the hub get prompt scores drop by at most 0.018 and still rank first.

The embedding deployment allows only Microsoft Entra ID auth because key auth is disabled by policy. The evaluator only sends an api-key header, so it ran with an uncommitted local change that sends a bearer token instead. Scoring logic is unchanged.

GitHub issue number?

#2917

Pre-merge Checklist

  • Required for All PRs
    • Read contribution guidelines
    • PR title clearly describes the change
    • Commit history is clean with descriptive messages (cleanup guide)
    • Added comprehensive tests for new/modified functionality
    • Created a changelog entry if the change falls among the following: new feature, bug fix, UI/UX update, breaking change, or updated dependencies. Follow the changelog entry guide
  • For MCP tool changes:
    • One tool per PR: This PR adds or modifies only one MCP tool for faster review cycles
    • Updated servers/Azure.Mcp.Server/README.md and/or servers/Fabric.Mcp.Server/README.md documentation
    • Validate README.md changes running the script ./eng/scripts/Process-PackageReadMe.ps1. See Package README
    • For new or modified tool descriptions (excluding Fabric MCP tools), ran ToolDescriptionEvaluator and obtained a score of 0.4 or more and a top 3 ranking for all related test prompts
    • For tools with new names, including new tools or renamed tools, update consolidated-tools.json
    • For renamed tools, follow the Tool Rename Checklist and tag the PR with the breaking-change label
    • For new tools associated with Azure services or publicly available tools/APIs/products, add URL to documentation in the PR description
  • Extra steps for Azure MCP Server tool changes:
    • Updated command list in servers/Azure.Mcp.Server/docs/azmcp-commands.md
    • Ran ./eng/scripts/Update-AzCommandsMetadata.ps1 to update tool metadata in azmcp-commands.md (required for CI)
    • Updated test prompts in servers/Azure.Mcp.Server/docs/e2eTestPrompts.md
    • 👉 For Community (non-Microsoft team member) PRs:
      • Security review: Reviewed code for security vulnerabilities, malicious code, or suspicious activities before running tests (crypto mining, spam, data exfiltration, etc.)
      • Manual tests run: added comment /azp run mcp - pullrequest - live to run Live Test Pipeline

Invoking Livetests

Copilot submitted PRs are not trustworthy by default. Users with write access to the repo need to validate the contents of this PR before leaving a comment with the text /azp run mcp - pullrequest - live. This will trigger the necessary livetest workflows to complete required validation.

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

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

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

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

It adds two tools despite the one-tool rule, lacks evaluator results, and has unresolved authentication-order and retry-amplification concerns.

4 open findings
What changed in this PR

Adds IoT Hub routing endpoint health and diagnostics capabilities, plus routing endpoint details in hub responses.

Changes:

  • Adds two routing troubleshooting commands and supporting services/models.
  • Adds recorded, unit, infrastructure, and security tests.
  • Updates registration, documentation, consolidated mappings, and changelog.
File Description
tools/​Azure.Mcp.Tools.IoTHub/​tests/​test-resources.bicep Adds routing test resources.
tools/​Azure.Mcp.Tools.IoTHub/​tests/​Azure.Mcp.Tools.IoTHub.Tests/​Services/​SequenceHttpMessageHandler.cs Adds sequential HTTP test handler.
tools/​Azure.Mcp.Tools.IoTHub/​tests/​Azure.Mcp.Tools.IoTHub.Tests/​Services/​RoutingDiagnosticsHttpMessageHandler.cs Adds diagnostics HTTP test handler.
tools/​Azure.Mcp.Tools.IoTHub/​tests/​Azure.Mcp.Tools.IoTHub.Tests/​Services/​IoTHubRoutingServiceTests.cs Tests routing service fundamentals.
tools/​Azure.Mcp.Tools.IoTHub/​tests/​Azure.Mcp.Tools.IoTHub.Tests/​Services/​IoTHubRoutingServiceDiagnosticsTests.cs Tests diagnostics orchestration.
tools/​Azure.Mcp.Tools.IoTHub/​tests/​Azure.Mcp.Tools.IoTHub.Tests/​Routing/​RoutingMetricEvidenceBuilderTests.cs Tests metric evidence construction.
tools/​Azure.Mcp.Tools.IoTHub/​tests/​Azure.Mcp.Tools.IoTHub.Tests/​Routing/​RoutingEndpointMapperTests.cs Tests endpoint mapping.
tools/​Azure.Mcp.Tools.IoTHub/​tests/​Azure.Mcp.Tools.IoTHub.Tests/​Routing/​RoutingDiagnosticsWindowTests.cs Tests time-window validation.
tools/​Azure.Mcp.Tools.IoTHub/​tests/​Azure.Mcp.Tools.IoTHub.Tests/​Routing/​IoTHubRoutingEndpointHealthCommandTests.cs Tests health command behavior.
tools/​Azure.Mcp.Tools.IoTHub/​tests/​Azure.Mcp.Tools.IoTHub.Tests/​Routing/​IoTHubRoutingEndpointDiagnosticsCommandTests.cs Tests diagnostics command behavior.
tools/​Azure.Mcp.Tools.IoTHub/​tests/​Azure.Mcp.Tools.IoTHub.Tests/​IoTHubCommandTests.cs Adds recorded routing tests.
tools/​Azure.Mcp.Tools.IoTHub/​tests/​Azure.Mcp.Tools.IoTHub.Tests/​assets.json Updates recording assets tag.
tools/​Azure.Mcp.Tools.IoTHub/​src/​Services/​RoutingTargetDescriptor.cs Defines target metadata.
tools/​Azure.Mcp.Tools.IoTHub/​src/​Services/​ResolvedTarget.cs Models resolved targets.
tools/​Azure.Mcp.Tools.IoTHub/​src/​Services/​ObservationWindow.cs Formats metric windows.
tools/​Azure.Mcp.Tools.IoTHub/​src/​Services/​IoTHubService.cs Adds routing endpoints to hub output.
tools/​Azure.Mcp.Tools.IoTHub/​src/​Services/​IoTHubRoutingService.cs Implements routing evidence queries.
tools/​Azure.Mcp.Tools.IoTHub/​src/​Services/​IIoTHubRoutingService.cs Defines routing service contract.
tools/​Azure.Mcp.Tools.IoTHub/​src/​Services/​ExistenceResult.cs Models target existence checks.
tools/​Azure.Mcp.Tools.IoTHub/​src/​Services/​ArmGetResult.cs Models raw ARM responses.
tools/​Azure.Mcp.Tools.IoTHub/​src/​Routing/​RoutingMetricEvidenceBuilder.cs Builds metric evidence output.
tools/​Azure.Mcp.Tools.IoTHub/​src/​Routing/​RoutingEndpointMapper.cs Maps configured endpoints.
tools/​Azure.Mcp.Tools.IoTHub/​src/​Routing/​RoutingDiagnosticsWindow.cs Validates diagnostics windows.
tools/​Azure.Mcp.Tools.IoTHub/​src/​Routing/​MetricFieldNameBuilder.cs Generates metric field names.
tools/​Azure.Mcp.Tools.IoTHub/​src/​Options/​Routing/​IoTHubRoutingEndpointHealthOptions.cs Defines health options.
tools/​Azure.Mcp.Tools.IoTHub/​src/​Options/​Routing/​IoTHubRoutingEndpointDiagnosticsOptions.cs Defines diagnostics options.
tools/​Azure.Mcp.Tools.IoTHub/​src/​Models/​RoutingTargetInfo.cs Models resolved target details.
tools/​Azure.Mcp.Tools.IoTHub/​src/​Models/​RoutingTargetEmitted.cs Models target metrics.
tools/​Azure.Mcp.Tools.IoTHub/​src/​Models/​RoutingProperties.cs Models routing configuration.
tools/​Azure.Mcp.Tools.IoTHub/​src/​Models/​RoutingObservationWindow.cs Models returned time windows.
tools/​Azure.Mcp.Tools.IoTHub/​src/​Models/​RoutingMetricEvidence.cs Models metric evidence.
tools/​Azure.Mcp.Tools.IoTHub/​src/​Models/​RoutingHubEmitted.cs Models hub metrics.
tools/​Azure.Mcp.Tools.IoTHub/​src/​Models/​RoutingEndpoints.cs Models endpoint collections.
tools/​Azure.Mcp.Tools.IoTHub/​src/​Models/​RoutingEndpointProperties.cs Models non-secret endpoint properties.
tools/​Azure.Mcp.Tools.IoTHub/​src/​Models/​RoutingEndpointHealthSnapshot.cs Models health snapshots.
tools/​Azure.Mcp.Tools.IoTHub/​src/​Models/​RoutingEndpointHealthResult.cs Wraps health results.
tools/​Azure.Mcp.Tools.IoTHub/​src/​Models/​RoutingEndpointDiagnostics.cs Wraps diagnostics results.
tools/​Azure.Mcp.Tools.IoTHub/​src/​Models/​RoutingEndpointDiagnostic.cs Models endpoint diagnostics.
tools/​Azure.Mcp.Tools.IoTHub/​src/​Models/​RoutingEndpointDetails.cs Models endpoint details.
tools/​Azure.Mcp.Tools.IoTHub/​src/​Models/​RoutingDiagnosticError.cs Models partial-evidence errors.
tools/​Azure.Mcp.Tools.IoTHub/​src/​Models/​IoTHubProperties.cs Adds routing properties.
tools/​Azure.Mcp.Tools.IoTHub/​src/​Models/​IoTHubDescription.cs Adds routing endpoints to hub details.
tools/​Azure.Mcp.Tools.IoTHub/​src/​Models/​EndpointHealthDataListResult.cs Models paged health data.
tools/​Azure.Mcp.Tools.IoTHub/​src/​Models/​EndpointHealthData.cs Models REST health records.
tools/​Azure.Mcp.Tools.IoTHub/​src/​IoTHubSetup.cs Registers routing service and commands.
tools/​Azure.Mcp.Tools.IoTHub/​src/​Commands/​Routing/​IoTHubRoutingEndpointHealthCommand.cs Implements health command.
tools/​Azure.Mcp.Tools.IoTHub/​src/​Commands/​Routing/​IoTHubRoutingEndpointDiagnosticsCommand.cs Implements diagnostics command.
tools/​Azure.Mcp.Tools.IoTHub/​src/​Commands/​IoTHubValidation.cs Centralizes hub-name validation.
tools/​Azure.Mcp.Tools.IoTHub/​src/​Commands/​IoTHubJsonContext.cs Registers routing serialization types.
tools/​Azure.Mcp.Tools.IoTHub/​src/​Commands/​IoTHub/​IoTHubGetCommand.cs Documents expanded hub output.
tools/​Azure.Mcp.Tools.IoTHub/​src/​Azure.Mcp.Tools.IoTHub.csproj Adds Monitor SDK dependency.
tools/​Azure.Mcp.Tools.IoTHub/​cspell.yaml Adds routing terminology.
servers/​Azure.Mcp.Server/​src/​Resources/​consolidated-tools.json Adds consolidated tool mappings.
servers/​Azure.Mcp.Server/​README.md Documents routing scenarios.
servers/​Azure.Mcp.Server/​docs/​e2eTestPrompts.md Adds routing prompts.
servers/​Azure.Mcp.Server/​docs/​azmcp-commands.md Documents routing commands.
servers/​Azure.Mcp.Server/​changelog-entries/​vineetkalki-iothub-routing-tools.yaml Records new features.

🧠 Review effort: Balanced


💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Provide a current endpoint-health snapshot and historical routing evidence, including downstream resource existence and per-metric availability without inferring overall hub health.

Use a dedicated routing service with cloud-aware ARM validation, SDK-default retries, bounded operations, and cancellation handling. Include command documentation, registration, unit tests, recorded tests, and routing test infrastructure.

Co-authored-by: Copilot <[email protected]>
@vineetkalki
vineetkalki force-pushed the iothub/routing-endpoint-health branch from 02f943c to 25ca8f8 Compare October 8, 2026 20:58
@vineetkalki
vineetkalki marked this pull request as draft October 8, 2026 21:00
Only retry batched target metrics individually when Azure Monitor rejects
the batch with 400, the incompatible-metric case. Throttling and server
errors now fail the batch after SDK retries instead of fanning out into
per-metric requests that consume the operation budget.

Validate each ARM request URI, including nextLink continuations, before
resolving the tenant or credential so untrusted destinations fail before
any authentication work.

Co-authored-by: Copilot <[email protected]>
@vineetkalki
vineetkalki marked this pull request as ready for review October 12, 2026 17:11
vineetkalki and others added 2 commits October 12, 2026 14:08
microsoft#3884 removed the static EndpointValidator overload that took an executing tool namespace, so the routing service no longer compiles against main (CS1739). Validate ARM request and nextLink URIs through IAzureService.ValidateAzureServiceEndpoint, as IoTHubDeviceService now does. Tests use AzureServiceTestHelpers so endpoint validation stays real and shared ARM clients route through the test handler.

Co-authored-by: Copilot <[email protected]>
@vineetkalki

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree company="Microsoft"

vineetkalki and others added 2 commits October 14, 2026 12:16
Key-based endpoints have no endpointUri, and IoT Hub endpoint ids are opaque GUIDs rather than ARM resource IDs. The mapper fell back to the entity path or container name as the namespace or account name, so diagnostics checked a resource that does not exist and reported an existing target as notFound. Derive the target name only from the endpoint URI host so these endpoints report an unresolved target, and use opaque ids in the mapper fixture to match service responses.

Co-authored-by: Copilot <[email protected]>
@conniey

Copy link
Copy Markdown
Member

/azp run MCP - pullrequest - live

@azure-pipelines

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

@vineetkalki

Copy link
Copy Markdown
Contributor Author

/azp run mcp - pullrequest - live

@azure-pipelines

Copy link
Copy Markdown
Commenter does not have sufficient privileges for PR 3894 in repo microsoft/mcp

The live pipeline failed in test-resources-post.ps1 because the azure-iot CLI extension it used cannot be installed on network-isolated agents. Seed the test devices through the IoT Hub registry REST API with Microsoft Entra ID instead, and grant the test principal IoT Hub Data Contributor.

Also add the identity-based Service Bus routing endpoints in the post script rather than the template. IoT Hub validates those endpoints when they are created and rejects them (IH400117) until the routing identity's Service Bus Data Sender assignment takes effect. ARM cannot wait for that, so the post script retries until it does.

Co-authored-by: Copilot <[email protected]>
@vineetkalki

Copy link
Copy Markdown
Contributor Author

The live run failed before any test ran. The IoT Hub test-resources-post.ps1 created its test devices with az iot commands, which need the azure-iot CLI extension, and the extension can't be installed on the network-isolated agent (Pip failed with status code 1).

Fixed in ca2e181:

  • The post script now creates the test devices through the IoT Hub registry REST API with Microsoft Entra ID, and the test principal gets IoT Hub Data Contributor instead of Data Reader.
  • Validating that turned up a second problem: a fresh deployment of the template can fail with IH400117. IoT Hub checks identity-based routing endpoints when they're created, before the routing identity's Service Bus Data Sender role takes effect. The post script now adds those endpoints and retries until the role is effective.

I validated this against a fresh deployment in a separate subscription. The template deployed, the post script configured routing and created the 3 devices, and all 4 IoT Hub live tests passed in Live mode.

Could someone with write access re-run /azp run mcp - pullrequest - live?

@jichang1

Copy link
Copy Markdown
Contributor

/azp run MCP - pullrequest - live

@azure-pipelines

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

@KarishmaGhiya

Copy link
Copy Markdown
Member

There are merge conflicts that need to be addressed

vineetkalki and others added 2 commits October 23, 2026 08:20
Resolve the conflict in tools/Azure.Mcp.Tools.IoTHub/tests/test-resources-post.ps1 by keeping this branch's version. microsoft#3742 hardened the azure-iot CLI extension install, but this branch's post script no longer uses the extension; it creates the test devices through the IoT Hub registry REST API, which passed in the live pipeline in both stdio and HTTP modes.

Co-authored-by: Copilot <[email protected]>
Hub and resource group names were interpolated into ARM resource IDs. ResourceIdentifier accepts traversal segments, and URI normalization then sent the request elsewhere: rg1/../rg2 and rg1\..\rg2 read the hub from resource group rg2, and .. escaped to the subscription scope.

Reject names outside the Azure naming rules before any credential or network work. The check runs in the shared routing service path used by both routing commands, and in IoTHubService.GetIoTHub, which serves hub get and, through the hostname resolver, the device and query tools. Resource group names follow the documented rule: 1-90 letters or digits (Char.IsLetterOrDigit), underscores, hyphens, periods, or parentheses, not ending with a period. Routing targets built from the hub's endpoint configuration are reported as unresolved unless every name is a single path segment.

Co-authored-by: Copilot <[email protected]>
@vineetkalki

Copy link
Copy Markdown
Contributor Author

KarishmaGhiya Merged main into the branch in 2ef99ef, and the PR is mergeable again.

The only conflict was tools/Azure.Mcp.Tools.IoTHub/tests/test-resources-post.ps1. #3742 hardened the azure-iot CLI extension install there, but this branch's post script no longer uses the extension: it creates the test devices through the IoT Hub registry REST API. I kept this branch's version, which passed the live pipeline in both stdio and HTTP modes (build 6963792).

After the merge and the resource-name fix in 584662b, mcp - pullrequest passed (build 6994390). The post script and recordings didn't change, but feel free to re-run /azp run mcp - pullrequest - live if you'd like a live run on the new head.

@jichang1

Copy link
Copy Markdown
Contributor

/azp run MCP - pullrequest - live

@azure-pipelines

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

@jichang1
jichang1 self-requested a review October 27, 2026 18:27
@jichang1 jichang1 self-assigned this Oct 27, 2026

@jichang1 jichang1 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.

approved

@jichang1
jichang1 merged commit b10fb6b into microsoft:main Oct 28, 2026
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants