-
Notifications
You must be signed in to change notification settings - Fork 496
Open
Labels
bugSomething isn't working.Something isn't working.
Description
Context
- OS, version, SKU and CPU architecture used: Azure Function Dotnet isolated Windows
- Application's .NET Target Framework : net8.0
- Device: N/A
- SDK version used:
Description of the issue
RegistryManager.GetDeviceAsync (string deviceId) returns a null if device is not found.
Per Code Expected DeviceNotFoundException
{
if (Logging.IsEnabled)
Logging.Enter(this, $"Getting device: {deviceId}", nameof(GetDeviceAsync));
try
{
if (string.IsNullOrWhiteSpace(deviceId))
{
throw new ArgumentException(IotHubApiResources.GetString(ApiResources.ParameterCannotBeNullOrWhitespace, "deviceId"));
}
EnsureInstanceNotClosed();
var errorMappingOverrides = new Dictionary<HttpStatusCode, Func<HttpResponseMessage, Task<Exception>>>()
{
{ HttpStatusCode.NotFound, async responseMessage => new DeviceNotFoundException(await ExceptionHandlingHelper.GetExceptionMessageAsync(responseMessage).ConfigureAwait(false)) }
};
return _httpClientHelper.GetAsync<Device>(GetRequestUri(deviceId), errorMappingOverrides, null, false, cancellationToken);
Code sample exhibiting the issue
[Fact]
public async Task TestRegistryManager()
{
var registry = RegistryManager.CreateFromConnectionString(connectionString);
await Assert.ThrowsAsync<DeviceNotFoundException>(async () => await registry.GetDeviceAsync("IDoNoTExist") );
}
Console log of the issue
Follow the instructions here to capture SDK logs.
Don't forget to remove any connection string information!
Metadata
Metadata
Assignees
Labels
bugSomething isn't working.Something isn't working.