diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index 446177481b..bd324605f8 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -1,3 +1,3 @@
# Track1 .NET Azure IoT Hub and DPS SDKs
-* @timtay-microsoft @abhipsaMisra @brycewang-microsoft @tmahmood-microsoft @patilsnr
+* @timtay-microsoft @lev-i @olivakar @avishekpant
diff --git a/e2e/test/E2ETests.csproj b/e2e/test/E2ETests.csproj
index 505f0aa1e8..95cc47ae5c 100644
--- a/e2e/test/E2ETests.csproj
+++ b/e2e/test/E2ETests.csproj
@@ -40,6 +40,7 @@
+
diff --git a/iothub/device/samples/getting started/FileUploadSample/FileUploadSample.csproj b/iothub/device/samples/getting started/FileUploadSample/FileUploadSample.csproj
index 2621440c1f..aed1f4e7d6 100644
--- a/iothub/device/samples/getting started/FileUploadSample/FileUploadSample.csproj
+++ b/iothub/device/samples/getting started/FileUploadSample/FileUploadSample.csproj
@@ -7,7 +7,7 @@
-
+
diff --git a/iothub/device/samples/getting started/MethodSample/MethodSample.csproj b/iothub/device/samples/getting started/MethodSample/MethodSample.csproj
index 7cb0a69c4c..5e306d239e 100644
--- a/iothub/device/samples/getting started/MethodSample/MethodSample.csproj
+++ b/iothub/device/samples/getting started/MethodSample/MethodSample.csproj
@@ -8,7 +8,7 @@
-
+
diff --git a/iothub/device/samples/getting started/SimulatedDevice/SimulatedDevice.csproj b/iothub/device/samples/getting started/SimulatedDevice/SimulatedDevice.csproj
index 203cd57782..f6151a0414 100644
--- a/iothub/device/samples/getting started/SimulatedDevice/SimulatedDevice.csproj
+++ b/iothub/device/samples/getting started/SimulatedDevice/SimulatedDevice.csproj
@@ -8,7 +8,7 @@
-
+
diff --git a/iothub/device/samples/getting started/SimulatedDeviceWithCommand/SimulatedDeviceWithCommand.csproj b/iothub/device/samples/getting started/SimulatedDeviceWithCommand/SimulatedDeviceWithCommand.csproj
index 203cd57782..f6151a0414 100644
--- a/iothub/device/samples/getting started/SimulatedDeviceWithCommand/SimulatedDeviceWithCommand.csproj
+++ b/iothub/device/samples/getting started/SimulatedDeviceWithCommand/SimulatedDeviceWithCommand.csproj
@@ -8,7 +8,7 @@
-
+
diff --git a/iothub/device/samples/how to guides/DeviceReconnectionSample/DeviceReconnectionSample.csproj b/iothub/device/samples/how to guides/DeviceReconnectionSample/DeviceReconnectionSample.csproj
index 4932b1e395..88b40e14c4 100644
--- a/iothub/device/samples/how to guides/DeviceReconnectionSample/DeviceReconnectionSample.csproj
+++ b/iothub/device/samples/how to guides/DeviceReconnectionSample/DeviceReconnectionSample.csproj
@@ -9,7 +9,9 @@
+
+
diff --git a/iothub/device/samples/solutions/PnpDeviceSamples/PnpConvention/PnpConventionTests.cs b/iothub/device/samples/solutions/PnpDeviceSamples/PnpConvention/PnpConventionTests.cs
deleted file mode 100644
index 7118367b2b..0000000000
--- a/iothub/device/samples/solutions/PnpDeviceSamples/PnpConvention/PnpConventionTests.cs
+++ /dev/null
@@ -1,164 +0,0 @@
-// Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-
-using FluentAssertions;
-using Microsoft.Azure.Devices.Shared;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Newtonsoft.Json;
-using Newtonsoft.Json.Linq;
-
-namespace PnpHelpers
-{
- class PnpConventionTests
- {
- ///
- /// Ensures the PnP convention helpers produce content to spec and using different data types
- ///
- [TestClass]
- [TestCategory("Unit")]
- public class PnpHelperTests
- {
- [TestMethod]
- public void CreateRootPropertyPatch()
- {
- // Format:
- // {
- // "samplePropertyName": 20
- // }
-
- const string propertyName = "someName";
- const int propertyValue = 10;
-
- TwinCollection patch = PnpConvention.CreatePropertyPatch(propertyName, propertyValue);
- var jObject = JObject.Parse(patch.ToJson());
-
- jObject.Count.Should().Be(1, "there should be a single property added");
- jObject.Value(propertyName).Should().Be(propertyValue);
- }
-
- [TestMethod]
- public void CreateComponentPropertyPatch()
- {
- // Format:
- // {
- // "sampleComponentName": {
- // "__t": "c",
- // "samplePropertyName"": 20
- // }
- // }
-
- const string componentName = "someComponent";
- const string propertyName = "someName";
- const int propertyValue = 10;
-
- TwinCollection patch = PnpConvention.CreateComponentPropertyPatch(componentName, propertyName, propertyValue);
-
- var jObject = JObject.Parse(patch.ToJson());
- JObject component = jObject.Value(componentName);
-
- component.Count.Should().Be(2, "there should be two properties added - the above property and a component identifier {\"__t\": \"c\"}");
- component.Value(propertyName).Should().Be(propertyValue);
- component[PnpConvention.PropertyComponentIdentifierKey].Should().NotBeNull();
- ((string)component[PnpConvention.PropertyComponentIdentifierKey]).Should().Be(PnpConvention.PropertyComponentIdentifierValue);
- }
-
- [TestMethod]
- public void CreateRootPropertyEmbeddedValuePatch()
- {
- // Format:
- // {
- // "samplePropertyName": {
- // "value": 20,
- // "ac": 200,
- // "av": 5,
- // "ad": "The update was successful."
- // }
- // }
-
- const string propertyName = "someName";
- const int propertyValue = 10;
- const int ackCode = 200;
- const long ackVersion = 2;
-
- TwinCollection patch = PnpConvention.CreateWritablePropertyResponse(propertyName, propertyValue, ackCode, ackVersion);
-
- var jObject = JObject.Parse(patch.ToJson());
- EmbeddedPropertyPatch actualPatch = jObject.ToObject();
-
- // The property patch object should have "value", "ac" and "av" properties set. Since we did not supply an "ackDescription", "ad" should be null.
- actualPatch.Value.SerializedValue.Should().Be(JsonConvert.SerializeObject(propertyValue));
- actualPatch.Value.AckCode.Should().Be(ackCode);
- actualPatch.Value.AckVersion.Should().Be(ackVersion);
- actualPatch.Value.AckDescription.Should().BeNull();
- }
-
- [TestMethod]
- public void CreateComponentPropertyEmbeddedValuePatch()
- {
- // Format:
- // {
- // "sampleComponentName": {
- // "__t": "c",
- // "samplePropertyName": {
- // "value": 20,
- // "ac": 200,
- // "av": 5,
- // "ad": "The update was successful."
- // }
- // }
- // }
-
- const string componentName = "someComponentName";
- const string propertyName = "someName";
- const int propertyValue = 10;
- const int ackCode = 200;
- const long ackVersion = 2;
- const string ackDescription = "The update was successful";
-
- TwinCollection patch = PnpConvention.CreateComponentWritablePropertyResponse(
- componentName,
- propertyName,
- JsonConvert.SerializeObject(propertyValue),
- ackCode,
- ackVersion,
- ackDescription);
-
- var jObject = JObject.Parse(patch.ToJson());
- JObject component = jObject.Value(componentName);
-
- // There should be two properties added to the component- the above property and a component identifier "__t": "c".
- component.Count.Should().Be(2);
- component[PnpConvention.PropertyComponentIdentifierKey].Should().NotBeNull();
- ((string)component[PnpConvention.PropertyComponentIdentifierKey]).Should().Be(PnpConvention.PropertyComponentIdentifierValue);
-
- // The property patch object should have "value", "ac", "av" and "ad" properties set.
- EmbeddedPropertyPatch actualPatch = component.ToObject();
- actualPatch.Value.SerializedValue.Should().Be(JsonConvert.SerializeObject(propertyValue));
- actualPatch.Value.AckCode.Should().Be(ackCode);
- actualPatch.Value.AckVersion.Should().Be(ackVersion);
- actualPatch.Value.AckDescription.Should().Be(ackDescription);
- }
- }
-
- internal class EmbeddedPropertyPatch
- {
- [JsonProperty("someName")]
- internal EmbeddedPropertyPatchValue Value { get; set; }
- }
-
- internal class EmbeddedPropertyPatchValue
- {
- [JsonProperty("value")]
- internal string SerializedValue { get; set; }
-
- [JsonProperty("ac")]
- internal int AckCode { get; set; }
-
- [JsonProperty("av")]
- internal long AckVersion { get; set; }
-
- [JsonProperty("ad")]
- internal string AckDescription { get; set; }
- }
- }
-}
\ No newline at end of file
diff --git a/iothub/device/samples/solutions/PnpDeviceSamples/PnpConvention/PnpHelpers.csproj b/iothub/device/samples/solutions/PnpDeviceSamples/PnpConvention/PnpHelpers.csproj
index 6fc57db9c9..ec4614c2fb 100644
--- a/iothub/device/samples/solutions/PnpDeviceSamples/PnpConvention/PnpHelpers.csproj
+++ b/iothub/device/samples/solutions/PnpDeviceSamples/PnpConvention/PnpHelpers.csproj
@@ -2,18 +2,10 @@
net6.0
- True
9.0
False
-
-
-
-
-
-
-
diff --git a/iothub/device/samples/solutions/PnpDeviceSamples/TemperatureController/TemperatureController.csproj b/iothub/device/samples/solutions/PnpDeviceSamples/TemperatureController/TemperatureController.csproj
index f09ee74a83..158ed6cc2c 100644
--- a/iothub/device/samples/solutions/PnpDeviceSamples/TemperatureController/TemperatureController.csproj
+++ b/iothub/device/samples/solutions/PnpDeviceSamples/TemperatureController/TemperatureController.csproj
@@ -10,6 +10,7 @@
+
diff --git a/iothub/device/samples/solutions/PnpDeviceSamples/Thermostat/Thermostat.csproj b/iothub/device/samples/solutions/PnpDeviceSamples/Thermostat/Thermostat.csproj
index 235b844b87..c5e2d07262 100644
--- a/iothub/device/samples/solutions/PnpDeviceSamples/Thermostat/Thermostat.csproj
+++ b/iothub/device/samples/solutions/PnpDeviceSamples/Thermostat/Thermostat.csproj
@@ -11,6 +11,7 @@
+
diff --git a/iothub/device/src/Microsoft.Azure.Devices.Client.csproj b/iothub/device/src/Microsoft.Azure.Devices.Client.csproj
index 8044b4e824..0ae56aa9a4 100644
--- a/iothub/device/src/Microsoft.Azure.Devices.Client.csproj
+++ b/iothub/device/src/Microsoft.Azure.Devices.Client.csproj
@@ -96,9 +96,9 @@
-
-
-
+
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
@@ -111,7 +111,7 @@
-
+
diff --git a/iothub/device/src/Transport/AmqpIot/AmqpIotSendingLink.cs b/iothub/device/src/Transport/AmqpIot/AmqpIotSendingLink.cs
index cd9f3de5ba..5dac3f2295 100644
--- a/iothub/device/src/Transport/AmqpIot/AmqpIotSendingLink.cs
+++ b/iothub/device/src/Transport/AmqpIot/AmqpIotSendingLink.cs
@@ -94,7 +94,9 @@ internal async Task SendMessagesAsync(IEnumerable messa
foreach (Message message in messages)
{
+#pragma warning disable CA2000 // Dispose objects before losing scope
using AmqpMessage amqpMessage = AmqpIotMessageConverter.MessageToAmqpMessage(message);
+#pragma warning restore CA2000 // Dispose objects before losing scope
var data = new Data
{
Value = AmqpIotMessageConverter.ReadStream(amqpMessage.ToStream()),
diff --git a/iothub/device/src/Transport/Mqtt/MqttIotHubAdapter.cs b/iothub/device/src/Transport/Mqtt/MqttIotHubAdapter.cs
index 4e35a17e29..62ea68bcc5 100644
--- a/iothub/device/src/Transport/Mqtt/MqttIotHubAdapter.cs
+++ b/iothub/device/src/Transport/Mqtt/MqttIotHubAdapter.cs
@@ -23,7 +23,9 @@
using Microsoft.Azure.Devices.Shared;
#if NET5_0_OR_GREATER
+
using TaskCompletionSource = System.Threading.Tasks.TaskCompletionSource;
+
#else
using TaskCompletionSource = Microsoft.Azure.Devices.Shared.TaskCompletionSource;
#endif
@@ -1108,7 +1110,7 @@ private static IByteBuffer GetWillMessageBody(Message message)
{
Stream bodyStream = message.GetBodyStream();
byte[] buffer = new byte[bodyStream.Length];
- bodyStream.Read(buffer, 0, buffer.Length);
+ _ = bodyStream.Read(buffer, 0, buffer.Length);
IByteBuffer copiedBuffer = Unpooled.CopiedBuffer(buffer);
return copiedBuffer;
}
diff --git a/iothub/device/tests/Microsoft.Azure.Devices.Client.Tests.csproj b/iothub/device/tests/Microsoft.Azure.Devices.Client.Tests.csproj
index 2333b7375e..e25182fece 100644
--- a/iothub/device/tests/Microsoft.Azure.Devices.Client.Tests.csproj
+++ b/iothub/device/tests/Microsoft.Azure.Devices.Client.Tests.csproj
@@ -27,13 +27,13 @@
-
-
-
-
-
+
+
+
+
+
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/iothub/service/samples/getting started/EdgeDeploymentSample/EdgeDeploymentSample.csproj b/iothub/service/samples/getting started/EdgeDeploymentSample/EdgeDeploymentSample.csproj
index 648800d6cd..d85e318b87 100644
--- a/iothub/service/samples/getting started/EdgeDeploymentSample/EdgeDeploymentSample.csproj
+++ b/iothub/service/samples/getting started/EdgeDeploymentSample/EdgeDeploymentSample.csproj
@@ -8,7 +8,7 @@
-
+
diff --git a/iothub/service/samples/getting started/FileUploadNotificationReceiverSample/FileUploadNotificationReceiverSample.csproj b/iothub/service/samples/getting started/FileUploadNotificationReceiverSample/FileUploadNotificationReceiverSample.csproj
index e6eed95ea6..eda9caece2 100644
--- a/iothub/service/samples/getting started/FileUploadNotificationReceiverSample/FileUploadNotificationReceiverSample.csproj
+++ b/iothub/service/samples/getting started/FileUploadNotificationReceiverSample/FileUploadNotificationReceiverSample.csproj
@@ -8,7 +8,8 @@
-
+
+
diff --git a/iothub/service/samples/getting started/InvokeDeviceMethod/InvokeDeviceMethod.csproj b/iothub/service/samples/getting started/InvokeDeviceMethod/InvokeDeviceMethod.csproj
index 209e2768a0..2de1cb7e32 100644
--- a/iothub/service/samples/getting started/InvokeDeviceMethod/InvokeDeviceMethod.csproj
+++ b/iothub/service/samples/getting started/InvokeDeviceMethod/InvokeDeviceMethod.csproj
@@ -7,7 +7,7 @@
-
+
diff --git a/iothub/service/samples/getting started/JobsSample/JobsSample.csproj b/iothub/service/samples/getting started/JobsSample/JobsSample.csproj
index 7c0901b9ed..05778f257a 100644
--- a/iothub/service/samples/getting started/JobsSample/JobsSample.csproj
+++ b/iothub/service/samples/getting started/JobsSample/JobsSample.csproj
@@ -8,7 +8,7 @@
-
+
diff --git a/iothub/service/samples/getting started/ReadD2cMessages/ReadD2cMessages.csproj b/iothub/service/samples/getting started/ReadD2cMessages/ReadD2cMessages.csproj
index cde015c636..b641cd6575 100644
--- a/iothub/service/samples/getting started/ReadD2cMessages/ReadD2cMessages.csproj
+++ b/iothub/service/samples/getting started/ReadD2cMessages/ReadD2cMessages.csproj
@@ -7,7 +7,7 @@
-
+
diff --git a/iothub/service/samples/getting started/ServiceClientSample/ServiceClientSample.csproj b/iothub/service/samples/getting started/ServiceClientSample/ServiceClientSample.csproj
index 90e14904b0..fe2623fa17 100644
--- a/iothub/service/samples/getting started/ServiceClientSample/ServiceClientSample.csproj
+++ b/iothub/service/samples/getting started/ServiceClientSample/ServiceClientSample.csproj
@@ -8,6 +8,8 @@
+
+
diff --git a/iothub/service/samples/how to guides/AzureSasCredentialAuthenticationSample/AzureSasCredentialAuthenticationSample.csproj b/iothub/service/samples/how to guides/AzureSasCredentialAuthenticationSample/AzureSasCredentialAuthenticationSample.csproj
index 5f3f45f120..842c1fc5fd 100644
--- a/iothub/service/samples/how to guides/AzureSasCredentialAuthenticationSample/AzureSasCredentialAuthenticationSample.csproj
+++ b/iothub/service/samples/how to guides/AzureSasCredentialAuthenticationSample/AzureSasCredentialAuthenticationSample.csproj
@@ -7,7 +7,7 @@
-
+
diff --git a/iothub/service/samples/how to guides/CleanupDevicesSample/CleanupDevicesSample.csproj b/iothub/service/samples/how to guides/CleanupDevicesSample/CleanupDevicesSample.csproj
index 3fa7b07d7b..11c4dc045a 100644
--- a/iothub/service/samples/how to guides/CleanupDevicesSample/CleanupDevicesSample.csproj
+++ b/iothub/service/samples/how to guides/CleanupDevicesSample/CleanupDevicesSample.csproj
@@ -7,7 +7,7 @@
-
+
diff --git a/iothub/service/samples/how to guides/ImportExportDevicesSample/ImportExportDevicesSample.csproj b/iothub/service/samples/how to guides/ImportExportDevicesSample/ImportExportDevicesSample.csproj
index 8cf4bd0438..938cab5a22 100644
--- a/iothub/service/samples/how to guides/ImportExportDevicesSample/ImportExportDevicesSample.csproj
+++ b/iothub/service/samples/how to guides/ImportExportDevicesSample/ImportExportDevicesSample.csproj
@@ -7,7 +7,7 @@
-
+
diff --git a/iothub/service/samples/how to guides/RoleBasedAuthenticationSample/RoleBasedAuthenticationSample.csproj b/iothub/service/samples/how to guides/RoleBasedAuthenticationSample/RoleBasedAuthenticationSample.csproj
index 8cac8ba8de..8e0bb7c133 100644
--- a/iothub/service/samples/how to guides/RoleBasedAuthenticationSample/RoleBasedAuthenticationSample.csproj
+++ b/iothub/service/samples/how to guides/RoleBasedAuthenticationSample/RoleBasedAuthenticationSample.csproj
@@ -7,8 +7,8 @@
-
-
+
+
diff --git a/iothub/service/samples/solutions/DigitalTwinClientSamples/TemperatureController/TemperatureController.csproj b/iothub/service/samples/solutions/DigitalTwinClientSamples/TemperatureController/TemperatureController.csproj
index 02a6a93226..7991e92a22 100644
--- a/iothub/service/samples/solutions/DigitalTwinClientSamples/TemperatureController/TemperatureController.csproj
+++ b/iothub/service/samples/solutions/DigitalTwinClientSamples/TemperatureController/TemperatureController.csproj
@@ -9,6 +9,7 @@
+
diff --git a/iothub/service/samples/solutions/DigitalTwinClientSamples/Thermostat/Thermostat.csproj b/iothub/service/samples/solutions/DigitalTwinClientSamples/Thermostat/Thermostat.csproj
index 02a6a93226..7991e92a22 100644
--- a/iothub/service/samples/solutions/DigitalTwinClientSamples/Thermostat/Thermostat.csproj
+++ b/iothub/service/samples/solutions/DigitalTwinClientSamples/Thermostat/Thermostat.csproj
@@ -9,6 +9,7 @@
+
diff --git a/iothub/service/samples/solutions/PnpServiceSamples/TemperatureController/TemperatureController.csproj b/iothub/service/samples/solutions/PnpServiceSamples/TemperatureController/TemperatureController.csproj
index 1ef59e3f7e..1302faf31a 100644
--- a/iothub/service/samples/solutions/PnpServiceSamples/TemperatureController/TemperatureController.csproj
+++ b/iothub/service/samples/solutions/PnpServiceSamples/TemperatureController/TemperatureController.csproj
@@ -9,6 +9,7 @@
+
diff --git a/iothub/service/samples/solutions/PnpServiceSamples/Thermostat/Thermostat.csproj b/iothub/service/samples/solutions/PnpServiceSamples/Thermostat/Thermostat.csproj
index 02a6a93226..7991e92a22 100644
--- a/iothub/service/samples/solutions/PnpServiceSamples/Thermostat/Thermostat.csproj
+++ b/iothub/service/samples/solutions/PnpServiceSamples/Thermostat/Thermostat.csproj
@@ -9,6 +9,7 @@
+
diff --git a/iothub/service/src/Authentication/IotHubTokenCredentialProperties.cs b/iothub/service/src/Authentication/IotHubTokenCredentialProperties.cs
index 1efa16ecf2..20d1a9323c 100644
--- a/iothub/service/src/Authentication/IotHubTokenCredentialProperties.cs
+++ b/iothub/service/src/Authentication/IotHubTokenCredentialProperties.cs
@@ -26,6 +26,8 @@ internal class IotHubTokenCrendentialProperties
private readonly TokenCredential _credential;
private readonly object _tokenLock = new object();
private AccessToken? _cachedAccessToken;
+ private string[] _scopes;
+
#endif
#if NET451
@@ -39,6 +41,13 @@ public IotHubTokenCrendentialProperties()
public IotHubTokenCrendentialProperties(string hostName, TokenCredential credential) : base(hostName)
{
_credential = credential;
+ _scopes = CommonConstants.IotHubAadTokenScopes;
+ }
+
+ public IotHubTokenCrendentialProperties(string hostName, TokenCredential credential, string[] scopes) : base(hostName)
+ {
+ _credential = credential;
+ _scopes = scopes;
}
#endif
@@ -57,7 +66,7 @@ public override string GetAuthorizationHeader()
|| TokenHelper.IsCloseToExpiry(_cachedAccessToken.Value.ExpiresOn))
{
_cachedAccessToken = _credential.GetToken(
- new TokenRequestContext(CommonConstants.IotHubAadTokenScopes),
+ new TokenRequestContext(_scopes),
new CancellationToken());
}
}
@@ -69,7 +78,7 @@ public override string GetAuthorizationHeader()
#pragma warning disable CS1998 // Disabled as we need to throw exception for NET 451.
// The AMQP protocol uses this method to get a CBS token for authentication.
- public async override Task GetTokenAsync(Uri namespaceAddress, string appliesTo, string[] requiredClaims)
+ public override async Task GetTokenAsync(Uri namespaceAddress, string appliesTo, string[] requiredClaims)
{
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
#if NET451
diff --git a/iothub/service/src/DigitalTwin/Authentication/DigitalTwinTokenCredential.cs b/iothub/service/src/DigitalTwin/Authentication/DigitalTwinTokenCredential.cs
index 51a816e4b4..adaaa75157 100644
--- a/iothub/service/src/DigitalTwin/Authentication/DigitalTwinTokenCredential.cs
+++ b/iothub/service/src/DigitalTwin/Authentication/DigitalTwinTokenCredential.cs
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+using System;
using System.Threading;
using Azure.Core;
using Microsoft.Azure.Devices.Authentication;
@@ -18,10 +19,18 @@ internal class DigitalTwinTokenCredential : DigitalTwinServiceClientCredentials
private readonly object _tokenLock = new object();
private AccessToken? _cachedAccessToken;
private readonly TokenCredential _credential;
+ private string[] _scopes;
public DigitalTwinTokenCredential(TokenCredential credential)
{
_credential = credential;
+ _scopes = CommonConstants.IotHubAadTokenScopes;
+ }
+
+ public DigitalTwinTokenCredential(TokenCredential credential, string[] scopes)
+ {
+ _credential = credential;
+ _scopes = scopes;
}
public override string GetAuthorizationHeader()
@@ -33,7 +42,7 @@ public override string GetAuthorizationHeader()
|| TokenHelper.IsCloseToExpiry(_cachedAccessToken.Value.ExpiresOn))
{
_cachedAccessToken = _credential.GetToken(
- new TokenRequestContext(CommonConstants.IotHubAadTokenScopes),
+ new TokenRequestContext(_scopes),
new CancellationToken());
}
}
diff --git a/iothub/service/src/DigitalTwin/DigitalTwinClient.cs b/iothub/service/src/DigitalTwin/DigitalTwinClient.cs
index d5e5c131cc..384750042a 100644
--- a/iothub/service/src/DigitalTwin/DigitalTwinClient.cs
+++ b/iothub/service/src/DigitalTwin/DigitalTwinClient.cs
@@ -8,6 +8,7 @@
using Azure;
using Azure.Core;
using Microsoft.Azure.Devices.Authentication;
+using Microsoft.Azure.Devices.Common;
using Microsoft.Azure.Devices.DigitalTwin.Authentication;
using Microsoft.Azure.Devices.Extensions;
using Microsoft.Azure.Devices.Generated;
@@ -82,6 +83,32 @@ public static DigitalTwinClient Create(
string hostName,
TokenCredential credential,
params DelegatingHandler[] handlers)
+ {
+ return Create(hostName, credential, CommonConstants.IotHubAadTokenScopes, handlers);
+ }
+
+ ///
+ /// Creates DigitalTwinClient, authenticating using an identity in Azure Active Directory (AAD).
+ ///
+ ///
+ /// For more about information on the options of authenticating using a derived instance of , see
+ /// .
+ /// For more information on configuring IoT hub with Azure Active Directory, see
+ ///
+ ///
+ /// IoT hub host name.
+ /// Azure Active Directory (AAD) credentials to authenticate with IoT hub. See
+ ///
+ /// The delegating handlers to add to the http client pipeline. You can add handlers for tracing,
+ /// implementing a retry strategy, routing requests through a proxy, etc.
+ ///
+ /// The custom scopes to use when authenticating.
+ /// A DigitalTwinsClient instance.
+ public static DigitalTwinClient Create(
+ string hostName,
+ TokenCredential credential,
+ string[] scopes,
+ params DelegatingHandler[] handlers)
{
if (string.IsNullOrEmpty(hostName))
{
diff --git a/iothub/service/src/Jobs/JobClient.cs b/iothub/service/src/Jobs/JobClient.cs
index 343b132517..84f1c98e70 100644
--- a/iothub/service/src/Jobs/JobClient.cs
+++ b/iothub/service/src/Jobs/JobClient.cs
@@ -117,6 +117,29 @@ public static JobClient Create(
string hostName,
TokenCredential credential,
HttpTransportSettings transportSettings = default)
+ {
+ return Create(hostName, credential, CommonConstants.IotHubAadTokenScopes, transportSettings);
+ }
+
+ ///
+ /// Creates JobClient, authenticating using an identity in Azure Active Directory (AAD).
+ ///
+ ///
+ /// For more about information on the options of authenticating using a derived instance of , see
+ /// .
+ /// For more information on configuring IoT hub with Azure Active Directory, see
+ ///
+ ///
+ /// IoT hub host name.
+ /// Azure Active Directory (AAD) credentials to authenticate with IoT hub. See
+ /// The HTTP transport settings.
+ /// The custom scopes to authenticate with.
+ /// A JobClient instance.
+ public static JobClient Create(
+ string hostName,
+ TokenCredential credential,
+ string[] scopes,
+ HttpTransportSettings transportSettings = default)
{
if (string.IsNullOrEmpty(hostName))
{
@@ -128,7 +151,7 @@ public static JobClient Create(
throw new ArgumentNullException(nameof(credential));
}
- var tokenCredentialProperties = new IotHubTokenCrendentialProperties(hostName, credential);
+ var tokenCredentialProperties = new IotHubTokenCrendentialProperties(hostName, credential, scopes);
return new JobClient(tokenCredentialProperties, transportSettings ?? new HttpTransportSettings());
}
diff --git a/iothub/service/src/Messaging/Models/Message.cs b/iothub/service/src/Messaging/Models/Message.cs
index e66c611df2..0c6b6a29e2 100644
--- a/iothub/service/src/Messaging/Models/Message.cs
+++ b/iothub/service/src/Messaging/Models/Message.cs
@@ -369,7 +369,7 @@ public byte[] GetBytes()
{
// We can trust Amqp bufferListStream.Length;
byte[] bytes = new byte[listStream.Length];
- listStream.Read(bytes, 0, bytes.Length);
+ _ = listStream.Read(bytes, 0, bytes.Length);
return bytes;
}
diff --git a/iothub/service/src/Messaging/ServiceClient.cs b/iothub/service/src/Messaging/ServiceClient.cs
index 5a800abed6..42147809f9 100644
--- a/iothub/service/src/Messaging/ServiceClient.cs
+++ b/iothub/service/src/Messaging/ServiceClient.cs
@@ -155,6 +155,33 @@ public static ServiceClient Create(
TransportType transportType = TransportType.Amqp,
ServiceClientTransportSettings transportSettings = default,
ServiceClientOptions options = default)
+ {
+ return Create(hostName, credential, CommonConstants.IotHubAadTokenScopes, transportType, transportSettings, options);
+ }
+
+ ///
+ /// Creates ServiceClient, authenticating using an identity in Azure Active Directory (AAD).
+ ///
+ ///
+ /// For more about information on the options of authenticating using a derived instance of , see
+ /// .
+ /// For more information on configuring IoT hub with Azure Active Directory, see
+ ///
+ ///
+ /// IoT hub host name.
+ /// Azure Active Directory credentials to authenticate with IoT hub. See
+ /// Specifies whether Amqp or Amqp_WebSocket_Only transport is used.
+ /// The custom scopes to use when authenticating.
+ /// Specifies the AMQP_WS and HTTP proxy settings for service client.
+ /// The options that allow configuration of the service client instance during initialization.
+ /// A ServiceClient instance.
+ public static ServiceClient Create(
+ string hostName,
+ TokenCredential credential,
+ string[] scopes,
+ TransportType transportType = TransportType.Amqp,
+ ServiceClientTransportSettings transportSettings = default,
+ ServiceClientOptions options = default)
{
if (string.IsNullOrEmpty(hostName))
{
@@ -166,7 +193,7 @@ public static ServiceClient Create(
throw new ArgumentNullException($"{nameof(credential)}, Parameter cannot be null");
}
- var tokenCredentialProperties = new IotHubTokenCrendentialProperties(hostName, credential);
+ var tokenCredentialProperties = new IotHubTokenCrendentialProperties(hostName, credential, scopes);
bool useWebSocketOnly = transportType == TransportType.Amqp_WebSocket_Only;
return new ServiceClient(
diff --git a/iothub/service/src/Microsoft.Azure.Devices.csproj b/iothub/service/src/Microsoft.Azure.Devices.csproj
index 73002c7ec2..e8d21ae113 100644
--- a/iothub/service/src/Microsoft.Azure.Devices.csproj
+++ b/iothub/service/src/Microsoft.Azure.Devices.csproj
@@ -34,7 +34,7 @@
- 1.39.1
+ 1.40.0
Microsoft Azure IoT Service Client SDK
True
True
@@ -136,12 +136,12 @@
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
@@ -182,6 +182,6 @@
-
+
diff --git a/iothub/service/src/Registry/RegistryManager.cs b/iothub/service/src/Registry/RegistryManager.cs
index ec0fd11e78..9734c0dbf2 100644
--- a/iothub/service/src/Registry/RegistryManager.cs
+++ b/iothub/service/src/Registry/RegistryManager.cs
@@ -153,6 +153,29 @@ public static RegistryManager Create(
string hostName,
TokenCredential credential,
HttpTransportSettings transportSettings = default)
+ {
+ return Create(hostName, credential, CommonConstants.IotHubAadTokenScopes, transportSettings);
+ }
+
+ ///
+ /// Creates RegistryManager, authenticating using an identity in Azure Active Directory (AAD).
+ ///
+ ///
+ /// For more about information on the options of authenticating using a derived instance of , see
+ /// .
+ /// For more information on configuring IoT hub with Azure Active Directory, see
+ ///
+ ///
+ /// IoT hub host name.
+ /// Azure Active Directory (AAD) credentials to authenticate with IoT hub.
+ /// The HTTP transport settings.
+ /// The custom scopes to use when authenticating.
+ /// A RegistryManager instance.
+ public static RegistryManager Create(
+ string hostName,
+ TokenCredential credential,
+ string[] scopes,
+ HttpTransportSettings transportSettings = default)
{
if (string.IsNullOrEmpty(hostName))
{
@@ -164,7 +187,7 @@ public static RegistryManager Create(
throw new ArgumentNullException($"{nameof(credential)}, Parameter cannot be null");
}
- var tokenCredentialProperties = new IotHubTokenCrendentialProperties(hostName, credential);
+ var tokenCredentialProperties = new IotHubTokenCrendentialProperties(hostName, credential, scopes);
return new RegistryManager(tokenCredentialProperties, transportSettings ?? new HttpTransportSettings());
}
diff --git a/iothub/service/tests/Microsoft.Azure.Devices.Tests.csproj b/iothub/service/tests/Microsoft.Azure.Devices.Tests.csproj
index 5a7937c5c1..5449a1c59c 100644
--- a/iothub/service/tests/Microsoft.Azure.Devices.Tests.csproj
+++ b/iothub/service/tests/Microsoft.Azure.Devices.Tests.csproj
@@ -18,10 +18,10 @@
-
-
-
-
+
+
+
+
diff --git a/provisioning/device/samples/getting started/X509Sample/X509Sample.csproj b/provisioning/device/samples/getting started/X509Sample/X509Sample.csproj
index 93a2d0e359..bb7521f297 100644
--- a/provisioning/device/samples/getting started/X509Sample/X509Sample.csproj
+++ b/provisioning/device/samples/getting started/X509Sample/X509Sample.csproj
@@ -9,13 +9,13 @@
-
-
+
+
-
-
-
+
+
+
diff --git a/provisioning/device/samples/how to guides/SymmetricKeySample/SymmetricKeySample.csproj b/provisioning/device/samples/how to guides/SymmetricKeySample/SymmetricKeySample.csproj
index d4632ce2bb..200eb988a7 100644
--- a/provisioning/device/samples/how to guides/SymmetricKeySample/SymmetricKeySample.csproj
+++ b/provisioning/device/samples/how to guides/SymmetricKeySample/SymmetricKeySample.csproj
@@ -8,13 +8,13 @@
-
-
+
+
-
-
-
+
+
+
diff --git a/provisioning/device/samples/how to guides/TpmSample/TpmSample.csproj b/provisioning/device/samples/how to guides/TpmSample/TpmSample.csproj
index 355e5615c5..93e584b012 100644
--- a/provisioning/device/samples/how to guides/TpmSample/TpmSample.csproj
+++ b/provisioning/device/samples/how to guides/TpmSample/TpmSample.csproj
@@ -8,13 +8,13 @@
-
-
-
+
+
+
-
-
+
+
diff --git a/provisioning/device/src/Microsoft.Azure.Devices.Provisioning.Client.csproj b/provisioning/device/src/Microsoft.Azure.Devices.Provisioning.Client.csproj
index 8d0c02601a..a06fd7645d 100644
--- a/provisioning/device/src/Microsoft.Azure.Devices.Provisioning.Client.csproj
+++ b/provisioning/device/src/Microsoft.Azure.Devices.Provisioning.Client.csproj
@@ -59,7 +59,7 @@
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/provisioning/device/tests/Microsoft.Azure.Devices.Provisioning.Client.Tests.csproj b/provisioning/device/tests/Microsoft.Azure.Devices.Provisioning.Client.Tests.csproj
index 61219c1f9b..6506e7c005 100644
--- a/provisioning/device/tests/Microsoft.Azure.Devices.Provisioning.Client.Tests.csproj
+++ b/provisioning/device/tests/Microsoft.Azure.Devices.Provisioning.Client.Tests.csproj
@@ -11,9 +11,9 @@
-
-
-
+
+
+
diff --git a/provisioning/service/samples/getting started/CleanupEnrollmentsSample/CleanupEnrollmentsSample.csproj b/provisioning/service/samples/getting started/CleanupEnrollmentsSample/CleanupEnrollmentsSample.csproj
index 91b14f4975..15c724c7bc 100644
--- a/provisioning/service/samples/getting started/CleanupEnrollmentsSample/CleanupEnrollmentsSample.csproj
+++ b/provisioning/service/samples/getting started/CleanupEnrollmentsSample/CleanupEnrollmentsSample.csproj
@@ -9,7 +9,7 @@
-
+
diff --git a/provisioning/service/samples/getting started/EnrollmentGroupSample/EnrollmentGroupSample.csproj b/provisioning/service/samples/getting started/EnrollmentGroupSample/EnrollmentGroupSample.csproj
index db780d015b..1c1e160bb1 100644
--- a/provisioning/service/samples/getting started/EnrollmentGroupSample/EnrollmentGroupSample.csproj
+++ b/provisioning/service/samples/getting started/EnrollmentGroupSample/EnrollmentGroupSample.csproj
@@ -7,7 +7,7 @@
-
+
diff --git a/provisioning/service/samples/getting started/EnrollmentSample/IndividualEnrollmentSample.csproj b/provisioning/service/samples/getting started/EnrollmentSample/IndividualEnrollmentSample.csproj
index be41b8427f..cea6aceb19 100644
--- a/provisioning/service/samples/getting started/EnrollmentSample/IndividualEnrollmentSample.csproj
+++ b/provisioning/service/samples/getting started/EnrollmentSample/IndividualEnrollmentSample.csproj
@@ -8,7 +8,7 @@
-
+
diff --git a/provisioning/service/samples/how to guides/BulkOperationSample/BulkOperationSample.csproj b/provisioning/service/samples/how to guides/BulkOperationSample/BulkOperationSample.csproj
index 795c5b44b5..c5f9046a36 100644
--- a/provisioning/service/samples/how to guides/BulkOperationSample/BulkOperationSample.csproj
+++ b/provisioning/service/samples/how to guides/BulkOperationSample/BulkOperationSample.csproj
@@ -8,7 +8,7 @@
-
+
diff --git a/provisioning/service/src/Microsoft.Azure.Devices.Provisioning.Service.csproj b/provisioning/service/src/Microsoft.Azure.Devices.Provisioning.Service.csproj
index 87ae33d989..24c15d1605 100644
--- a/provisioning/service/src/Microsoft.Azure.Devices.Provisioning.Service.csproj
+++ b/provisioning/service/src/Microsoft.Azure.Devices.Provisioning.Service.csproj
@@ -64,7 +64,7 @@
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/provisioning/service/tests/Microsoft.Azure.Devices.Provisioning.Service.Tests.csproj b/provisioning/service/tests/Microsoft.Azure.Devices.Provisioning.Service.Tests.csproj
index e76d379104..22653bdca8 100644
--- a/provisioning/service/tests/Microsoft.Azure.Devices.Provisioning.Service.Tests.csproj
+++ b/provisioning/service/tests/Microsoft.Azure.Devices.Provisioning.Service.Tests.csproj
@@ -11,10 +11,10 @@
-
-
-
-
+
+
+
+
diff --git a/provisioning/transport/amqp/src/Microsoft.Azure.Devices.Provisioning.Transport.Amqp.csproj b/provisioning/transport/amqp/src/Microsoft.Azure.Devices.Provisioning.Transport.Amqp.csproj
index 6af69b3716..3584ca7094 100644
--- a/provisioning/transport/amqp/src/Microsoft.Azure.Devices.Provisioning.Transport.Amqp.csproj
+++ b/provisioning/transport/amqp/src/Microsoft.Azure.Devices.Provisioning.Transport.Amqp.csproj
@@ -101,8 +101,8 @@
-
-
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/provisioning/transport/amqp/tests/Microsoft.Azure.Devices.Provisioning.Transport.Amqp.Tests.csproj b/provisioning/transport/amqp/tests/Microsoft.Azure.Devices.Provisioning.Transport.Amqp.Tests.csproj
index 29446a93b7..60c6a48fd8 100644
--- a/provisioning/transport/amqp/tests/Microsoft.Azure.Devices.Provisioning.Transport.Amqp.Tests.csproj
+++ b/provisioning/transport/amqp/tests/Microsoft.Azure.Devices.Provisioning.Transport.Amqp.Tests.csproj
@@ -12,9 +12,9 @@
-
-
-
+
+
+
diff --git a/provisioning/transport/http/src/Microsoft.Azure.Devices.Provisioning.Transport.Http.csproj b/provisioning/transport/http/src/Microsoft.Azure.Devices.Provisioning.Transport.Http.csproj
index 9786970b19..03ac233337 100644
--- a/provisioning/transport/http/src/Microsoft.Azure.Devices.Provisioning.Transport.Http.csproj
+++ b/provisioning/transport/http/src/Microsoft.Azure.Devices.Provisioning.Transport.Http.csproj
@@ -100,7 +100,7 @@
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/provisioning/transport/http/tests/Microsoft.Azure.Devices.Provisioning.Transport.Http.Tests.csproj b/provisioning/transport/http/tests/Microsoft.Azure.Devices.Provisioning.Transport.Http.Tests.csproj
index b63e1b0532..06e875745b 100644
--- a/provisioning/transport/http/tests/Microsoft.Azure.Devices.Provisioning.Transport.Http.Tests.csproj
+++ b/provisioning/transport/http/tests/Microsoft.Azure.Devices.Provisioning.Transport.Http.Tests.csproj
@@ -11,9 +11,9 @@
-
-
-
+
+
+
diff --git a/provisioning/transport/mqtt/src/Microsoft.Azure.Devices.Provisioning.Transport.Mqtt.csproj b/provisioning/transport/mqtt/src/Microsoft.Azure.Devices.Provisioning.Transport.Mqtt.csproj
index 30d6abf097..b973e03164 100644
--- a/provisioning/transport/mqtt/src/Microsoft.Azure.Devices.Provisioning.Transport.Mqtt.csproj
+++ b/provisioning/transport/mqtt/src/Microsoft.Azure.Devices.Provisioning.Transport.Mqtt.csproj
@@ -110,7 +110,7 @@
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/provisioning/transport/mqtt/tests/Microsoft.Azure.Devices.Provisioning.Transport.Mqtt.Tests.csproj b/provisioning/transport/mqtt/tests/Microsoft.Azure.Devices.Provisioning.Transport.Mqtt.Tests.csproj
index 8d67fef893..01da47eea3 100644
--- a/provisioning/transport/mqtt/tests/Microsoft.Azure.Devices.Provisioning.Transport.Mqtt.Tests.csproj
+++ b/provisioning/transport/mqtt/tests/Microsoft.Azure.Devices.Provisioning.Transport.Mqtt.Tests.csproj
@@ -11,9 +11,9 @@
-
-
-
+
+
+
diff --git a/samples/helpers/ColorConsoleLogger/ColorConsoleLogger.csproj b/samples/helpers/ColorConsoleLogger/ColorConsoleLogger.csproj
index cdd1401223..def41e93cc 100644
--- a/samples/helpers/ColorConsoleLogger/ColorConsoleLogger.csproj
+++ b/samples/helpers/ColorConsoleLogger/ColorConsoleLogger.csproj
@@ -7,6 +7,7 @@
+
diff --git a/security/tpm/samples/SecurityProviderTpmSimulator/SecurityProviderTpmSimulator.cs b/security/tpm/samples/SecurityProviderTpmSimulator/SecurityProviderTpmSimulator.cs
index ab2e760e75..876057204a 100644
--- a/security/tpm/samples/SecurityProviderTpmSimulator/SecurityProviderTpmSimulator.cs
+++ b/security/tpm/samples/SecurityProviderTpmSimulator/SecurityProviderTpmSimulator.cs
@@ -9,6 +9,8 @@
using Microsoft.Azure.Devices.Shared;
using Tpm2Lib;
+#pragma warning disable CA1416
+
namespace Microsoft.Azure.Devices.Provisioning.Security.Samples
{
///
@@ -69,7 +71,9 @@ public static void StopSimulatorProcess()
{
process?.Kill();
}
+#pragma warning disable CA1031
catch (Exception)
+#pragma warning restore CA1030
{
}
}
@@ -133,3 +137,5 @@ protected override void Dispose(bool disposing)
}
}
}
+
+#pragma warning restore CA1416
diff --git a/security/tpm/samples/SecurityProviderTpmSimulator/SecurityProviderTpmSimulator.csproj b/security/tpm/samples/SecurityProviderTpmSimulator/SecurityProviderTpmSimulator.csproj
index 3d8096766c..c3b604b885 100644
--- a/security/tpm/samples/SecurityProviderTpmSimulator/SecurityProviderTpmSimulator.csproj
+++ b/security/tpm/samples/SecurityProviderTpmSimulator/SecurityProviderTpmSimulator.csproj
@@ -9,12 +9,12 @@
-
+
+
-
diff --git a/security/tpm/src/Microsoft.Azure.Devices.Provisioning.Security.Tpm.csproj b/security/tpm/src/Microsoft.Azure.Devices.Provisioning.Security.Tpm.csproj
index 7c40e4155e..95457a994e 100644
--- a/security/tpm/src/Microsoft.Azure.Devices.Provisioning.Security.Tpm.csproj
+++ b/security/tpm/src/Microsoft.Azure.Devices.Provisioning.Security.Tpm.csproj
@@ -59,7 +59,7 @@
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/security/tpm/tests/Microsoft.Azure.Devices.Provisioning.Security.Tpm.Tests.csproj b/security/tpm/tests/Microsoft.Azure.Devices.Provisioning.Security.Tpm.Tests.csproj
index be0e17162d..333c3cc46c 100644
--- a/security/tpm/tests/Microsoft.Azure.Devices.Provisioning.Security.Tpm.Tests.csproj
+++ b/security/tpm/tests/Microsoft.Azure.Devices.Provisioning.Security.Tpm.Tests.csproj
@@ -12,9 +12,9 @@
-
-
-
+
+
+
diff --git a/shared/src/Microsoft.Azure.Devices.Shared.csproj b/shared/src/Microsoft.Azure.Devices.Shared.csproj
index 8a55d86213..ffd421ccfe 100644
--- a/shared/src/Microsoft.Azure.Devices.Shared.csproj
+++ b/shared/src/Microsoft.Azure.Devices.Shared.csproj
@@ -51,7 +51,7 @@
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/shared/tests/Microsoft.Azure.Devices.Shared.Tests.csproj b/shared/tests/Microsoft.Azure.Devices.Shared.Tests.csproj
index 94d204cb8c..a271887abb 100644
--- a/shared/tests/Microsoft.Azure.Devices.Shared.Tests.csproj
+++ b/shared/tests/Microsoft.Azure.Devices.Shared.Tests.csproj
@@ -16,10 +16,10 @@
-
-
-
-
+
+
+
+
diff --git a/versions.csv b/versions.csv
index de06416107..e9ffe1da73 100644
--- a/versions.csv
+++ b/versions.csv
@@ -1,6 +1,6 @@
AssemblyPath, Version
iothub\device\src\Microsoft.Azure.Devices.Client.csproj, 1.42.3
-iothub\service\src\Microsoft.Azure.Devices.csproj, 1.39.1
+iothub\service\src\Microsoft.Azure.Devices.csproj, 1.40.0
shared\src\Microsoft.Azure.Devices.Shared.csproj, 1.30.4
provisioning\device\src\Microsoft.Azure.Devices.Provisioning.Client.csproj, 1.19.4
provisioning\service\src\Microsoft.Azure.Devices.Provisioning.Service.csproj, 1.18.4