Skip to content

Commit 6353626

Browse files
[ApplicationInsights] Fixed ApplicationInsightsLinkedStorageAccount CRUD command that complain missing resourcegroupName when using InputObject (#15166)
* [ApplicationInsights] ApplicationInsightsLinkedStorageAccount CRUD command that complain missing resourcegroupName when using InputObject [#14848]. * Update ChangeLog.md * [ApplicationInsights] Add CRUD test cases of the LinkedStorageAccount for pipeline. Co-authored-by: Dingmeng Xue <[email protected]>
1 parent 733d2ff commit 6353626

File tree

7 files changed

+631
-7399
lines changed

7 files changed

+631
-7399
lines changed

src/ApplicationInsights/ApplicationInsights.Test/ScenarioTests/LinkedStorageAccountTests.ps1

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,22 @@ function Test-LinkedStorageAccountCRUD
5151

5252
Remove-AzApplicationInsightsLinkedStorageAccount -ResourceGroupName $rgname -ComponentName $appName
5353

54+
# Test CRUD by pipeline.
55+
New-AzApplicationInsightsLinkedStorageAccount -InputObject $app -LinkedStorageAccountResourceId $account1.Id
56+
$linkedAccount = Get-AzApplicationInsightsLinkedStorageAccount -InputObject $app
57+
58+
Assert-NotNull $linkedAccount
59+
Assert-AreEqual $account1.Id $linkedAccount.linkedStorageAccount
60+
Assert-AreEqual "serviceprofiler" $linkedAccount.Name
61+
62+
Update-AzApplicationInsightsLinkedStorageAccount -InputObject $app -LinkedStorageAccountResourceId $account2.Id
63+
$linkedAccount = Get-AzApplicationInsightsLinkedStorageAccount -InputObject $app
64+
65+
Assert-NotNull $linkedAccount
66+
Assert-AreEqual $account2.Id $linkedAccount.linkedStorageAccount
67+
68+
Remove-AzApplicationInsightsLinkedStorageAccount -InputObject $app
69+
5470
Remove-AzStorageAccount -ResourceGroupName $rgname -Name $accountName1 -force
5571
Remove-AzStorageAccount -ResourceGroupName $rgname -Name $accountName2 -force
5672

src/ApplicationInsights/ApplicationInsights.Test/SessionRecords/Microsoft.Azure.Commands.ApplicationInsights.Test.ScenarioTests.LinkedStorageAccountTests/TestLinkedStorageAccountCRUD.json

Lines changed: 606 additions & 7395 deletions
Large diffs are not rendered by default.

src/ApplicationInsights/ApplicationInsights/ApplicationInsights/GetApplicationInsightsLinkedStorageAccount.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public override void ExecuteCmdlet()
7272
this.ResourceId = this.InputObject.Id;
7373
}
7474

75-
if (this.IsParameterBound(c => c.ResourceId))
75+
if (this.IsParameterBound(c => c.ResourceId) || !string.IsNullOrEmpty(this.ResourceId))
7676
{
7777
ResourceIdentifier identifier = new ResourceIdentifier(this.ResourceId);
7878
this.ResourceGroupName = identifier.ResourceGroupName;

src/ApplicationInsights/ApplicationInsights/ApplicationInsights/NewApplicationInsightsLinkedStorageAccount.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public override void ExecuteCmdlet()
8181
this.ResourceId = this.InputObject.Id;
8282
}
8383

84-
if (this.IsParameterBound(c => c.ResourceId))
84+
if (this.IsParameterBound(c => c.ResourceId) || !string.IsNullOrEmpty(this.ResourceId))
8585
{
8686
ResourceIdentifier identifier = new ResourceIdentifier(this.ResourceId);
8787
this.ResourceGroupName = identifier.ResourceGroupName;

src/ApplicationInsights/ApplicationInsights/ApplicationInsights/RemoveApplicationInsightsLinkedStorageAccount.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public override void ExecuteCmdlet()
7171
this.ResourceId = this.InputObject.Id;
7272
}
7373

74-
if (this.IsParameterBound(c => c.ResourceId))
74+
if (this.IsParameterBound(c => c.ResourceId) || !string.IsNullOrEmpty(this.ResourceId))
7575
{
7676
ResourceIdentifier identifier = new ResourceIdentifier(this.ResourceId);
7777
this.ResourceGroupName = identifier.ResourceGroupName;

src/ApplicationInsights/ApplicationInsights/ApplicationInsights/UpdateApplicationInsightsLinkedStorageAccount.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public override void ExecuteCmdlet()
8080
this.ResourceId = this.InputObject.Id;
8181
}
8282

83-
if (this.IsParameterBound(c => c.ResourceId))
83+
if (this.IsParameterBound(c => c.ResourceId) || !string.IsNullOrEmpty(this.ResourceId))
8484
{
8585
ResourceIdentifier identifier = new ResourceIdentifier(this.ResourceId);
8686
this.ResourceGroupName = identifier.ResourceGroupName;

src/ApplicationInsights/ApplicationInsights/ChangeLog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21+
* Fixed issue that `ResourcegroupName` is missed when executing below cmdlets with `InputObject` parameter [#14848]
22+
* `Get-AzApplicationInsightsLinkedStorageAccount`
23+
* `New-AzApplicationInsightsLinkedStorageAccount`
24+
* `Update-AzApplicationInsightsLinkedStorageAccount`
25+
* `Remove-AzApplicationInsightsLinkedStorageAccount`
2126

2227
## Version 1.1.0
2328
* Added Parameters: `RetentionInDays` `PublicNetworkAccessForIngestion` `PublicNetworkAccessForQuery` for `New-AzApplicationInsights`

0 commit comments

Comments
 (0)