Skip to content

Commit

Permalink
Update migration guide and update SDK for Edge (#3167)
Browse files Browse the repository at this point in the history
  • Loading branch information
David R. Williamson authored Mar 16, 2023
1 parent 081e2c2 commit 62dfbb4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
15 changes: 13 additions & 2 deletions SDK v2 migration guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ The folllowing namespaces have been deprecated:
- `Microsoft.Azure.Devices.Shared`
- `Microsoft.Azure.Devices.Common.Exceptions`
- `Microsoft.Azure.Devices.Client.Exceptions`
- `Microsoft.Azure.Devices.Client.Transport.Mqtt`

### Consolidating IoT hub service clients

Expand Down Expand Up @@ -178,30 +179,34 @@ Find a client you currently use below, read the table of API name changes and us
| v1 API | Equivalent v2 API | Notes |
|:---|:---|:---|
| `DeviceClient` | `IotHubDeviceClient` | Specify the service it is a device client for. |
| `ITransportSettings` | `IotHubClientTransportSettings` | Disambiguate with other clients. |
| `IRetryPolicy` | `IIotHubClientRetryPolicy` | Disambiguate with other clients. |
| `DeviceClient.Dispose()` | `IotHubDeviceClient.DisposeAsync()` | Ensures the client is closed before disposing. |
| `DeviceClient.SendEventAsync(...)` | `IotHubDeviceClient.SendTelemetryAsync(TelemetryMessage, ...)` | Even our public documentation calls this telemetry, so we renamed the method to describe this better.¹ |
| `DeviceClient.SendEventBatchAsync(...)` | `IotHubDeviceClient.SendTelemetryAsync(IEnumerable<TelemetryMessage>, ...)` | This is now only supported over AMQP. Support over MQTT has been removed. Also, see¹. |
| `DeviceClient.SetConnectionStatusChangesHandler(...)` | `IotHubDeviceClient.ConnectionStatusChangeCallback` | Local operation doesn't require being a method. |
| `DeviceClient.SetReceiveMessageHandlerAsync(...)` | `IotHubDeviceClient.SetIncomingMessageCallbackAsync(...)` | Disambiguate from telemetry messages. |
| `SetMethodDefaultHandlerAsync` | `SetDirectMethodCallbackAsync` | Use full name of the operation type.⁴ |
| `SetMethodHandlerAsync` | Deprecated. | Handler by method name is deprecated. Use `SetDirectMethodCallbackAsync` and filter by method name in the callback. |
| `DeviceClient.GetTwinAsync(...)` | `IotHubDeviceClient.GetTwinPropertiesAsync(...)` | The device client doesn't get the full twin, just the properties so this helps avoid that confusion.² |
| `Twin` | `TwinProperties` | See² |
| `Twin.Properties.Desired` | `TwinProperties.Desired` | See² |
| `Twin.Properties.Reported` | `TwinProperties.Reported` | See² |
| `MessageResponse` | `MessageAcknowledgement` | It isn't a full response, just a simple acknowledgement. |
| `MessageResponse.Completed` | `MessageAcknowledgement.Complete` | Use imperative tense for acknowledgements. |
| `Message` | `TelemetryMessage`, `IncomingMessage` | Distinguished between the different messaging operations. |
| `DeviceClient.SetRetryPolicy(...)` | `IotHubClientOptions.RetryPolicy` | Should be specified at initialization time, and putting it in the client options object reduces the client API surface. |
| `ExponentialBackOff` | `IotHubClientExponentialBackOffRetryPolicy` | Clarify it is a retry policy. |
| `Message.CreationTimeUtc` | `TelemetryMessage.CreatedOnUtc`, `IncomingMessage.CreatedOnUtc` | Conforming to the naming guidelines by the Azure SDK team, where DateTime/Offset types have an "On" suffix (and "Utc" suffix when explicitly in UTC).³ |
| `Message.EnqueuedTimeUtc` | `TelemetryMessage.EnqueuedtimeUtc`, `IncomingMessage.EnqueuedTimeUtc` | See³ |
| `Message.ExpiryTimeUtc` | `TelemetryMessage.ExpiresOnUtc`, `IncomingMessage.ExpiresOnUtc` | See³ |
| `MethodRequest` | `DirectMethodRequest` | Use full name of the operation type.|
| `MethodRequest` | `DirectMethodRequest` | See|
| `MethodResponse` | `DirectMethodResponse` | See⁴ |
| `IotHubException` | `IotHubClientException` | Specify the exception is for Hub device and module client only. |
| `DeviceAuthenticationWithTokenRefresh` and `ModuleAuthenticationWithTokenRefresh` | `ClientAuthenticationWithTokenRefresh` | More descriptive naming and reduce duplication.⁵ |
| `DeviceAuthenticationWithToken` and `ModuleAuthenticationWithToken` | `ClientAuthenticationWithSharedAccessSignature` | See⁵ |
| `DeviceAuthenticationWithSakRefresh` and `ModuleAuthenticationWithSakRefresh` | `ClientAuthenticationWithSharedAccessKeyRefresh` | See⁵ |
| `AuthenticationWithTokenRefresh.SafeCreateNewToken(...)` and derived classes | `ClientAuthenticationWithTokenRefresh.SafeCreateNewTokenAsync(...)` and derived classes. | Async suffix for async methods. |
| `RetryPolicyBase` | `IIotHubClientRetryPolicy` | Introducing an interface for client retry policy. |

#### ModuleClient

Expand All @@ -211,6 +216,8 @@ The device client and module client share a lot of API surface and underlying im

| v1 API | Equivalent v2 API | Notes |
|:---|:---|:---|
| `SetMessageHandlerAsync` | `SetIncomingMessageCallbackAsync` | Renamed to be more descriptive about the callback being set. |
| `SetInputMessageHandlerAsync` | `SetIncomingMessageCallbackAsync` | The input parameter is deprecated; the callback can observe and filter using the `IncomingMessage.InputName` property. |
| `ModuleClient.SendEventAsync(string outputName, ...)` | `IotHubModuleClient.SendMessageToRouteAsync(string outputName, ...)` | Change the name to be more descriptive about sending messages between Edge modules.¹ |
| `ModuleClient.SendEventBatchAsync(string outputName, ...)` | `IotHubModuleClient.SendMessagesToRouteAsync(string outputName, ...)` | See¹ |

Expand All @@ -229,6 +236,10 @@ N/A
This service client has probably seen more updates than any other client library in this v2.
What was a loose affiliation of separate clients is now a consolidated client with organized subclients by operation type.

#### Non-client specific changes

- `IotHubConnectionStringBuilder` has been removed. It was not required as part of any API calls and was intended to be internal.

#### Exception changes

These span across all service clients.
Expand Down
10 changes: 8 additions & 2 deletions iothub/device/src/ConnectionStatusInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,19 @@ namespace Microsoft.Azure.Devices.Client
/// </summary>
public class ConnectionStatusInfo
{
internal ConnectionStatusInfo()
/// <summary>
/// Generally only created by the SDK or for unit testing, using defaults of disconnected and client closed.
/// </summary>
public ConnectionStatusInfo()
: this(ConnectionStatus.Disconnected, ConnectionStatusChangeReason.ClientClosed)
{
RecommendedAction = RecommendedAction.OpenConnection;
}

internal ConnectionStatusInfo(ConnectionStatus status, ConnectionStatusChangeReason changeReason)
/// <summary>
/// Generally only created by the SDK or for unit testing.
/// </summary>
public ConnectionStatusInfo(ConnectionStatus status, ConnectionStatusChangeReason changeReason)
{
Status = status;
ChangeReason = changeReason;
Expand Down

0 comments on commit 62dfbb4

Please sign in to comment.