Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update SDK v2 migration guide.md #2889

Merged
merged 13 commits into from
Oct 18, 2022
27 changes: 21 additions & 6 deletions SDK v2 migration guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,31 @@ are outlines of the notable breaking changes as well as a mapping from version 1
- [IoT hub service client](#iot-hub-service-client)
- [Device Provisioning Service (DPS) device client](#dps-device-client)
- [DPS service client](#dps-service-client)
- [Security provider client](#authentication-provider-client)
- [Security provider client](#security-provider-client)
- [Frequently asked questions](#frequently-asked-questions)

## Why the version 1 SDK is being replaced

There are a number of reasons why the Azure IoT SDK team chose to do a major version revision. Here are a few of the more important reasons:
- Removing or upgrading several NuGet dependencies (TODO: list).
- Consolidate IoT hub service clients and rename to reflect the items or operations they support.
- Removing or upgrading several NuGet dependencies.
- Upgraded
- Microsoft.Azure.Devices.Client
- Microsoft.Azure.Devices
- Microsoft.Azure.Devices.Authentication
schoims marked this conversation as resolved.
Show resolved Hide resolved
- Microsoft.Azure.Devices.Provisioning.Client
- Microsoft.Azure.Devices.Provisioning.Service
- Removed
- Microsoft.Azure.Devices.Shared
- Microsoft.Azure.Devices.Provisioning.Transport.Amqp
- Microsoft.Azure.Devices.Provisioning.Transport.Http
- Microsoft.Azure.Devices.Provisioning.Transport.Mqtt
- Microsoft.Azure.Devices.Provisioning.Security.Tpm
- Consolidating IoT hub service clients and renaming to reflect the items or operations they support.
- Many existing client classes (RegistryManager, ServiceClient, etc.) were confusingly named and contained methods that weren't always consistent with the client's assumed responsibilities.
- Many existing clients had a mix of standard constructors (`new DeviceClient(...)`) and static builder methods (`DeviceClient.CreateFromConnectionString(...)`) that caused some confusion among users. The factory methods have been removed and the addition of constructors in clients enables unit testing.
- Exception handling.
- Exception handling in the v1 SDK required multiple exception types to be caught. This logic has been consolidated to always throw `IotHubClientException` and `IotHubServiceException` for exceptions arising from communication attempts with IoT Hub, `DeviceProvisioningClientException` and `DeviceProvisioningServiceException` for exceptions arising from communication attempts with DPS. Parameter validation will throw `ArgumentException`/`ArgumentNullException`/`FormatException`/`InvalidOperationException`.
schoims marked this conversation as resolved.
Show resolved Hide resolved
schoims marked this conversation as resolved.
Show resolved Hide resolved
- `RecommendedAction` in connection status handling.

## What will happen to the version 1 SDK

Expand Down Expand Up @@ -96,7 +111,7 @@ but users are still encouraged to migrate to version 2 when they have the chance

| Version 1 API | Equivalent version 2 API |
|:---|:---|
| `RegistryManager` | `IotHubServiceClient`, subclients `Devices`, `Twins`, `Configurations`, etc. |
| `RegistryManager` | `IotHubServiceClient`, `subclients`, `Devices`, `Twins`, `Configurations`, etc. |
schoims marked this conversation as resolved.
Show resolved Hide resolved
| `RegistryManager.AddDeviceAsync(Device, ...)` | `IotHubServiceClient.Devices.CreateAsync(Device, ...)` |
| `RegistryManager.AddDevices2Async(...)` | `IotHubServiceClient.Devices.CreateAsync(IEnumerable<Device>,...)` |
| `RegistryManager.RemoveDeviceAsync(...)` | `IotHubServiceClient.Devices.DeleteAsync(...)` |
Expand Down Expand Up @@ -254,7 +269,7 @@ but users are still encouraged to migrate to version 2 when they have the chance
- Query methods (like for individual and group enrollments) now take a query string (and optionally a page size parameter), and the `Query` result no longer requires disposing.
- ETag fields on the classes `IndividualEnrollment`, `EnrollmentGroup`, and `DeviceRegistrationState` are now taken as the `Azure.ETag` type instead of strings.

### Security provider clients
### Security provider client

Breaking changes:

Expand Down Expand Up @@ -323,4 +338,4 @@ Question:
> Is the version 2 library backwards compatible?

Answer:
> No. Please refer to [Semver rules](https://semver.org/) and see above in the [Migration guide](#migration-guide).
> No. Please refer to [Semver rules](https://semver.org/) and see above in the [Migration guide](#migration-guide).