了解和使用 Azure IoT 中心 SDKUnderstand and use Azure IoT Hub SDKs
有两种类别的软件开发工具包 (SDK) 适用于 IoT 中心:There are two categories of software development kits (SDKs) for working with IoT Hub:
IoT 中心设备 SDK:可用于使用设备客户端或模块客户端构建在 IoT 设备上运行的应用。IoT Hub Device SDKs enable you to build apps that run on your IoT devices using device client or module client. 这些应用将遥测发送到 IoT 中心,并可以选择从 IoT 中心接收消息、作业、方法或孪生更新。These apps send telemetry to your IoT hub, and optionally receive messages, job, method, or twin updates from your IoT hub. 还可以使用模块客户端为 Azure IoT Edge 运行时创建模块。You can also use module client to author modules for Azure IoT Edge runtime.
IoT 中心服务 SDK:可用于构建后端应用程序来管理 IoT 中心,并视需要发送消息、计划作业、调用直接方法或向 IoT 设备或模块发送相应属性更新。IoT Hub Service SDKs enable you to build backend applications to manage your IoT hub, and optionally send messages, schedule jobs, invoke direct methods, or send desired property updates to your IoT devices or modules.
此外,我们还提供了一组 SDK 来处理设备预配服务。In addition, we also provide a set of SDKs for working with the Device Provisioning Service.
预配设备 SDK:可用于构建在 IoT 设备上运行的与设备预配服务进行通信的应用。Provisioning Device SDKs enable you to build apps that run on your IoT devices to communicate with the Device Provisioning Service.
预配服务 SDK:可用于构建后端应用程序来管理设备预配服务中的注册。Provisioning Service SDKs enable you to build backend applications to manage your enrollments in the Device Provisioning Service.
了解使用 Azure IoT SDK 执行开发的益处。Learn about the benefits of developing using Azure IoT SDKs.
备注
本文中提到的某些功能(例如云到设备消息传递、设备孪生、设备管理)仅在 IoT 中心的标准层中提供。Some of the features mentioned in this article, like cloud-to-device messaging, device twins, and device management, are only available in the standard tier of IoT hub. 有关基本和标准 IoT 中心层的详细信息,请参阅如何选择合适的 IoT 中心层。For more information about the basic and standard IoT Hub tiers, see How to choose the right IoT Hub tier.
操作系统平台和硬件兼容性OS platform and hardware compatibility
可以在 Azure IoT SDK 平台支持中找到支持的 SDK 平台。Supported platforms for the SDKs can be found in Azure IoT SDKs Platform Support.
Azure IoT 中心设备 SDKAzure IoT Hub Device SDKs
Microsoft Azure IoT 设备 SDK 包含的代码可帮助构建连接到 Azure IoT 中心服务并由这些服务管理的应用程序。The Microsoft Azure IoT device SDKs contain code that facilitates building applications that connect to and are managed by Azure IoT Hub services.
适用于 .NET 的 Azure IoT 中心设备 SDK:Azure IoT Hub device SDK for .NET:
- 通过 Nuget 下载。Download from Nuget. 命名空间是 Microsoft.Azure.Devices.Clients,其中包含 IoT 中心设备客户端(DeviceClient、ModuleClient)。The namespace is Microsoft.Azure.Devices.Clients, which contains IoT Hub Device Clients (DeviceClient, ModuleClient).
- 源代码Source code
- API 参考API reference
- 模块参考Module reference
适用于 Embedded C 的 Azure IoT 中心设备 SDK (ANSI C - C99):Azure IoT Hub device SDK for Embedded C (ANSI C - C99):
- 构建 Embedded C SDKBuild the Embedded C SDK
- 源代码Source code
- 受约束设备的大小图表。Size chart for constrained devices.
- API 参考API reference
适用于 C 的 Azure IoT 中心设备 SDK (ANSI C - C99):Azure IoT Hub device SDK for C (ANSI C - C99):
- 通过 apt-get、MBED、Arduino IDE 或 iOS 进行安装Install from apt-get, MBED, Arduino IDE or iOS
- 源代码Source code
- 编译 C 设备 SDKCompile the C Device SDK
- API 参考API reference
- 模块参考Module reference
- 将 C SDK 移植到其他平台Porting the C SDK to other platforms
- 开发人员文档,包含交叉编译以及在不同的平台上开始等信息。Developer documentation for information on cross-compiling, getting started on different platforms, etc.
- Azure IoT 中心 C SDK 资源消耗信息Azure IoT Hub C SDK resource consumption information
适用于 Java 的 Azure IoT 中心设备 SDK:Azure IoT Hub device SDK for Java:
- 添加到 Maven 项目Add to Maven project
- 源代码Source code
- API 参考API reference
- 模块参考Module reference
适用于 Node.js 的 Azure IoT 中心设备 SDK:Azure IoT Hub device SDK for Node.js:
- 通过 npm 安装Install from npm
- 源代码Source code
- API 参考API reference
- 模块参考Module reference
适用于 Python 的 Azure IoT 中心设备 SDK:Azure IoT Hub device SDK for Python:
- 通过 pip 安装Install from pip
- 源代码Source code
- API 参考API reference
适用于 iOS 的 Azure IoT 中心设备 SDK:Azure IoT Hub device SDK for iOS:
- 通过 CocoaPod 安装Install from CocoaPod
- 示例Samples
- API 参考:请参阅 C API 参考API reference: see C API reference
Azure IoT 中心服务 SDKAzure IoT Hub Service SDKs
Azure IoT 服务 SDK 包含的代码可帮助生成直接与 IoT 中心进行交互以管理设备和安全性的应用程序。The Azure IoT service SDKs contain code to facilitate building applications that interact directly with IoT Hub to manage devices and security.
适用于 .NET 的 Azure IoT 中心服务 SDK:Azure IoT Hub service SDK for .NET:
- 通过 Nuget 下载。Download from Nuget. 命名空间是 Microsoft.Azure.Devices,其中包含 IoT 中心服务客户端(RegistryManager、ServiceClients)。The namespace is Microsoft.Azure.Devices, which contains IoT Hub Service Clients (RegistryManager, ServiceClients).
- 源代码Source code
- API 参考API reference
适用于 Java 的 Azure IoT 中心服务 SDK:Azure IoT Hub service SDK for Java:
- 添加到 Maven 项目Add to Maven project
- 源代码Source code
- API 参考API reference
适用于 Node.js 的 Azure IoT 中心服务 SDK:Azure IoT Hub service SDK for Node.js:
- 通过 npm 下载Download from npm
- 源代码Source code
- API 参考API reference
适用于 Python 的 Azure IoT 中心服务 SDK:Azure IoT Hub service SDK for Python:
- 通过 pip 下载Download from pip
- 源代码Source code
- API 参考API reference
适用于 C 的 Azure IoT 中心服务 SDK:Azure IoT Hub service SDK for C:
适用于 C 的 Azure IoT 服务 SDK 不再处于活动开发状态。The Azure IoT Service SDK for C is no longer under active development. 我们将持续解决崩溃、数据损坏、安全漏洞等严重 bug。We will continue to fix critical bugs such as crashes, data corruption, and security vulnerabilities. 但我们不会添加任何新功能,也不会修复不严重的 bug。We will NOT add any new feature or fix bugs that are not critical, however.
在更高级别的语言(C#、Java、Node、Python)中可使用 Azure IoT 服务 SDK 支持。Azure IoT Service SDK support is available in higher-level languages (C#, Java, Node, Python).
- 通过 apt-get、MBED、Arduino IDE 或 Nuget 下载Download from apt-get, MBED, Arduino IDE, or Nuget
- 源代码Source code
适用于 iOS 的 Azure IoT 中心服务 SDK:Azure IoT Hub service SDK for iOS:
备注
有关使用语言和平台特定的程序包管理器在开发计算机上安装二进制文件和依赖项的信息,请参阅 GitHub 存储库中的自述文件。See the readme files in the GitHub repositories for information about using language and platform-specific package managers to install binaries and dependencies on your development machine.
Microsoft Azure 预配 SDKMicrosoft Azure Provisioning SDKs
Microsoft Azure 预配 SDK 使你可以使用 设备预配服务将设备预配到 IoT 中心。The Microsoft Azure Provisioning SDKs enable you to provision devices to your IoT Hub using the Device Provisioning Service.
适用于 C# 的 Azure 预配设备和服务 SDK:Azure Provisioning device and service SDKs for C#:
- 通过 NuGet 下载设备 SDK 和服务 SDK。Download from Device SDK and Service SDK from NuGet.
- 源代码Source code
- API 参考API reference
适用于 C 的 Azure 预配设备和服务 SDK:Azure Provisioning device and service SDKs for C:
- 通过 apt-get、MBED、Arduino IDE 或 iOS 进行安装Install from apt-get, MBED, Arduino IDE or iOS
- 源代码Source code
- API 参考API reference
适用于 Java 的 Azure 预配设备和服务 SDK:Azure Provisioning device and service SDKs for Java:
- 添加到 Maven 项目Add to Maven project
- 源代码Source code
- API 参考API reference
适用于 Node.js 的 Azure 预配设备和服务 SDK:Azure Provisioning device and service SDKs for Node.js:
- 源代码Source code
- API 参考API reference
- 通过 npm 下载设备 SDK 和服务 SDKDownload Device SDK and Service SDK from npm
适用于 Python 的 Azure 预配设备和服务 SDK:Azure Provisioning device and service SDKs for Python:
- 源代码Source code
- 通过 pip 下载设备 SDK 和服务 SDKDownload Device SDK and Service SDK from pip
后续步骤Next steps
Azure IoT SDK 还提供了一组工具来帮助开发:Azure IoT SDKs also provide a set of tools to help with development:
- iothub-diagnostics:一种跨平台命令行工具,用于帮助诊断与 IoT 中心连接相关的问题。iothub-diagnostics: a cross-platform command line tool to help diagnose issues related to connection with IoT Hub.
- azure-iot-explorer:一个跨平台的桌面应用程序,用于连接到 IoT 中心并添加/管理 IoT 设备及与其通信。azure-iot-explorer: a cross-platform desktop application to connect to your IoT Hub and add/manage/communicate with IoT devices.
与使用 Azure IoT SDK 进行开发相关的文档:Relevant docs related to development using the Azure IoT SDKs:
- 了解如何使用 IoT 中心 SDK 管理连接和可靠的消息传送。Learn about how to manage connectivity and reliable messaging using the IoT Hub SDKs.
- 了解如何针对移动平台进行开发,例如 iOS 和 Android。Learn about how to develop for mobile platforms such as iOS and Android.
- Azure IoT SDK 平台支持Azure IoT SDK platform support
此 IoT 中心开发人员指南中的其他参考主题包括:Other reference topics in this IoT Hub developer guide include: