iot-cloud

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

iot-cloud

IoT云平台

Purpose

用途

This skill enables interaction with major cloud IoT platforms, including AWS IoT Core, GCP IoT Core, and Azure IoT Hub, for device management, data ingestion, and fleet operations. It focuses on automating IoT workflows like provisioning devices and handling telemetry.
本Skill支持与主流云IoT平台(包括AWS IoT Core、GCP IoT Core和Azure IoT Hub)进行交互,用于设备管理、数据采集和设备组操作。它专注于自动化IoT工作流,例如设备配置和遥测数据处理。

When to Use

适用场景

Use this skill for IoT device management in cloud environments, such as scaling fleets of connected devices, integrating IoT data with backend services, or monitoring remote sensors. Apply it when dealing with AWS, GCP, or Azure IoT services, especially for real-time data processing or fleet-wide updates.
当你需要在云环境中进行IoT设备管理时使用本Skill,例如扩展联网设备组、将IoT数据与后端服务集成,或者监控远程传感器。在使用AWS、GCP或Azure IoT服务时,尤其是进行实时数据处理或全设备组更新时,均可应用本Skill。

Key Capabilities

核心功能

  • Provision and manage IoT devices on AWS IoT Core, including creating things and attaching policies.
  • Handle device registry and telemetry in GCP IoT Core via Pub/Sub integration.
  • Manage device identities and message routing in Azure IoT Hub, including direct method calls.
  • Support fleet management features like bulk updates, shadow synchronization (AWS), and device twins (Azure).
  • Query device states and handle secure connections using MQTT or HTTPS protocols across platforms.
  • 在AWS IoT Core上配置和管理IoT设备,包括创建Thing和附加策略。
  • 通过Pub/Sub集成处理GCP IoT Core中的设备注册表和遥测数据。
  • 在Azure IoT Hub中管理设备身份和消息路由,包括直接方法调用。
  • 支持设备组管理功能,如批量更新、影子同步(AWS)和设备孪生(Azure)。
  • 查询设备状态,并跨平台使用MQTT或HTTPS协议处理安全连接。

Usage Patterns

使用模式

Always set environment variables for authentication first, e.g., export AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID. Use SDKs for programmatic access; for AWS, install boto3 and import it. Pattern: Initialize client, perform operation, handle response. For CLI, prefix commands with platform-specific tools like
aws iot
or
gcloud iot
.
Example 1: Create an AWS IoT thing using boto3:
python
import boto3
iot_client = boto3.client('iot')
response = iot_client.create_thing(thingName='MySensor')
print(response['thingArn'])
Example 2: Register a device on Azure IoT Hub using Azure CLI:
bash
az iot hub device-identity create --hub-name MyHub --device-id MyDevice --edge-enabled
az iot hub device-identity show --hub-name MyHub --device-id MyDevice
For GCP, use gcloud CLI in scripts: First, authenticate with
gcloud auth login
, then create devices. Common pattern: Use loops for bulk operations, e.g., in a Python script with subprocess.
首先务必设置用于身份验证的环境变量,例如export AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID。使用SDK进行程序化访问;对于AWS,安装boto3并导入它。模式:初始化客户端、执行操作、处理响应。对于CLI,使用平台特定工具作为命令前缀,如
aws iot
gcloud iot
示例1:使用boto3创建AWS IoT Thing:
python
import boto3
iot_client = boto3.client('iot')
response = iot_client.create_thing(thingName='MySensor')
print(response['thingArn'])
示例2:使用Azure CLI在Azure IoT Hub上注册设备:
bash
az iot hub device-identity create --hub-name MyHub --device-id MyDevice --edge-enabled
az iot hub device-identity show --hub-name MyHub --device-id MyDevice
对于GCP,在脚本中使用gcloud CLI:首先通过
gcloud auth login
进行身份验证,然后创建设备。常见模式:使用循环进行批量操作,例如在Python脚本中结合subprocess。

Common Commands/API

常用命令/API

For AWS IoT Core: Use AWS CLI or boto3 SDK. Command:
aws iot create-thing --thing-name Device1 --thing-type Sensor
. API endpoint: POST https://iot.us-east-1.amazonaws.com/things. Include flags like --attribute to add metadata, e.g.,
aws iot create-thing --thing-name Device1 --attribute '{"location": "office"}'
.
For GCP IoT Core: Use gcloud CLI. Command:
gcloud iot devices create Device1 --registry=MyRegistry --region=us-central1 --project=MyProject
. API endpoint: POST https://cloudiot.googleapis.com/v1/projects/{project}/locations/{location}/registries/{registry}/devices. Config format: JSON payload for device config, e.g., {"id": "Device1", "credentials": [{"publicKey": {"format": "RSA_X509_PEM", "key": "-----BEGIN CERTIFICATE-----"}}]}.
For Azure IoT Hub: Use az CLI. Command:
az iot hub device-identity create --hub-name MyHub --device-id Device1 --auth-method x509_ca
. API endpoint: POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{hubName}/IotHubDevices/{deviceId}. Use env var for keys: $AZURE_IOT_HUB_CONNECTION_STRING.
General pattern: Pass authentication via env vars, e.g., $GOOGLE_APPLICATION_CREDENTIALS for GCP JSON key file.
对于AWS IoT Core:使用AWS CLI或boto3 SDK。命令:
aws iot create-thing --thing-name Device1 --thing-type Sensor
。API端点:POST https://iot.us-east-1.amazonaws.com/things。可添加--attribute等标志来添加元数据,例如`aws iot create-thing --thing-name Device1 --attribute '{"location": "office"}'`。
对于GCP IoT Core:使用gcloud CLI。命令:
gcloud iot devices create Device1 --registry=MyRegistry --region=us-central1 --project=MyProject
。API端点:POST https://cloudiot.googleapis.com/v1/projects/{project}/locations/{location}/registries/{registry}/devices。配置格式:设备配置的JSON负载,例如{"id": "Device1", "credentials": [{"publicKey": {"format": "RSA_X509_PEM", "key": "-----BEGIN CERTIFICATE-----"}}]}。
对于Azure IoT Hub:使用az CLI。命令:
az iot hub device-identity create --hub-name MyHub --device-id Device1 --auth-method x509_ca
。API端点:POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{hubName}/IotHubDevices/{deviceId}。使用环境变量存储密钥:$AZURE_IOT_HUB_CONNECTION_STRING。
通用模式:通过环境变量传递身份验证信息,例如GCP的$GOOGLE_APPLICATION_CREDENTIALS(对应JSON密钥文件)。

Integration Notes

集成说明

Integrate by linking IoT services to other cloud components. For AWS, use AWS IoT Rules to route data to S3 or Lambda; configure via
aws iot create-topic-rule --rule-name MyRule --sql-version '2016-03-23' --sql "SELECT * FROM 'iot/topic'" --actions '{"lambda":{"functionArn":"arn:aws:lambda:region:account-id:function:function-name"}}'
. For GCP, connect to Pub/Sub: Use
gcloud pubsub topics create my-topic
and link in device registry. For Azure, integrate with Event Grid:
az eventgrid event-subscription create --name sub1 --source-resource-id /subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.Devices/IotHubs/{hub} --endpoint-type webhook --endpoint-url https://endpoint.com/api/updates
. Always validate schemas; use JSON for payloads. If using multiple platforms, manage credentials via a secrets manager like AWS Secrets Manager.
通过将IoT服务与其他云组件关联来实现集成。对于AWS,使用AWS IoT规则将数据路由到S3或Lambda;通过
aws iot create-topic-rule --rule-name MyRule --sql-version '2016-03-23' --sql "SELECT * FROM 'iot/topic'" --actions '{"lambda":{"functionArn":"arn:aws:lambda:region:account-id:function:function-name"}}'
进行配置。对于GCP,连接到Pub/Sub:使用
gcloud pubsub topics create my-topic
并在设备注册表中关联。对于Azure,与Event Grid集成:
az eventgrid event-subscription create --name sub1 --source-resource-id /subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.Devices/IotHubs/{hub} --endpoint-type webhook --endpoint-url https://endpoint.com/api/updates
。务必验证架构;使用JSON作为负载格式。如果使用多个平台,通过密钥管理器(如AWS Secrets Manager)管理凭据。

Error Handling

错误处理

Check for common errors like authentication failures (e.g., 403 Forbidden) by verifying env vars first, such as ensuring $AWS_SECRET_ACCESS_KEY is set. For AWS, catch ClientError in boto3:
python
try:
    iot_client.create_thing(thingName='Device1')
except iot_client.exceptions.ResourceAlreadyExistsException:
    print("Thing already exists; update instead.")
For GCP, handle via gcloud exit codes; check if command returns non-zero and retry with exponential backoff. Azure: Parse JSON error responses, e.g., if
az iot hub device-identity create
fails with "Conflict", use
az iot hub device-identity update
. Log errors with details like error codes (e.g., AWS: InvalidRequestException) and include retry logic for transient issues like network errors.
检查常见错误,例如身份验证失败(如403 Forbidden),首先验证环境变量,确保$AWS_SECRET_ACCESS_KEY已设置。对于AWS,在boto3中捕获ClientError:
python
try:
    iot_client.create_thing(thingName='Device1')
except iot_client.exceptions.ResourceAlreadyExistsException:
    print("Thing已存在;请改为更新操作。")
对于GCP,通过gcloud退出码处理;检查命令是否返回非零值,并使用指数退避策略重试。Azure:解析JSON错误响应,例如如果
az iot hub device-identity create
因“Conflict”失败,使用
az iot hub device-identity update
。记录包含错误代码(如AWS的InvalidRequestException)的详细错误信息,并为网络错误等临时问题添加重试逻辑。

Graph Relationships

关联关系

  • Part of cluster: iot
  • Tagged with: iot
  • Related to: Other skills in iot cluster for broader IoT ecosystems
  • 所属集群:iot
  • 标签:iot
  • 关联对象:iot集群中的其他Skill,用于构建更广泛的IoT生态系统