シナリオ: HTTPを使用した非構造化データの送信

このシナリオでは、Internet of Thingsプラットフォームを使用してデバイスを接続し、HTTPを使用して非構造化テレメトリ・データをクラウドに送信する方法と、APEXでデータを表示する方法について説明します。

  1. IoTドメイン・グループの作成
  2. IoTドメインの作成
  3. デジタル・ツイン・インスタンスの作成
  4. データの送信
  5. APEXにアクセスするためのIoTドメインの構成
  6. APEXのIoTデータへのアクセス

Internet of Thingsに接続するデバイスごとに、次のステップを実行します。

ステップ1: IoTドメイン・グループの作成

oci iot domain-group createコマンド、<compartment-OCID>および<domain-group-name>の必須パラメータを使用して、特定のコンパートメントにIoTドメイン・グループを作成します。<compartment-OCID>を、ドメイン・グループを作成するコンパートメント用のOCIDに置き換えます。<domain-group-name>をドメイン・グループ名に置き換え、オプションで<your-sample-description>を説明に置き換えます。

oci iot domain-group create --compartment-id <compartment-OCID> --display-name <domain-group-name> --description <your-sample-description>

IoTドメイン・グループの作成には数分かかる場合があります。このレスポンス例では、ドメイン・グループが作成され、このデータ・ホストURLが使用されています:

wtmn2xs4ifkba.data.iot.us-phoenix-1.oci.oraclecloud.com

ドメイン・グループの短縮ID: wtmn2xs4ifkba

data-host:<domain-group-short-id>.data.iot.<region>.oci.oraclecloud.com

{
  "data": {
    "compartment-id": "<compartment-OCID>",
    "data-host": "wtmn2xs4ifkba.data.iot.<region>.oci.oraclecloud.com",
    "db-allow-listed-vcn-ids": null,
    "db-connection-string": null,
    "db-token-scope": null,
    "defined-tags": {
      "Oracle-Tags": {
        "CreatedBy": "default/user@oracle.com",
        "CreatedOn": "2025-08-14T16:43:02.950Z"
      }
    },
    "description": "<your-domain-group-description>",
    "display-name": "<your-domain-group-name>",
    "freeform-tags": {},
    "id": "<domain-group-OCID>",
    "lifecycle-state": "CREATING",
    "system-tags": {},
    "time-created": "2025-08-14T16:43:03.307000+00:00",
    "time-updated": "2025-08-14T16:43:03.307000+00:00"
  },
  "etag": "<unique-id>",
  "opc-work-request-id": "<work-request-OCID>"
}
        
オプションのステップ: IoTドメイン・グループ作成時の作業リクエスト更新の取得
オプション。ドメイン・グループの作成にかかる時間中に、oci iot work-request getコマンドおよび必須パラメータを使用して、ドメイン・グループの作成プロセスの作業リクエストの更新を取得します。<work-request-id>を、IoTドメイン・グループ・レスポンスの作成時の作業リクエストOCIDに置き換えます。
oci iot work-request get --work-request-id <work-request-OCID>

このレスポンス例は、ドメイン・グループの作成操作が進行中であることを示しています。

{
  "data": {
    "compartment-id": "<compartment-OCID>",
    "id": "<work-request-OCID>",
    "operation-type": "CREATE_IOT_DOMAIN_GROUP",
    "percent-complete": 50.0,
    "resources": [
      {
        "action-type": "IN_PROGRESS",
        "entity-type": "iotDomainGroup",
        "entity-uri": "/20250531/iotDomainGroups/<iot-domain-group-OCID>",
        "identifier": "<work-request-OCID>",
        "metadata": null
      }
    ],
    "status": "ACCEPTED",
    "time-accepted": "2025-08-14T16:43:03.327000+00:00",
    "time-finished": null,
    "time-started": null,
    "time-updated": "2025-08-14T16:43:22.121000+00:00"
  },
  "etag": "<unique-id>"
}
        
オプションのステップ: IoTドメイン・グループ作成時の作業リクエスト・エラーのリスト
オプション。ドメイン・グループの作成にかかる時間中に、エラーをチェックする場合は、oci iot work-request list-errorsコマンドおよび必須パラメータを使用して、ドメイン・グループの作成プロセスの作業リクエスト・エラーをリストできます。
oci iot work-request list-errors --work-request-id <work-request-OCID>
レスポンスの例:
{
  "data": {
    "items": []
  }
}
オプションのステップ: IoTドメイン・グループ作成時の作業リクエスト・ログのリスト
オプション。ドメイン・グループの作成にかかる時間中に、ログ・エントリをリストする場合は、oci iot work-request list-logsコマンドと必要なパラメータを使用して作業リクエストのログ・エントリをリストできます。
oci iot work-request list-logs --work-request-id <work-request-OCID>

このレスポンス例では、IoTドメイン・グループを作成するステップを示し、それが終了しています:

{
  "data": {
    "items": [
      {
        "message": "Generating database credentials",
        "timestamp": "2025-08-14T16:43:12.150000+00:00"
      },
      {
        "message": "Creating database",
        "timestamp": "2025-08-14T16:43:18.156000+00:00"
      },
      {
        "message": "Provisioning database",
        "timestamp": "2025-08-14T16:43:22.121000+00:00"
      },
      {
        "message": "Enabling data guard",
        "timestamp": "2025-08-14T16:48:25.138000+00:00"
      },
      {
        "message": "Configuring admin secret rotation ",
        "timestamp": "2025-08-14T16:53:59.878000+00:00"
      },
      {
        "message": "Generating DNS record(s)",
        "timestamp": "2025-08-14T16:54:05.318000+00:00"
      },
      {
        "message": "Configuring routing policy",
        "timestamp": "2025-08-14T16:54:06.455000+00:00"
      },
      {
        "message": "Finishing work request",
        "timestamp": "2025-08-14T16:54:58.139000+00:00"
      }
    ]
  }
}
オプションのステップ: IoTドメイン・グループの作成が完了したことを確認する作業リクエストの取得
  1. オプション。oci iot work-request getコマンドおよび必須パラメータを使用して、ドメイン・グループの作業リクエストの更新を取得します。<work-request-id>を作業リクエストOCIDに置き換えます。
    oci iot work-request get --work-request-id <work-request-OCID>

    このレスポンス例では、IoTドメイン・グループの作成に成功しました。

    {
      "data": {
        "compartment-id": "<compartment-OCID>",
        "id": "<work-request-OCID>",
        "operation-type": "CREATE_IOT_DOMAIN_GROUP",
        "percent-complete": 100.0,
        "resources": [
          {
            "action-type": "CREATED",
            "entity-type": "iotDomainGroup",
            "entity-uri": "/20250531/iotDomainGroups/<domain-group-OCID>",
            "identifier": "<domain-group-OCID>",
            "metadata": null
          }
        ],
        "status": "SUCCEEDED",
        "time-accepted": "2025-08-14T16:43:03.327000+00:00",
        "time-finished": "2025-08-14T16:54:58.139000+00:00",
        "time-started": "2025-08-14T16:43:12.131000+00:00",
        "time-updated": "2025-08-14T16:54:58.139000+00:00"
      },
      "etag": "<unique-id>"
    }
    

オプションのステップ: IoTドメイン・グループの詳細の取得

oci iot domain-group getコマンドおよび必須パラメータを使用して、ドメイン・グループのデータベース接続の詳細(構成されている場合)を含むIoTドメイン・グループの詳細を取得します。<iot-domain-group-OCID>を、IoTドメイン・グループのOCIDに置き換えます。

oci iot domain-group get --iot-domain-group-id <iot-domain-group-OCID>
このレスポンス例では、ドメイン・グループがアクティブである"lifecycleState": "ACTIVE"を示し、次のデータ・ホストを使用します: wtmn2xs4ifkba.data.iot.us-phoenix-1.oci.oraclecloud.com。この例では、wtmn2xs4ifkbaはIoTドメイン・グループ短縮IDです。
{
  "data": {
    "compartment-id": "<compartment-OCID>",
    "data-host": "wtmn2xs4ifkba.data.iot.<region>.oci.oraclecloud.com",
    "db-allow-listed-vcn-ids": null,
    "db-connection-string": null,
    "db-token-scope": null,
    "defined-tags": {
      "Oracle-Tags": {
        "CreatedBy": "default/user@oracle.com",
        "CreatedOn": "2025-08-14T16:43:02.950Z"
      }
    },
    "description": "This is a sample domain group",
    "display-name": "Sample Domain Group",
    "freeform-tags": {},
    "id": "<iot-domain-group-OCID>",
    "lifecycle-state": "ACTIVE",
    "system-tags": {},
    "time-created": "2025-08-14T16:43:03.307000+00:00",
    "time-updated": "2025-08-14T16:54:58.187000+00:00"
  },
  "etag": "<unique-id>"
}

ステップ2: IoTドメインの作成

Internet of Thingsドメインを作成するには、oci iot domain createコマンドおよび必要な<domain-group-OCID>および<compartment-OCID>パラメータを使用します。<domain-group-OCID>を、このIoTドメインに関連付けるドメイン・グループのOCIDに置き換えます。<your-sample-description>を、IoTドメインの説明に置き換えます。

oci iot domain create --compartment-id <compartment-OCID> --iot-domain-group-id <domain-group-OCID> --display-name <your-iot-domain-name> --description <your-iot-domain-description>

ドメインの作成には数分かかる場合があります。このレスポンス例では、domain short iddevice host URLが表示されます。

"device-host": "cuay2mrhlgrrg.device.iot.<region>.oci.oraclecloud.com"

ドメイン短縮ID: cuay2mrhlgrrg

"device-host": "<domain-short-id>.device.iot.<region>.oci.oraclecloud.com"

{
  "data": {
    "compartment-id": "<compartment-OCID>",
    "data-retention-periods-in-days": {
      "historized-data": 30,
      "raw-command-data": 16,
      "raw-data": 16,
      "rejected-data": 16
    },
    "db-allow-listed-identity-group-names": null,
    "db-allowed-identity-domain-host": null,
    "defined-tags": {
      "Oracle-Tags": {
        "CreatedBy": "default/user@oracle.com",
        "CreatedOn": "2025-08-14T16:57:03.140Z"
      }
    },
    "description": "<your-iot-domain-description>",
    "device-host": "cuay2mrhlgrrg.device.iot.<region>.oci.oraclecloud.com",
    "display-name": "<your-iot-domain-name>",
    "freeform-tags": {},
    "id": "<iot-domain-OCID>",
    "iot-domain-group-id": "<iot-domain-group-OCID>",
    "lifecycle-state": "CREATING",
    "system-tags": {},
    "time-created": "2025-08-14T16:57:03.384000+00:00",
    "time-updated": "2025-08-14T16:57:03.384000+00:00"
  },
  "etag": "<unique-id>",
  "opc-work-request-id": "<work-request-OCID>"
}
オプションのステップ: IoTドメイン作成時の作業リクエストの取得

オプション。ドメインの作成にかかる時間中に、oci iot work-request getコマンドおよび必須パラメータを使用して、ドメインを作成するための作業リクエストの更新を取得します。<work-request-id>を、前のレスポンスの作業リクエストIDに置き換えます。

oci iot work-request get --work-request-id <work-request-OCID>

レスポンス例は、IoTドメインの作成が受け入れられ、進行中であることを示しています。

{
  "data": {
    "compartment-id": "<iot-domain-OCID>",
    "id": "<work-request-OCID>",
    "operation-type": "CREATE_IOT_DOMAIN",
    "percent-complete": 50.0,
    "resources": [
      {
        "action-type": "IN_PROGRESS",
        "entity-type": "iotDomain",
        "entity-uri": "/20250531/iotDomains/<iot-domain-OCID>",
        "identifier": "<iot-domain-OCID>",
        "metadata": null
      }
    ],
    "status": "ACCEPTED",
    "time-accepted": "2025-08-14T16:57:03.413000+00:00",
    "time-finished": null,
    "time-started": null,
    "time-updated": "2025-08-14T16:57:23.124000+00:00"
  },
  "etag": "<unique-id>"
}
オプション・ステップ: 作業リクエスト・ログの取得
オプション。ドメインの作成にかかる時間中に、作業リクエストのログ・エントリをリストする場合は、oci iot work-request list-logsコマンドと必要なパラメータを使用して、IoTドメイン作成作業リクエストのログ・エントリをリストできます。
oci iot work-request list-logs --work-request-id <work-request-OCID>

このレスポンス例では、IoTドメインを作成するステップと、ドメインが終了しているステップを示します。

{
  "data": {
    "items": [
      {
        "message": "Generating DNS record(s)",
        "timestamp": "2025-08-14T16:57:22.148000+00:00"
      },
      {
        "message": "Onboarding domain schema(s)",
        "timestamp": "2025-08-14T16:57:23.124000+00:00"
      },
      {
        "message": "Successfully onboarded domain schemas",
        "timestamp": "2025-08-14T16:58:43.508000+00:00"
      },
      {
        "message": "Finishing work request",
        "timestamp": "2025-08-14T16:58:43.771000+00:00"
      }
    ]
  }
}
オプションのステップ: IoTドメイン作成時の作業リクエストの取得
オプション。oci iot work-request getコマンドおよび必須パラメータを使用して、ドメインを作成するための作業リクエストの更新を取得します。<work-request-id>を作業リクエストOCIDに置き換えます。
oci iot work-request get --work-request-id <work-request-OCID>

このレスポンス例では、IoTドメインの作成が成功しました。

"status": "SUCCEEDED",

{
  "data": {
    "compartment-id": "<compartment-OCID>",
    "id": "<work-request-OCID>",
    "operation-type": "CREATE_IOT_DOMAIN",
    "percent-complete": 100.0,
    "resources": [
      {
        "action-type": "CREATED",
        "entity-type": "iotDomain",
        "entity-uri": "/20250531/iotDomains/<iot-domain-OCID>",
        "identifier": "<iot-domain-OCID>",
        "metadata": null
      }
    ],
    "status": "SUCCEEDED",
    "time-accepted": "2025-08-14T16:57:03.413000+00:00",
    "time-finished": "2025-08-14T16:58:43.771000+00:00",
    "time-started": "2025-08-14T16:57:22.147000+00:00",
    "time-updated": "2025-08-14T16:58:43.771000+00:00"
  },
  "etag": "<unique-id>"
}

オプションのステップ: IoTドメインの詳細の取得

ドメインがアクティブであることを確認するには、oci iot domain getコマンドと必要なパラメータを使用して、ドメインの詳細を取得します。<iot-domain-OCID>を、IoTドメインのOCIDに置き換えます。
oci iot domain get --iot-domain-id <iot-domain-OCID>

このレスポンス例は、ドメインがアクティブであることを示しています: "lifecycle-state": "ACTIVE"およびドメイン短縮IDのデバイス・ホストURL:

<domain-short-id>.device.iot.<region>.oci.oraclecloud.com

{
  "data": {
    "compartment-id": "<compartment-OCID>",
    "data-retention-periods-in-days": {
      "historized-data": 30,
      "raw-command-data": 16,
      "raw-data": 16,
      "rejected-data": 16
    },
    "db-allow-listed-identity-group-names": null,
    "db-allowed-identity-domain-host": null,
    "defined-tags": {
      "Oracle-Tags": {
        "CreatedBy": "default/user@oracle.com",
        "CreatedOn": "2025-08-14T16:57:03.140Z"
      }
    },
    "description": "<your-iot-domain-description>",
    "device-host": "<domain-short-id>.device.iot.<region>.oci.oraclecloud.com",
    "display-name": "<your-iot-domain-name>",
    "freeform-tags": {},
    "id": "<iot-domain-OCID>",
    "iot-domain-group-id": "<iot-domain-group-OCID>",
    "lifecycle-state": "ACTIVE",
    "system-tags": {},
    "time-created": "2025-08-14T16:57:03.384000+00:00",
    "time-updated": "2025-08-14T16:58:43.789000+00:00"
  },
  "etag": "<unique-id>"
}

ステップ3: デジタル・ツイン・インスタンスの作成

oci iot digital-twin-instance createコマンドおよび必要な<iot-domain-OCID>パラメータを使用して、関連するIoTドメインのデジタル・ツイン・インスタンスを作成します。デジタル・ツイン・インスタンスを作成する場合、必須および認証ID。証明書またはシークレットのいずれかを使用します。シークレットの作成を参照してください。

<iot-domain-OCID>を、デジタル・ツイン・インスタンスのIoTドメインのOCIDに置き換えます。このコマンド例には、オプションの表示名が含まれ、<display-name>をデジタル・ツイン・インスタンスのわかりやすい名前に置き換えます。
oci iot digital-twin-instance create --iot-domain-id <iot-domain-OCID> --auth-id <vault-secret-OCID> --display-name <display-name>
レスポンスの例:
{
  "data": {
    "auth-id": "<vault-secret-OCID>",
    "defined-tags": {
      "Oracle-Tags": {
        "CreatedBy": "default/user@oracle.com",
        "CreatedOn": "2025-08-14T06:12:43.393Z"
      }
    },
    "description": null,
    "digital-twin-adapter-id": "<iot-digital-twin-adapter-OCID>",
    "digital-twin-model-id": "<iot-digital-twin-model-OCID>",
    "digital-twin-model-spec-uri": "dtmi:com:oracle:example:core:Space:sp;1",
    "display-name": "device for conference room 103",
    "external-key": "<unique-id>",
    "freeform-tags": {},
    "id": "<iot-digital-twin-instance-OCID>",
    "iot-domain-id": "<iot-domain-OCID>",
    "lifecycle-state": "ACTIVE",
    "system-tags": {},
    "time-created": "2025-09-11T06:12:44.178000+00:00",
    "time-updated": "2025-09-11T06:12:44.178000+00:00"
  },
  "etag": "<unique-id>"
}

ステップ4: データの送信

前の手順の device host URLを使用してデータを送信します。

送信するデータをいくらでも送信できます。この例では、2つのプレーン・テキスト・データ・メッセージの送信を示します。最初の例は、このシナリオの値を使用するコマンドを示しています。2番目のコマンドは、値名を表示します。詳細は、cURLの使用を参照してください

<domain-short-id>および<region>を環境の値に置き換えます。

https://<domain-short-id>.device.iot.<region>.oci.oraclecloud.com/sampletopic

このcurlコマンドの例では、デバイス・ホストURLが含まれ、このシナリオに基づく値を示し、サンプル・トピックが含まれています。
curl -u '9K7F8Y3HJGX1FA1GFG9QVV9E2C<vault-secret-OCID>' https://<domain-short-id>.device.iot.us-phoenix-1.oci.oraclecloud.com/sampletopic -H 'Content-Type: plain-text' -d "sample data 2"
このcurlコマンドの例では、このシナリオの値の例のない値の名前を示します。
curl -u '<external-key>:<vault-secret-OCID>' https://<domain-short-id>.device.iot.<region>.oci.oraclecloud.com/sampletopic -H 'Content-Type: plain-text' -d "sample data 1"

ステップ5: APEXへのIoTドメインのアクセスの構成

APEXでデータを表示するには、APEXでIoTデータを表示するためのアクセスの構成が必要です。このプロセスのステップでは、APEXにアクセスできるように、次のコマンドを使用してAPEXパスワードをIoTドメインに追加します。

oci iot domain configure-apex-data-accessコマンドおよび必要なパラメータを使用して、APEXへのIoTドメインのアクセスを構成します。<your-initial-apex-password>および<iot-domain-OCID>を環境の値に置き換えます。
oci iot domain configure-apex-data-access --iot-domain-id <iot-domain-OCID> --db-workspace-admin-initial-password <your-inital-apex-password>

レスポンスの例:

{
  "opc-work-request-id": "<work-request-OCID>"
}
オプション・ステップ: データ・アクセスの作業要求の取得

オプション。APEXへのアクセスの構成にかかる時間中に、oci iot work-request getコマンドと必要なパラメータを使用して作業リクエストの更新を取得します。<work-request-id>を、前のレスポンスの作業リクエストIDに置き換えます。

oci iot work-request get --work-request-id <work-request-OCID>

レスポンスの例:

{
  "data": {
    "compartment-id": "<compartment-OCID>",
    "id": "<work-request-OCID>",
    "operation-type": "CONFIGURE_DOMAIN_DATA_ACCESS",
    "percent-complete": 0.0,
    "resources": [
      {
        "action-type": "IN_PROGRESS",
        "entity-type": "iotDomain",
        "entity-uri": "/20250531/iotDomains/<iot-domain-OCID>",
        "identifier": "<iot-domain-OCID>",
        "metadata": null
      }
    ],
    "status": "ACCEPTED",
    "time-accepted": "2025-08-14T17:44:44.716000+00:00",
    "time-finished": null,
    "time-started": null,
    "time-updated": "2025-08-14T17:44:44.716000+00:00"
  },
  "etag": "<unique-id>"
}
オプション・ステップ: 作業リクエスト・ログのリスト
オプション。ドメインのAPEXへのアクセスの構成にかかる時間中に、ログ・エントリをリストする場合は、oci iot work-request list-logsコマンドと必要なパラメータを使用して、作業リクエストのログ・エントリをリストできます:
oci iot work-request list-logs --work-request-id <work-request-OCID>

このレスポンス例では、ドメインのAPEXへのアクセスが進行中で、それが終了していることを示しています:

{
  "data": {
    "items": [
      {
        "message": "Configuring domain data access is in Progress",
        "timestamp": "2025-08-14T17:45:19.708000+00:00"
      },
      {
        "message": "Finishing work request",
        "timestamp": "2025-08-14T17:45:19.978000+00:00"
      }
    ]
  }
}
オプション・ステップ: 作業リクエスト・エラーのリスト
オプション。ドメインのAPEXへのアクセスの構成にかかる時間中に、エラーをチェックする場合は、oci iot work-request list-errorsコマンドおよび必要なパラメータを使用して作業リクエスト・エラーをリストできます:
oci iot work-request list-errors --work-request-id <work-request-OCID>
レスポンスの例:
{
  "data": {
    "items": []
  }
}
オプション・ステップ: 作業要求の取得
オプション。APEXアクセスの構成が終了したことを確認するには、oci iot work-request getコマンドと必要なパラメータを使用して作業リクエストを取得します。<work-request-id>を作業リクエストIDに置き換えます。
oci iot work-request get --work-request-id <work-request-OCID>

このレスポンス例では、IoTドメインのAPEXに対する構成アクセスが更新されています:

"status": "SUCCEEDED"

{
  "data": {
    "compartment-id": "<compartment-OCID>",
    "id": "<work-request-OCID>",
    "operation-type": "CONFIGURE_DOMAIN_DATA_ACCESS",
    "percent-complete": 100.0,
    "resources": [
      {
        "action-type": "UPDATED",
        "entity-type": "iotDomain",
        "entity-uri": "/20250531/iotDomains/<iot-domain-OCID>",
        "identifier": "<iot-domain-OCID>",
        "metadata": null
      }
    ],
    "status": "SUCCEEDED",
    "time-accepted": "2025-08-14T17:44:44.716000+00:00",
    "time-finished": "2025-08-14T17:45:19.978000+00:00",
    "time-started": "2025-08-14T17:45:19.708000+00:00",
    "time-updated": "2025-08-14T17:45:19.978000+00:00"
  },
  "etag": "<unique-id>"
}

ステップ6: APEXでのIoTデータへのアクセス

  1. APEXにログインするには、デバイス・ホストドメイン短縮IDを使用します:

    https://<domain-group-short-id-from-data-host>.data.iot.<region>.oci.oraclecloud.com/ords/r/apex

    device-host:<domain-short-id>.device.iot.<region>.oci.oraclecloud.com

    APEXで、次を使用してログインします。
    ノート

    2つのアンダースコア(__WKSPおよび __IOT)に注意してください。
  2. IoTデータを問い合せるには、<domain-short-id-from-device-host>__IOTスキーマを選択します。「SQLワークショップ」を選択し、「オブジェクト・ブラウザ」を選択します。

    SQLワークショップのURL:

    https://<domain-group-short-id-from-data-host>.data.iot.<region>.oci.oraclecloud.com/ords/r/apex/sql-workshop
  3. SQLコマンドを入力して実行し、IoTデータを問い合せます。問合せするデータベース表の正しいスキーマを選択したことを確認し、次のコマンドを実行します。
    select * from RAW_DATA

    これで、Internet of Things接続デバイスのデータベース・ビュー、スキーマおよびRAWデータを確認できます。

    大きなスクリーンショットを表示するには、右クリックして新しいブラウザ・ウィンドウでイメージを開きます。

APEX IoT