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

[IoT]IoT Hub SDK version update to 4.2.0 and fixed Get-AzIoTHub to work with DigiCert hubs #20938

Merged
merged 5 commits into from
Feb 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Devices" Version="1.22.0" />
<PackageReference Include="Microsoft.Azure.Management.DeviceProvisioningServices" Version="0.10.0-preview" />
<PackageReference Include="Microsoft.Azure.Management.IotHub" Version="3.0.1" />
<PackageReference Include="Microsoft.Azure.Management.IotHub" Version="4.2.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function Test-AzureIotDpsAccessPolicyLifeCycle

# Constant variable
$AccessPolicyDefaultKeyName = "provisioningserviceowner"
$AccessPolicyDefaultRights = "ServiceConfig, DeviceConnect, EnrollmentWrite"
$AccessPolicyDefaultRights = "ServiceConfig, EnrollmentWrite, DeviceConnect"
$NewAccessPolicyKeyName = "Access1"
$NewAccessPolicyRights = "ServiceConfig"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function Test-AzIotDpsEnrollmentGroupLifeCycle
Assert-True { $iotHub.Name -eq $IotHubName }

# Add a key to IoT Hub
$hubKeys = Add-AzIoTHubKey -Name $IotHubName -ResourceGroupName $ResourceGroupName -KeyName $hubKeyName -Rights ServiceConnect
$hubKeys = Add-AzIoTHubKey -Name $IotHubName -ResourceGroupName $ResourceGroupName -KeyName $hubKeyName -Rights RegistryWrite,ServiceConnect
Assert-True { $hubKeys.Count -gt 1 }

# Get key information from IoT Hub
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function Test-AzIotDpsEnrollmentLifeCycle
Assert-True { $iotHub.Name -eq $IotHubName }

# Add a key to IoT Hub
$hubKeys = Add-AzIoTHubKey -Name $IotHubName -ResourceGroupName $ResourceGroupName -KeyName $hubKeyName -Rights ServiceConnect
$hubKeys = Add-AzIoTHubKey -Name $IotHubName -ResourceGroupName $ResourceGroupName -KeyName $hubKeyName -Rights RegistryWrite,ServiceConnect
Assert-True { $hubKeys.Count -gt 1 }

# Get key information from IoT Hub
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function Test-AzureIotDpsLinkedHubLifeCycle
Assert-True { $iotHub.Name -eq $IotHubName }

# Add a key to IoT Hub
$hubKeys = Add-AzIoTHubKey -Name $IotHubName -ResourceGroupName $ResourceGroupName -KeyName $hubKeyName -Rights ServiceConnect
$hubKeys = Add-AzIoTHubKey -Name $IotHubName -ResourceGroupName $ResourceGroupName -KeyName $hubKeyName -Rights ServiceConnect,RegistryWrite
Assert-True { $hubKeys.Count -gt 1 }

# Get key information from IoT Hub
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function Test-AzIotDpsRegistrationLifeCycle
Assert-True { $iotHub.Name -eq $IotHubName }

# Add a key to IoT Hub
$hubKeys = Add-AzIoTHubKey -Name $IotHubName -ResourceGroupName $ResourceGroupName -KeyName $hubKeyName -Rights ServiceConnect
$hubKeys = Add-AzIoTHubKey -Name $IotHubName -ResourceGroupName $ResourceGroupName -KeyName $hubKeyName -Rights RegistryWrite,ServiceConnect
Assert-True { $hubKeys.Count -gt 1 }

# Get key information from IoT Hub
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/IotHub/IotHub.Test/IotHub.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Devices" Version="1.22.0" />
<PackageReference Include="Microsoft.Azure.Management.EventHub" Version="5.0.0" />
<PackageReference Include="Microsoft.Azure.Management.IotHub" Version="3.0.1" />
<PackageReference Include="Microsoft.Azure.Management.IotHub" Version="4.2.0" />
<PackageReference Include="Microsoft.Azure.Management.Storage" Version="25.0.0" />
</ItemGroup>

Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/IotHub/IotHub/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
- Additional information about change #1
-->
## Upcoming Release
* Updated IoT Hub Management SDK to version 4.2.0 (api-version 2021-07-02)
* Fixed `Get-AzIoTHub` to work with DigiCert hubs

## Version 2.7.4
* Updated IoT Hub Management SDK to version 4.1.0 (api-version 2021-07-10)
Expand Down
2 changes: 1 addition & 1 deletion src/IotHub/IotHub/IotHub.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Devices" Version="1.22.0" />
<PackageReference Include="Microsoft.Azure.Devices.Client" Version="1.27.0" />
<PackageReference Include="Microsoft.Azure.Management.IotHub" Version="3.0.1" />
<PackageReference Include="Microsoft.Azure.Management.IotHub" Version="4.2.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="2.2.0" />
</ItemGroup>

Expand Down
6 changes: 3 additions & 3 deletions src/IotHub/IotHub/IotHub/AddAzureRmIotHubCertificate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,11 @@ public override void ExecuteCmdlet()
{
certificate = Encoding.UTF8.GetString(Encoding.UTF8.GetBytes(certificate));

CertificateBodyDescription certificateBodyDescription = new CertificateBodyDescription();
certificateBodyDescription.Certificate = certificate;
CertificateProperties certificateProperties = new CertificateProperties();
certificateProperties.Certificate = certificate;

CertificateDescription certificateDescription;
certificateDescription = this.IotHubClient.Certificates.CreateOrUpdate(this.ResourceGroupName, this.Name, this.CertificateName, this.Etag, certificateBodyDescription.Certificate);
certificateDescription = this.IotHubClient.Certificates.CreateOrUpdate(this.ResourceGroupName, this.Name, this.CertificateName, this.Etag, certificateProperties);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to point to a copy rather than the original object here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we discussed offline, since we are adding certificate, there is no original object, instead we would need to create a new object in order to use CreateOrUpdate. Also tested that only pass in the certificate is enough, the rest CertificateProperties properties can be figured out after the service call, this is the return after calling this command:

Id : /subscriptions/a386d5ea-ea90-441a-8263-d816368c84a1/resourceGroups/jiacjutest/providers/Microsoft.D
evices/IotHubs/newstate/certificates/certifitry
ResourceGroupName : jiacjutest
Name : newstate
CertificateName : certifitry
Subject : management
Thumbprint : 46BB6DAA9A62A4D256FC02A1F73AAB18F7724B72
Status : Unverified
Expiry : 9/27/2031 12:09
Created : 1/01/0001 00:01
Etag : IjhlMDI2ODQ1LTAwMDAtMDMwMC0wMDAwLTYzZWQ4YzZjMDAwMCI=



this.WriteObject(IotHubUtils.ToPSCertificateDescription(certificateDescription));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ public override void ExecuteCmdlet()
string eventsEndpointName = "events";
if (ShouldProcess(EventHubConsumerGroupName, Properties.Resources.AddEventHubConsumerGroup))
{
this.IotHubClient.IotHubResource.CreateEventHubConsumerGroup(this.ResourceGroupName, this.Name, eventsEndpointName, this.EventHubConsumerGroupName);
EventHubConsumerGroupName properties = new EventHubConsumerGroupName(this.EventHubConsumerGroupName);
this.IotHubClient.IotHubResource.CreateEventHubConsumerGroup(this.ResourceGroupName, this.Name, eventsEndpointName, this.EventHubConsumerGroupName, properties);
IEnumerable<EventHubConsumerGroupInfo> iotHubEHConsumerGroups = this.IotHubClient.IotHubResource.ListEventHubConsumerGroups(this.ResourceGroupName, this.Name, eventsEndpointName);
this.WriteObject(IotHubUtils.ToPSEventHubConsumerGroupInfo(iotHubEHConsumerGroups), true);
}
Expand Down
3 changes: 2 additions & 1 deletion src/IotHub/IotHub/Models/PSCapabilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public enum PSCapabilities
{
None = 0,
DeviceManagement = 1,
GWV2 = 2
GWV2 = 2,
RootCertificateV2 = 3
}
}