다음을 통해 공유


데이터 흐름 그래프에 대한 WASM(WebAssembly) 그래프 정의 구성(미리 보기)

중요합니다

데이터 흐름 그래프에 대한 WASM(WebAssembly) 그래프 정의는 미리 보기로 제공됩니다. 이 기능에는 제한 사항이 있으며 프로덕션 워크로드에는 적용되지 않습니다.

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

그래프 정의는 모듈이 처리 워크플로에 연결하는 방법을 정의하기 때문에 WASM 개발의 핵심입니다. 그래프 정의와 데이터 흐름 그래프 간의 관계를 이해하면 효과적으로 개발할 수 있습니다.

이 문서에서는 YAML 그래프 정의를 만들고 구성하는 데 중점을 둡니다. WASM 데이터 흐름 그래프를 배포하고 테스트하는 방법에 대한 자세한 내용은 데이터 흐름 그래프와 함께 WebAssembly 사용을 참조하세요.

중요합니다

데이터 흐름 그래프는 현재 MQTT, Kafka 및 OpenTelemetry 엔드포인트만 지원합니다. Data Lake, Microsoft Fabric OneLake, Azure Data Explorer 및 로컬 스토리지와 같은 다른 엔드포인트 형식은 지원되지 않습니다. 자세한 내용은 알려진 문제참조하세요.

그래프 정의 구조

그래프 정의는 구조의 유효성을 검사하고 호환성을 보장하는 공식 JSON 스키마 를 따릅니다. 구성에는 다음이 포함됩니다.

  • API 및 호스트 라이브러리 버전 호환성에 대한 모듈 요구 사항
  • 런타임 매개 변수 및 연산자 사용자 지정을 위한 모듈 구성
  • 워크플로에서 처리 노드를 정의하는 작업
  • 작업 간의 데이터 흐름 라우팅을 지정하는 연결
  • 선택적 데이터 유효성 검사를 위한 스키마

기본 그래프 구조

metadata:
  $schema: "https://www.schemastore.org/aio-wasm-graph-config-1.0.0.json"
  name: "Simple graph"
  description: "A simple graph with a source, a map module, and a sink"
  version: "1.0.0"
  vendor: "Microsoft"

moduleRequirements:
  apiVersion: "1.1.0"
  runtimeVersion: "1.1.0"

operations:
  - operationType: "source"
    name: "data-source"
  - operationType: "map"
    name: "my-operator/map"
    module: "my-operator:1.0.0"
  - operationType: "sink"
    name: "data-sink"

connections:
  - from: { name: "data-source" }
    to: { name: "my-operator/map" }
  - from: { name: "my-operator/map" }
    to: { name: "data-sink" }

버전 호환성

이 섹션에서는 moduleRequirements 의미 체계 버전 관리를 사용하여 호환성을 보장합니다.

moduleRequirements:
  apiVersion: "1.1.0"          # WASI API version for interface compatibility
  runtimeVersion: "1.1.0"     # Runtime version providing runtime support
  features:                    # Optional features required by modules
    - name: "wasi-nn"

팁 (조언)

대역 내 ONNX 추론을 wasi-nn 기능으로 설정하는 방법에 대한 지침은 WebAssembly 데이터 흐름 그래프에서 ONNX 추론 실행을 참조하세요.

예제 1: 단순 그래프 정의

간단한 그래프 정의는 온도 데이터를 화씨에서 섭씨로 변환하는 기본 3단계 파이프라인을 보여 줍니다.

metadata:
  name: "Simple graph"
  description: "A graph that transforms temperature from Fahrenheit to Celsius"
  version: "1.0.0"
  $schema: "https://www.schemastore.org/aio-wasm-graph-config-1.0.0.json"
  vendor: "Microsoft"

moduleRequirements:
  apiVersion: "1.1.0"
  runtimeVersion: "1.1.0"

moduleConfigurations:
  - name: module-temperature/map
    parameters:
      key1:
        name: key2
        description: key2
operations:
  - operationType: "source"
    name: "source"

  - operationType: "map"
    name: "module-temperature/map"
    module: "temperature:1.0.0"

  - operationType: "sink"
    name: "sink"

connections:
  - from:
      name: "source"
    to:
      name: "module-temperature/map"

  - from:
      name: "module-temperature/map"
    to:
      name: "sink"

이 예제에 대한 단계별 배포 지침 및 테스트 지침은 예제 1: 하나의 WASM 모듈이 있는 기본 배포를 참조하세요.

간단한 그래프의 작동 방식

이 그래프는 간단한 데이터 처리 파이프라인을 만듭니다.

  1. 원본 작업: 데이터 흐름의 원본 엔드포인트에서 온도 데이터를 받습니다.
  2. 지도 작업: 온도 WASM 모듈을 사용하여 데이터 처리(temperature:1.0.0)
  3. 싱크 작업: 변환된 데이터를 데이터 흐름의 대상 엔드포인트로 보냅니다.

온도 모듈은 표준 수식을 (F - 32) × 5/9 = C사용하여 화씨에서 섭씨로 변환합니다.

입력 형식:

{"temperature": {"value": 100.0, "unit": "F"}}

출력 형식:

{"temperature": {"value": 37.8, "unit": "C"}}

예제 2: 복합 그래프 정의

복잡한 그래프 정의는 고급 분석을 사용하여 온도, 습도 및 이미지 데이터를 처리하는 정교한 다중 센서 처리 워크플로를 보여 줍니다.

metadata:
  name: "Complex graph"
  description: "A graph that processes temperature and humidity data from sensors, along with snapshot data. The graph performs filtering, accumulation, and enrichment operations before sending the processed data to the sink."
  version: "1.0.0"
  $schema: "https://www.schemastore.org/aio-wasm-graph-config-1.0.0.json"
  vendor: "Microsoft"

moduleRequirements:
  apiVersion: "1.1.0"
  runtimeVersion: "1.1.0"

moduleConfigurations:
  - name: module-temperature/map
    parameters:
      key1:
        name: key2
        description: key2
  - name: module-snapshot/branch
    parameters:
      snapshot_topic:
        name: snapshot_topic
        description: Transform app snapshot_topic in snapshot branch's init routine
operations:
  - operationType: "source"
    name: "source"

  - operationType: delay
    name: module-window/delay
    module: window:1.0.0
  - operationType: "map"
    name: "module-format/map"
    module: "format:1.0.0"
  - operationType: map
    name: module-snapshot/map
    module: snapshot:1.0.0
  - operationType: branch
    name: module-snapshot/branch
    module: snapshot:1.0.0
  - operationType: accumulate
    name: module-snapshot/accumulate
    module: snapshot:1.0.0
  - operationType: map
    name: module-temperature/map
    module: temperature:1.0.0
  - operationType: branch
    name: module-temperature/branch
    module: temperature:1.0.0
  - operationType: filter
    name: module-temperature/filter
    module: temperature:1.0.0
  - operationType: accumulate
    name: module-temperature/accumulate
    module: temperature:1.0.0
  - operationType: accumulate
    name: module-humidity/accumulate
    module: humidity:1.0.0
  - operationType: concatenate
    name: concatenate1
    module:
  - operationType: accumulate
    name: module-collection/accumulate
    module: collection:1.0.0
  - operationType: map
    name: module-enrichment/map
    module: enrichment:1.0.0

  - operationType: "sink"
    name: "sink"

connections:
  - from:
      name: source
    to:
      name: module-window/delay

  - from:
      name: module-window/delay
    to:
      name: module-snapshot/branch

  - from:
      name: module-snapshot/branch
      arm: "False"
    to:
      name: module-temperature/branch

  - from:
      name: module-snapshot/branch
      arm: "True"
    to:
      name: module-format/map

  - from:
      name: module-format/map
    to:
      name: module-snapshot/map

  - from:
      name: module-snapshot/map
    to:
      name: module-snapshot/accumulate

  - from:
      name: module-snapshot/accumulate
    to:
      name: concatenate1

  - from:
      name: module-temperature/branch
      arm: "True"
    to:
      name: module-temperature/map

  - from:
      name: module-temperature/branch
      arm: "False"
    to:
      name: module-humidity/accumulate

  - from:
      name: module-humidity/accumulate
    to:
      name: concatenate1

  - from:
      name: module-temperature/map
    to:
      name: module-temperature/filter

  - from:
      name: module-temperature/filter
    to:
      name: module-temperature/accumulate

  - from:
      name: module-temperature/accumulate
    to:
      name: concatenate1

  - from:
      name: concatenate1
    to:
      name: module-collection/accumulate

  - from:
      name: module-collection/accumulate
    to:
      name: module-enrichment/map

  - from:
      name: module-enrichment/map
    to:
      name: sink

이 예제에 대한 단계별 배포 지침 및 테스트 지침은 예제 2: 복잡한 그래프 배포를 참조하세요.

복잡한 그래프의 작동 방식

복잡한 그래프는 세 개의 데이터 스트림을 처리하고 이를 보강된 센서 분석으로 결합합니다.

여러 모듈이 있는 복잡한 데이터 흐름 그래프 예제를 보여 주는 다이어그램

다이어그램에 표시된 것처럼 데이터는 단일 원본에서 여러 처리 단계로 흐릅니다.

  1. 창 모듈: 시간 기반 처리를 위해 들어오는 데이터를 지연합니다.
  2. 분기 작업: 콘텐츠 형식에 따라 데이터 라우팅(센서 데이터 및 스냅샷)
  3. 온도 처리 경로:
    • 화씨에서 섭씨로 변환
    • 잘못된 판독값을 필터링합니다.
    • 시간 창에 따른 통계 요약을 계산합니다.
  4. 습도 처리 경로:
    • 통계 분석을 사용하여 습도 측정을 누적합니다.
  5. 이미지 처리 경로:
    • 처리를 위해 이미지 데이터 형식 지정
    • 카메라 스냅샷에서 개체 감지 수행
  6. 최종 집계:
    • 처리된 모든 데이터 스트림을 연결합니다.
    • 다중 센서 결과 집계
    • 메타데이터 및 overtemperature 경고를 추가합니다.

그래프는 Rust 예제의 특수 모듈을 사용합니다.

  • 시간 기반 처리 지연을 위한 창 모듈
  • 변환, 필터링 및 통계 분석을 위한 온도 모듈
  • 환경 데이터 처리를 위한 습도 모듈
  • 이미지 데이터 라우팅 및 개체 검색을 위한 스냅샷 모듈
  • 처리를 위한 이미지 준비를 위한 형식 모듈
  • 다중 센서 데이터 집계를 위한 수집 모듈
  • 메타데이터 추가 및 경고 생성을 위한 보강 모듈

분기 작업을 사용하면 여러 센서 입력을 병렬로 처리할 수 있으므로 그래프가 단일 워크플로 내에서 여러 데이터 형식을 효율적으로 처리할 수 있습니다.

그래프 정의가 데이터 흐름이 되는 방법

그래프 정의와 Azure IoT Operations 데이터 흐름 그래프의 관계는 다음과 같습니다.

YAML 파일은 원본/싱크 작업을 사용하여 내부 처리 논리를 추상 엔드포인트로 정의합니다. 그래프 정의 아티팩트가 됩니다. 참조된 모듈은 실제 처리 연산자를 WASM 모듈로 구현합니다. 그래프 정의와 WASM 모듈은 모두 레지스트리 스토리지에 대한 OCI 아티팩트로 컨테이너 레지스트리(예: Azure Container Registry)에 업로드됩니다.

Azure Resource Manager 또는 Kubernetes 리소스는 그래프 정의를 "래핑"하고 데이터 흐름 그래프 리소스로 실제 엔드포인트에 연결합니다. 런타임 배포 중에 데이터 흐름 엔진은 레지스트리에서 아티팩트 끌어와 배포합니다. 엔드포인트 매핑의 경우 그래프의 추상 원본/싱크 작업은 실제 MQTT 토픽, Azure Event Hubs 또는 기타 데이터 원본에 연결됩니다.

예를 들어 이 다이어그램은 그래프 정의, WASM 모듈 및 데이터 흐름 그래프 간의 관계를 보여 줍니다.

그래프 정의, WASM 모듈 및 데이터 흐름 그래프 간의 관계를 보여 주는 다이어그램

레지스트리 배포

데이터 흐름 그래프가 이를 참조하려면 먼저 그래프 정의와 WASM 모듈을 모두 OCI(Open Container Initiative) 아티팩트로 컨테이너 레지스트리에 업로드해야 합니다.

  • 그래프 정의는 미디어 형식의 OCI 아티팩트로 패키지됩니다. application/vnd.oci.image.config.v1+json
  • WASM 모듈은 컴파일된 WebAssembly 이진 파일을 포함하는 OCI 아티팩트로 패키지됩니다.
  • 적절한 종속성 관리를 위해 의미 체계 버전 관리(예: my-graph:1.0.0) temperature-converter:2.1.0사용
  • 레지스트리 지원은 Azure Container Registry, Docker Hub 및 기타 OCI 규격 레지스트리와 호환됩니다.

분리를 사용하면 동일한 그래프 정의가 다른 엔드포인트와 함께 배포되는 재사용 가능한 논리를 사용할 수 있습니다. 개발, 스테이징 및 프로덕션에서 서로 다른 데이터 원본을 사용하는 환경 독립성도 제공합니다. 처리 논리를 변경하지 않고 엔드포인트 구성을 업데이트하는 모듈식 배포도 지원합니다.

그래프 정의 및 WASM 모듈을 레지스트리에 업로드하는 방법에 대한 자세한 지침은 데이터 흐름 그래프와 함께 WebAssembly 사용을 참조하세요. 레지스트리 설정, 인증 및 테스트를 포함한 전체 배포 워크플로는 해당 가이드의 예제를 참조하세요.

모듈 구성 매개 변수

그래프 정의는 모듈 구성을 통해 WASM 연산자용 런타임 매개 변수를 지정할 수 있습니다.

moduleConfigurations:
  - name: my-operator/map
    parameters:
      threshold:
        name: temperature_threshold
        description: "Temperature threshold for filtering"
        required: true
      unit:
        name: output_unit
        description: "Output temperature unit"
        required: false

이러한 매개 변수는 런타임에 WASM 연산자의 init 함수에 전달되어 모듈을 다시 빌드하지 않고 동적 구성을 사용하도록 설정합니다. Rust 및 Python 코드에서 이러한 매개 변수에 액세스하고 사용하는 방법에 대한 자세한 예제는 모듈 구성 매개 변수를 참조하세요.

전체 구현 예제는 조건부 라우팅 논리에 대한 매개 변수 사용을 보여 주는 분기 모듈을 참조하세요.

다음 단계