다음을 통해 공유


데이터 흐름 만들기

Important

Azure Arc에서 사용하도록 설정된 Azure IoT Operations 미리 보기는 현재 미리 보기로 제공됩니다. 프로덕션 환경에서는 이 미리 보기 소프트웨어를 사용하면 안 됩니다.

일반적으로 사용 가능한 릴리스를 사용할 수 있게 되면 새 Azure IoT Operations 설치를 배포해야 합니다. 미리 보기 설치를 업그레이드할 수 없습니다.

베타, 미리 보기로 제공되거나 아직 일반 공급으로 릴리스되지 않은 Azure 기능에 적용되는 약관은 Microsoft Azure 미리 보기에 대한 추가 사용 약관을 참조하세요.

데이터 흐름은 선택적 변환을 통해 데이터가 원본에서 대상까지 이동하는 경로입니다. Azure IoT Operations 포털을 사용하거나 데이터 흐름 사용자 지정 리소스를 만들어 데이터 흐름을 구성할 수 있습니다. 데이터 흐름을 만들기 전에 데이터 원본 및 대상에 대한 데이터 흐름 엔드포인트를 구성해야 합니다.

다음 예제는 MQTT 원본 엔드포인트, 변환 및 Kafka 대상 엔드포인트를 사용하는 데이터 흐름 구성입니다.

apiVersion: connectivity.iotoperations.azure.com/v1beta1
kind: Dataflow
metadata:
  name: my-dataflow
spec:
  profileRef: my-dataflow-profile
  mode: enabled
  operations:
    - operationType: source
      name: my-source
      sourceSettings:
        endpointRef: mq
        dataSources:
          - thermostats/+/telemetry/temperature/#
          - humidifiers/+/telemetry/humidity/#
        serializationFormat: json
    - operationType: builtInTransformation
      name: my-transformation
      builtInTransformationSettings:
        filter:
          - inputs:
              - 'temperature.Value'
              - '"Tag 10".Value'
            expression: "$1*$2<100000"
        map:
          - inputs:
              - '*'
            output: '*'
          - inputs:
              - temperature.Value
            output: TemperatureF
            expression: cToF($1)
          - inputs:
              - '"Tag 10".Value'
            output: 'Tag 10'
        serializationFormat: json
    - operationType: destination
      name: my-destination
      destinationSettings:
        endpointRef: kafka
        dataDestination: factory
속성 설명
profileRef 데이터 흐름 프로필대한 참조입니다.
mode 데이터 흐름 모드: enabled 또는 disabled.
operations[] 데이터 흐름에 의해 수행되는 작업입니다.
operationType 작업 유형: source, destination또는 builtInTransformation.

다음 섹션을 검토하여 데이터 흐름의 작업 유형을 구성하는 방법을 알아봅니다.

원본 구성

데이터 흐름에 대한 원본을 구성하려면 엔드포인트 참조와 데이터 원본을 지정합니다. 엔드포인트에 대한 데이터 원본 목록을 지정할 수 있습니다. 예를 들어, MQTT나 Kafka 항목입니다. 다음 정의는 원본 엔드포인트 및 데이터 원본을 사용하는 데이터 흐름 구성의 예입니다.

apiVersion: connectivity.iotoperations.azure.com/v1beta1
kind: Dataflow
metadata:
  name: mq-to-kafka
  namespace: azure-iot-operations
spec:
  profileRef: example-dataflow
  operations:
    - operationType: source
      sourceSettings:
        endpointRef: mq-source
        dataSources:
        - azure-iot-operations/data/thermostat
속성 설명
operationType source
sourceSettings 작업에 대한 설정입니다 source .
sourceSettings.endpointRef 엔드포인트에 대한 source 참조입니다.
sourceSettings.dataSources 작업에 대한 데이터 원본입니다 source . 와일드카드(#+)가 지원됩니다.

변환 구성

변환 작업은 데이터를 대상으로 보내기 전에 원본에서 데이터를 변환할 수 있는 위치입니다. 변환은 선택 사항입니다. 데이터를 변경할 필요가 없으면 데이터 흐름 구성에 변환 작업을 포함하지 마세요. 여러 변환은 구성에 지정된 순서에 관계없이 여러 변환이 단계별로 연결됩니다.

spec:
  operations:
  - operationType: builtInTransformation
    name: transform1
    builtInTransformationSettings:
      datasets:
        # ...
      filter:
        # ...
      map:
        # ...
속성 설명
operationType builtInTransformation
name 변환의 이름입니다.
builtInTransformationSettings 작업에 대한 설정입니다 builtInTransformation .
builtInTransformationSettings.datasets 일치시킬 데이터 세트 및 조건이 지정된 경우 원본 데이터에 다른 데이터를 추가합니다.
builtInTransformationSettings.filter 조건에 따라 데이터를 필터링합니다.
builtInTransformationSettings.map 선택적 변환을 사용하여 한 필드에서 다른 필드로 데이터를 이동합니다.

보강: 참조 데이터 추가

데이터를 보강하려면 Azure IoT Operations DSS(분산 상태 저장소)에서 참조 데이터 세트를 사용할 수 있습니다. 데이터 세트는 조건에 따라 원본 데이터에 추가 데이터를 추가하는 데 사용됩니다. 조건은 데이터 세트의 필드와 일치하는 원본 데이터의 필드로 지정됩니다.

속성 설명
builtInTransformationSettings.datasets.key 보강에 사용되는 데이터 세트(DSS의 키).
builtInTransformationSettings.datasets.expression 보강 작업의 조건입니다.

분산 상태 저장소의 키 이름은 데이터 흐름 구성의 데이터 세트에 해당합니다.

예를 들어, 원본 데이터의 deviceId 필드를 사용하여 데이터 세트의 asset 필드와 일치시킬 수 있습니다.

spec:
  operations:
  - operationType: builtInTransformation
    name: transform1
    builtInTransformationSettings:
      datasets:
      - key: assetDataset
        inputs:
          - $source.deviceId # ------------- $1
          - $context(assetDataset).asset # - $2
        expression: $1 == $2

데이터 세트에 asset 필드가 있는 레코드가 있는 경우 다음과 같습니다.

{
  "asset": "thermostat1",
  "location": "room1",
  "manufacturer": "Contoso"
}

필드가 일치하는 원본의 deviceId 데이터에는 사용 가능한 filter 필드와 manufacturer map 단계가 location 있습니다.thermostat1

DSS 집합 도구 샘플을 사용하여 샘플 데이터를 DSS에 로드할 수 있습니다.

조건 구문에 대한 자세한 내용은 데이터 흐름을 사용하여 데이터 보강 및 데이터 흐름을 사용하여 데이터 변환을 참조하세요.

필터: 조건에 따라 데이터 필터링

조건에 따라 데이터를 필터링하려면 filter 단계를 사용할 수 있습니다. 조건은 값과 일치하는 원본 데이터의 필드로 지정됩니다.

속성 설명
builtInTransformationSettings.filter.inputs[] 필터 조건을 평가하는 입력입니다.
builtInTransformationSettings.filter.expression 필터 평가 조건입니다.

예를 들어, 원본 데이터의 temperature 필드를 사용하여 데이터를 필터링할 수 있습니다.

spec:
  operations:
  - operationType: builtInTransformation
    name: transform1
    builtInTransformationSettings:
      filter:
        - inputs:
          - temperature ? $last # - $1
          expression: "$1 > 20"

temperature 필드가 20보다 큰 경우, 데이터는 다음 단계로 전달됩니다. temperature 필드가 20보다 작거나 같으면 데이터가 필터링됩니다.

맵: 한 필드에서 다른 필드로 데이터 이동

선택적 변환을 통해 데이터를 다른 필드에 매핑하려면 map 연산을 사용할 수 있습니다. 변환은 원본 데이터의 필드를 사용하는 수식으로 지정됩니다.

속성 설명
builtInTransformationSettings.map[].inputs[] 맵 작업을 위한 입력
builtInTransformationSettings.map[].output 맵 작업을 위한 출력 필드
builtInTransformationSettings.map[].expression 맵 연산을 위한 변환 수식

예를 들어, 원본 데이터의 temperature 필드를 사용하여 온도를 섭씨로 변환하고 temperatureCelsius 필드에 저장할 수 있습니다. 또한 컨텍스트화 데이터 세트의 location 필드를 사용하여 원본 데이터를 보강할 수도 있습니다.

spec:
  operations:
  - operationType: builtInTransformation
    name: transform1
    builtInTransformationSettings:
      map:
        - inputs:
          - temperature # - $1
          output: temperatureCelsius
          expression: "($1 - 32) * 5/9"
        - inputs:
          - $context(assetDataset).location  
          output: location

자세한 내용은 데이터 흐름을 사용하여 데이터 매핑 및 데이터 흐름을 사용하여 데이터 변환을 참조하세요.

대상 구성

데이터 흐름에 대한 대상을 구성하려면 엔드포인트와 대상의 경로(항목 또는 테이블)를 지정해야 합니다.

속성 설명
destinationSettings.endpointRef 엔드포인트에 대한 destination 참조
destinationSettings.dataDestination 데이터의 대상

대상 엔드포인트 참조 구성

대상에 대한 엔드포인트를 구성하려면 ID 및 엔드포인트 참조를 지정해야 합니다.

spec:
  operations:
  - operationType: destination
    name: destination1
    destinationSettings:
      endpointRef: eventgrid

대상 경로 구성

엔드포인트가 있으면 대상에 대한 경로를 구성할 수 있습니다. 대상이 MQTT 또는 Kafka 엔드포인트인 경우 경로를 사용하여 토픽을 지정합니다.

- operationType: destination
  destinationSettings:
    endpointRef: eventgrid
    dataDestination: factory

Microsoft Fabric과 같은 스토리지 엔드포인트의 경우 경로를 사용하여 테이블 이름을 지정합니다.

- operationType: destination
  destinationSettings:
    endpointRef: adls
    dataDestination: telemetryTable