본문 바로가기
카테고리 없음

Azure IoT Edge 체험하기

by Knowledge Store In Hyunsoft 2019. 10. 14.
* 이 포스팅은 쿠팡 파트너스 활동의 일환으로 이에 따른 일정액의 수수료를 제공받습니다.

1. 체험 계정 생성하기 https://azure.microsoft.com/free

 

지금 Azure 체험 계정 만들기 | Microsoft Azure

12개월 체험 서비스 및 USD 200 크레딧으로 시작하세요. Microsoft Azure에서 지금 체험 계정을 만들어 보세요.

azure.microsoft.com

2. Azure Cli로 Cloud Shell 인스턴스 추가

az login 

az extension add --name azure-cli-iot-ext

3. 리소스 그룹 생성

az group create --name IoTEdgeResources --location koreacentral

4. 테스트용 IoT 디바이스 생성(windows 10 가상머신: 약 7분 소요)

az vm create --resource-group IoTEdgeResources --name EdgeVM --image MicrosoftWindowsDesktop:Windows-10:rs5-pro:latest --admin-username azureuser --admin-password {password} --size Standard_DS1_v2
  1. Azure Portal에서 새 Windows 가상 머신으로 이동합니다.
  2. 연결을 선택합니다.
  3. RDP 탭에서 RDP 파일 다운로드를 선택합니다.

 

IoT Hub 만들기

1. iot hub 만들기(약 4분 소요)

az iot hub create --resource-group IoTEdgeResources --name {hub_name} --sku F1
더보기
{
  "etag": "AAAAAAjFViQ=",
  "id": "/subscriptions/0ea1e62f-acc5-424a-9dcd-d9b644d5eef2/resourceGroups/IoTEdgeResources/providers/Microsoft.Devices/IotHubs/hyun-iot-hub",
  "location": "koreacentral",
  "name": "hyun-iot-hub",
  "properties": {
    "authorizationPolicies": null,
    "cloudToDevice": {
      "defaultTtlAsIso8601": "1:00:00",
      "feedback": {
        "lockDurationAsIso8601": "0:01:00",
        "maxDeliveryCount": 10,
        "ttlAsIso8601": "1:00:00"
      },
      "maxDeliveryCount": 10
    },
    "comments": null,
    "deviceStreams": null,
    "enableFileUploadNotifications": false,
    "eventHubEndpoints": {
      "events": {
        "endpoint": "sb://ihsuprodseres005dednamespace.servicebus.windows.net/",
        "partitionCount": 2,
        "partitionIds": [
          "0",
          "1"
        ],
        "path": "iothub-ehub-hyun-iot-h-2309451-8560760109",
        "retentionTimeInDays": 1
      },
      "operationsMonitoringEvents": {
        "endpoint": "sb://ihsuprodseres004dednamespace.servicebus.windows.net/",
        "partitionCount": 2,
        "partitionIds": [
          "0",
          "1"
        ],
        "path": "iothub-ehub-hyun-iot-h-2309451-12d9f6a196",
        "retentionTimeInDays": 1
      }
    },
    "features": "None",
    "hostName": "hyun-iot-hub.azure-devices.net",
    "ipFilterRules": [],
    "locations": [
      {
        "location": "Korea Central",
        "role": "primary"
      },
      {
        "location": "Korea South",
        "role": "secondary"
      }
    ],
    "messagingEndpoints": {
      "fileNotifications": {
        "lockDurationAsIso8601": "0:01:00",
        "maxDeliveryCount": 10,
        "ttlAsIso8601": "1:00:00"
      }
    },
    "operationsMonitoringProperties": {
      "events": {
        "C2DCommands": "None",
        "Connections": "None",
        "DeviceIdentityOperations": "None",
        "DeviceTelemetry": "None",
        "FileUploadOperations": "None",
        "None": "None",
        "Routes": "None"
      }
    },
    "provisioningState": "Succeeded",
    "routing": {
      "endpoints": {
        "eventHubs": [],
        "serviceBusQueues": [],
        "serviceBusTopics": [],
        "storageContainers": []
      },
      "fallbackRoute": {
        "condition": "true",
        "endpointNames": [
          "events"
        ],
        "isEnabled": true,
        "name": "$fallback"
      },
      "routes": []
    },
    "state": "Active",
    "storageEndpoints": {
      "$default": {
        "connectionString": "",
        "containerName": "",
        "sasTtlAsIso8601": "1:00:00"
      }
    }
  },
  "resourceGroup": "IoTEdgeResources",
  "resourcegroup": "IoTEdgeResources",
  "sku": {
    "capacity": 1,
    "name": "F1",
    "tier": "Free"
  },
  "subscriptionid": "0ea1e62f-acc5-424a-9dcd-d9b644d5eef2",
  "tags": {},
  "type": "Microsoft.Devices/IotHubs"
}

 

2. hub에 myEdgeDevice 장치 생성

az iot hub device-identity create --device-id myEdgeDevice --hub-name {hub_name} --edge-enabled
더보기

{
  "authentication": {
    "symmetricKey": {
      "primaryKey": "wcfIrtREJqeZWg3KvRevlOF7fGf6ZrofWt6aQLzipuM=",
      "secondaryKey": "AUNmCnI2giAMle1qgKXhm5wKxtmuVcPheMvNsdVZrlg="
    },
    "type": "sas",
    "x509Thumbprint": {
      "primaryThumbprint": null,
      "secondaryThumbprint": null
    }
  },
  "capabilities": {
    "iotEdge": true
  },
  "cloudToDeviceMessageCount": 0,
  "connectionState": "Disconnected",
  "connectionStateUpdatedTime": "0001-01-01T00:00:00",
  "deviceId": "myEdgeDevice",
  "deviceScope": "ms-azure-iot-edge://myEdgeDevice-637066461556035877",
  "etag": "NjI4OTU0MzQ5",
  "generationId": "637066461556035877",
  "lastActivityTime": "0001-01-01T00:00:00",
  "status": "enabled",
  "statusReason": null,
  "statusUpdatedTime": "0001-01-01T00:00:00"
}

 

3. IoT Hub에서 물리적 디바이스를 해당 ID에 연결하는 디바이스에 대한 연결 문자열을 검색

az iot hub device-identity show-connection-string --device-id myEdgeDevice --hub-name {hub_name}

 

IoT Edge 런타임 설치 및 시작

1. 원격데스크탑으로 vm에 접속

 

2. PowerShell 을 관리자 권한으로 실행

 

3.AMD64 세션인지 확인

(Get-Process -Id $PID).StartInfo.EnvironmentVariables["PROCESSOR_ARCHITECTURE"]

 

4.Deploy-IoTEdge 명령 실행 (사용자의 Windows 머신이 지원되는 버전인지 확인하고, 컨테이너 기능을 작동하도록 켜고, moby 런타임을 다운로드한 다음, IoT Edge 런타임을 다운로드)

. {Invoke-WebRequest -useb aka.ms/iotedge-win} | Invoke-Expression; `
Deploy-IoTEdge -ContainerOs Windows

5.vm 리부팅

 

6.  PowerShell 을 관리자 권한으로 실행

 

7. Initialize IoTEdge 명령 (사용자의 머신에서 IoT Edge 런타임을 구성)

. {Invoke-WebRequest -useb aka.ms/iotedge-win} | Invoke-Expression; `
Initialize-IoTEdge -ContainerOs Windows

 

8. DeviceConnectionString 입력(샘플)

HostName=hyun-iot-hub.azure-devices.net;DeviceId=myEdgeDevice;SharedAccessKey=amzc2XY+2EVlMIv/n5qqYIhi3fNHuYbMKbXTTdK+TVo=

 

IoT Edge 런타임 상태 보기

1. vm에서 PowerShell 을 관리자 권한으로 실행

 

2. 상태 확인

Get-Service iotedge

 

3. IoT Edge 디바이스에서 실행되는 모든 모듈 보기

iotedge list

 

IoT Edge 모듈 배포

1. 에저 마켓플레이스로 이동(  https://azuremarketplace.microsoft.com/ko-kr/marketplace/apps/microsoft.edge-simulated-temperature-sensor-ga?tab=Overview )

 

2. 지금 받기 클릭

 

3, 디바이스 배포

 

 

728x90