Table of Contents

Interface IManagementActionHandlerFactory

Namespace
Azure.Iot.Operations.Connector
Assembly
Azure.Iot.Operations.Connector.dll

Factory for creating IManagementActionHandler instances, one per management action defined on an asset. Called by ConnectorWorker when an asset becomes available.

public interface IManagementActionHandlerFactory

Remarks

Follows the same factory pattern as IDatasetSamplerFactory: per-action context is passed at creation time so handler instances can capture device connection details, credentials, and action configuration.

The asset / device / group / action names are intentionally not passed here. They are surfaced on ManagementActionInvokedEventArgs for each invocation so the handler can read/call/write the correct asset on the correct device without needing to capture them at construction time.

Methods

CreateHandler(Device, string, Asset, AssetManagementGroupAction, EndpointCredentials?)

Create a handler for the specified management action.

IManagementActionHandler CreateHandler(Device device, string inboundEndpointName, Asset asset, AssetManagementGroupAction action, EndpointCredentials? endpointCredentials)

Parameters

device Device

The device model that owns the asset.

inboundEndpointName string

The name of the inbound endpoint used to reach the device.

asset Asset

The asset model that declares this action.

action AssetManagementGroupAction

The management action definition (carries action type, target URI, timeout, etc.).

endpointCredentials EndpointCredentials

Credentials for connecting to the device endpoint, if available.

Returns

IManagementActionHandler

A handler that will receive invocations for this action. The base connector will dispose it when the action is deleted or the asset becomes unavailable.

SupportsAction(AssetManagementGroupAction)

Indicates whether this factory can produce a handler for the supplied management action.

bool SupportsAction(AssetManagementGroupAction action)

Parameters

action AssetManagementGroupAction

The action definition declared on the asset.

Returns

bool

true if a handler can be created for action; otherwise false.

Remarks

Called by the orchestrator before ValidateConfigurationAsync(Device, string, Asset, AssetManagementGroupAction, CancellationToken) and CreateHandler(Device, string, Asset, AssetManagementGroupAction, EndpointCredentials?). If false is returned, the orchestrator reports an UnsupportedAction config error for the action and does not create a handler. Implementations should perform a lightweight check (for example, matching on ActionType) and must not have side effects.

ValidateConfigurationAsync(Device, string, Asset, AssetManagementGroupAction, CancellationToken)

Perform connector-specific validation of an action's definition. Called by the base worker at startup and on every definition-change notification, before any invocations are dispatched. Return null if the definition is valid from the connector's perspective.

ValueTask<ConfigError?> ValidateConfigurationAsync(Device device, string inboundEndpointName, Asset asset, AssetManagementGroupAction action, CancellationToken cancellationToken)

Parameters

device Device
inboundEndpointName string
asset Asset
action AssetManagementGroupAction
cancellationToken CancellationToken

Returns

ValueTask<ConfigError>

Remarks

The SDK performs structural validation (well-formed topic, required fields, etc.) and surfaces those errors via ManagementActionUpdated.Error. This hook lets the connector application add semantic validation that only it can perform — for example, that action.TargetUri uses a scheme this connector supports, that action.ActionConfiguration deserializes into the connector's expected shape, or that referenced asset attributes exist.

The base worker merges this result with the SDK-supplied ConfigError before reporting to ADR; if either is non-null the action is reported Unavailable.

The default implementation returns null (no connector-specific validation). Override to opt in.

Note: unlike most Validate* methods in this SDK (which throw on invalid input), this hook returns the error. Validation results are reported back to ADR as ConfigErrors, so returning one keeps the shape symmetric with the SDK-supplied error the worker merges it with, and avoids forcing the notification loop to catch-and-unwrap exceptions on every definition change.