Share via


Azure Data Manager for Agriculture에서 일기 예보 데이터 수집

날씨는 농업 산업에서 매우 대중화된 서비스입니다. Azure Data Manager for Agriculture는 고객이 선택한 날씨 공급자와 협력할 수 있는 기능을 제공합니다.

Azure Data Manager for Agriculture농업용 Azure Data Manager는 확장 기반 및 공급자에 구애받지 않는 접근 방식을 통해 현재 및 예측 날씨 데이터를 제공합니다. 날씨 확장을 작성하는 단계에 따라 원하는 공급자와 함께 작업할 수 있습니다.

디자인 개요

Azure Data Manager for Agriculture은 공급자에 구애받지 않는 접근 방식을 통해 날씨 데이터를 제공하므로 공급자의 API에 익숙할 필요가 없습니다. 대신 공급자와 관계없이 동일한 Azure Data Manager for Agriculture API를 사용할 수 있습니다.

공급자에 구애받지 않는 API의 동작에 대한 몇 가지 참고 사항은 다음과 같습니다.

  • 한 번의 호출로 최대 50개 위치에 대한 날씨 데이터를 요청할 수 있습니다.
  • 예측 데이터는 15분 이상 오래되지 않습니다. 현재 조건에 대한 데이터는 10분보다 오래되지 않습니다.
  • 위치에 대한 초기 호출이 완료되면 정의된 TTL(Time to Live)에 대한 데이터가 캐시됩니다.
  • 캐시를 따뜻하게 유지하려면 날씨 확장에서 apiFreshnessTimeInMinutes 매개 변수를 사용할 수 있습니다. 플랫폼은 정의된 시간 동안 작업을 계속 실행하고 캐시를 업데이트합니다. 기본값은 0입니다. 즉, 캐시가 기본적으로 웜 상태로 유지되지 않습니다.

다음 섹션에서는 날씨 데이터를 가져와서 Azure Data Manager for Agriculture에 수집하는 명령을 제공합니다.

1단계: 날씨 확장 설치

확장을 설치하려면 Azure Resource Manager ARMClient 도구를 사용하여 다음 명령을 실행합니다.

꺾쇠 괄호(<>)의 모든 값을 해당 환경 값으로 대체합니다. 현재 지원되는 확장 ID는 IBM.TWC입니다.

armclient PUT /subscriptions/<subscriptionid>/resourceGroups/<resource-group-name>/providers/Microsoft.AgFoodPlatform/farmBeats/<farmbeats-resource-name>/extensions/<extensionid>?api-version=2020-05-12-preview '{}'

설치 명령에 대한 샘플 출력은 다음과 같습니다.

{
      "id": "/subscriptions/<subscriptionid>/resourceGroups/<resource-group-name>/providers/Microsoft.AgFoodPlatform/farmBeats/<farmbeats-resource-name>/extensions/<extensionid>",
      "type": "Microsoft.AgFoodPlatform/farmBeats/extensions",
      "systemData": {
        "createdBy": "testuser@abc.com",
        "createdByType": "User",`        
        "createdAt": "2021-03-17T12:36:51Z",
        "lastModifiedBy": "testuser@abc.com",
        "lastModifiedByType": "User",
        "lastModifiedAt": "2021-03-17T12:36:51Z"
      },
      "properties": {
        "category": "Weather",
        "installedExtensionVersion": "1.0",
        "extensionAuthLink": "https://www.<provider.com/integration/",
        "extensionApiDocsLink": "https://docs.<provider>.com/documentation/Weather_Data/Historical_and_Climatological_Weather/latest#_daily_historical_ag_weather_v1_0"
      },
      "eTag": "92003c91-0000-0700-0000-804752e00000",
      "name": "<provider>"
}

확장 설치를 완료한 후 날씨 데이터를 수집할 수 있습니다.

apiFreshnessTimeInMinutes을(를) 업데이트하려면 다음 PowerShell 명령을 사용하여 확장을 업데이트합니다. 꺾쇠 괄호 안의 모든 값을 해당 환경 값으로 대체합니다.

armclient put /subscriptions/<subscriptionid>/resourceGroups/<resource-group-name>/providers/Microsoft.AgFoodPlatform/farmBeats/<farmbeats-resource-name>/<extensionid>?api-version=2021-09-01-preview '{"additionalApiProperties": {""15-day-daily-forecast"": {"apiFreshnessTimeInMinutes": <time>}, ""currents-on-demand"": {"apiFreshnessTimeInMinutes": <time>},""15-day-hourly-forecast"":{"apiFreshnessTimeInMinutes": <time>}}}'

이전 업데이트 명령은 패치 작업을 병합합니다. 명령에 언급된 API에 대해서만 새로 고침 시간을 업데이트하고 이전과 같이 다른 API의 새로 고침 시간 값을 유지합니다.

업데이트 명령에 대한 샘플 출력은 다음과 같습니다.

{
  "id": "/subscriptions/<subscriptionid>/resourceGroups/<resource-group-name>/providers/Microsoft.AgFoodPlatform/farmBeats/<farmbeats-resource-name>/extensions/<extensionid>",
  "type": "Microsoft.AgFoodPlatform/farmBeats/extensions",
  "systemData": {
    "createdBy": "50e74af5-3b8f-4a8c-9521-4f506b4e0c16",
    "createdByType": "User",
    "createdAt": "2022-10-10T21:28:05Z",
    "lastModifiedBy": "50e74af5-3b8f-4a8c-9521-4f506b4e0c16",
    "lastModifiedByType": "User",
    "lastModifiedAt": "2022-11-08T13:10:17Z"
  },
  "properties": {
    "extensionId": "provider",
    "extensionCategory": "Weather",
    "installedExtensionVersion": "2.0",
    "extensionApiDocsLink": "https://go.microsoft.com/fwlink/?linkid=2192974",
    "additionalApiProperties": {
      "15-day-daily-forecast": {
        "apiFreshnessTimeInMinutes": 1600
      },
      "currents-on-demand": {
        "apiFreshnessTimeInMinutes": 1600
      },
       "15-day-hourly-forecast": {
        "apiFreshnessTimeInMinutes": 1600
      }
    }
  },
  "eTag": "ea0261d0-0000-0700-0000-636a55390000",
  "name": "provider"
}

2단계: 날씨 데이터 가져오기

API에 액세스하는 데 필요한 자격 증명을 가져온 후 날씨 데이터 API를 호출하여 날씨 데이터를 가져와야 합니다.