Class ResourceId
- Namespace
- Azure.Iot.Operations.Services.EdgeRegistry
- Assembly
- Azure.Iot.Operations.Services.dll
Derives Resource identifiers that satisfy the cloud naming rules from arbitrary identifiers.
public static class ResourceId
- Inheritance
-
ResourceId
- Inherited Members
Fields
OriginalIdLabelKey
The label key under which the original, pre-derivation identifier is recorded by Derive(string, IReadOnlyList<Label>?).
public const string OriginalIdLabelKey = "originalid"
Field Value
Remarks
The label belongs on the Resource, and a lookup filters on this key with the original identifier as the value, not the derived Resource identifier.
Methods
Derive(string, IReadOnlyList<Label>?)
Derives a Resource identifier from an arbitrary identifier, recording the original in
resourceLabels under OriginalIdLabelKey and returning both.
public static (string ResourceId, IReadOnlyList<Label> ResourceLabels) Derive(string originalId, IReadOnlyList<Label>? resourceLabels = null)
Parameters
originalIdstringThe identifier to derive a Resource identifier from.
resourceLabelsIReadOnlyList<Label>The Resource labels to record the original identifier in. Left unmodified; the returned list is a copy.
Returns
- (string ResourceId, IReadOnlyList<Label> ResourceLabels)
The derived Resource identifier and the labels recording
originalId.
Remarks
originalId is used as the Resource identifier unchanged when it already
satisfies the cloud naming rules: 3 to 64 characters drawn from [a-z0-9-], beginning and
ending with an alphanumeric. Every other identifier is hashed, yielding the lowercase hex
SHA-256 of originalId. A hashed identifier is always 64 characters drawn from
[0-9a-f], which satisfies both the xRegistry identifier rules and the stricter cloud rules.
An identical OriginalIdLabelKey entry is never duplicated, while entries recording a different identifier are left in place.
Exceptions
- ArgumentNullException
originalIdis null.- ArgumentException
originalIdis empty.