Class AssetMonitor
- Namespace
- Azure.Iot.Operations.Services.Assets
- Assembly
- Azure.Iot.Operations.Services.dll
This class allows for getting and monitor changes to assets and asset endpoint profiles.
public class AssetMonitor : IAssetMonitor
- Inheritance
-
AssetMonitor
- Implements
- Inherited Members
Remarks
This class is only applicable for connector applications that have been deployed by the Akri operator.
Constructors
AssetMonitor()
public AssetMonitor()
Methods
GetAssetAsync(string, CancellationToken)
Get the asset with the provided Id.
public Task<Asset?> GetAssetAsync(string assetName, CancellationToken cancellationToken = default)
Parameters
assetName
stringThe Id of the asset to retrieve.
cancellationToken
CancellationTokenCancellation token.
Returns
GetAssetEndpointProfileAsync(CancellationToken)
Get the asset endpoint profile of the asset with the provided Id.
public Task<AssetEndpointProfile?> GetAssetEndpointProfileAsync(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationTokenCancellation token.
Returns
- Task<AssetEndpointProfile>
The requested asset endpoint profile. This value may be null if no asset endpoint profile is configured yet.
GetAssetNamesAsync(CancellationToken)
Returns the complete list of assets deployed by the operator to this pod.
public Task<List<string>> GetAssetNamesAsync(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationTokenCancellation token.
Returns
ObserveAssetEndpointProfile(TimeSpan?, CancellationToken)
Start receiving notifications on AssetEndpointProfileChanged when the asset endpoint profile changes for the asset with the provided Id.
public void ObserveAssetEndpointProfile(TimeSpan? pollingInterval = null, CancellationToken cancellationToken = default)
Parameters
pollingInterval
TimeSpan?How frequently to check for changes to the asset endpoint profile.
cancellationToken
CancellationTokenCancellation token.
ObserveAssets(TimeSpan?, CancellationToken)
Start receiving notifications on AssetChanged when any asset changes.
public void ObserveAssets(TimeSpan? pollingInterval = null, CancellationToken cancellationToken = default)
Parameters
pollingInterval
TimeSpan?How frequently to check for changes to the asset.
cancellationToken
CancellationTokenCancellation token.
UnobserveAssetEndpointProfile(CancellationToken)
Stop receiving notifications on AssetEndpointProfileChanged when the asset endpoint profile changes for the asset with the provided Id.
public void UnobserveAssetEndpointProfile(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationTokenCancellation token.
UnobserveAssets(CancellationToken)
Stop receiving notifications on AssetChanged when an asset changes.
public void UnobserveAssets(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationTokenCancellation token.
Events
AssetChanged
The callback that executes when an asset has changed once you start observing an asset with ObserveAssets(TimeSpan?, CancellationToken).
public event EventHandler<AssetChangedEventArgs>? AssetChanged
Event Type
AssetEndpointProfileChanged
The callback that executes when the asset endpoint profile has changed once you start observing it with ObserveAssetEndpointProfile(TimeSpan?, CancellationToken).
public event EventHandler<AssetEndpointProfileChangedEventArgs>? AssetEndpointProfileChanged