Skip to content

[Bug Fixed] Cmdlet not returning some properties #10175

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

Merged
merged 2 commits into from
Oct 4, 2019
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
3 changes: 3 additions & 0 deletions src/IotHub/IotHub.Test/ScenarioTests/IotHubTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ function Test-AzureRmIotHubLifecycle
$Location = Get-Location "Microsoft.Devices" "IotHub"
$IotHubName = getAssetName
$ResourceGroupName = getAssetName
$SubscriptionId = '91d12660-3dec-467a-be2a-213b5544ddc0'
$Sku = "B1"
$namespaceName = getAssetName 'eventHub'
$eventHubName = getAssetName
Expand Down Expand Up @@ -97,6 +98,8 @@ function Test-AzureRmIotHubLifecycle

Assert-True { $allIotHubsInResourceGroup.Count -eq 1 }
Assert-True { $iotHub.Name -eq $IotHubName }
Assert-True { $iotHub.Resourcegroup -eq $ResourceGroupName }
Assert-True { $iotHub.Subscriptionid -eq $SubscriptionId }
Assert-True { $iotHub.Properties.Routing.Routes.Count -eq 1}
Assert-True { $iotHub.Properties.Routing.Routes[0].Name -eq "route"}
Assert-True { $iotHub.Properties.Routing.Endpoints.EventHubs[0].Name -eq "eh1"}
Expand Down

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/IotHub/IotHub/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
-->
## Upcoming Release
* Add new routing source: DigitalTwinChangeEvents
* Minor bug fix: Get-AzIothub not returning subscriptionId

## Version 1.3.0
* Add support to invoke failover for an IotHub to the geo-paired disaster recovery region.
Expand Down
8 changes: 8 additions & 0 deletions src/IotHub/IotHub/Common/IotHubUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,14 @@ public static string GetResourceGroupName(string Id)
return m.Success ? m.Groups["rgname"].Value : null;
}

public static string GetSubscriptionId(string Id)
{
if (string.IsNullOrEmpty(Id)) return null;
Regex r = new Regex(@"(.*?)/subscriptions/(?<subscriptionid>\S+)/resourcegroups/(.*?)", RegexOptions.IgnoreCase);
Match m = r.Match(Id);
return m.Success ? m.Groups["subscriptionid"].Value : null;
}

public static string GetIotHubName(string Id)
{
if (string.IsNullOrEmpty(Id)) return null;
Expand Down
9 changes: 8 additions & 1 deletion src/IotHub/IotHub/Models/PSIotHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,14 @@ public class PSIotHub
/// The subscription identifier.
/// </summary>
[JsonProperty(PropertyName = "subscriptionid")]
public string Subscriptionid { get; set; }
public string Subscriptionid
{
get
{
return IotHubUtils.GetSubscriptionId(Id);
}
set { }
}

/// <summary>
/// The resource group name uniquely identifies the resource group
Expand Down