Skip to content

Commit ea93530

Browse files
committed
Updated SDK to fix parsing of FailedResources and updated output formatting
1 parent 923e518 commit ea93530

File tree

8 files changed

+86
-12
lines changed

8 files changed

+86
-12
lines changed

src/Resources/ResourceManager/ResourceManager.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
<ItemGroup>
1515
<PackageReference Include="AutoMapper" Version="6.2.2" />
16-
<PackageReference Include="Microsoft.Azure.Management.ResourceManager" Version="3.14.7-stacks" />
16+
<PackageReference Include="Microsoft.Azure.Management.ResourceManager" Version="3.14.9-stacks" />
1717
<PackageReference Include="Microsoft.CSharp" Version="4.5.0" />
1818
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="2.2.0" />
1919
</ItemGroup>

src/Resources/ResourceManager/SdkExtensions/ResourcesExtensions.cs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,5 +338,52 @@ public static Hashtable ToHashtable(this object obj)
338338
.ToDictionary(p => p.Name, p => p.GetValue(obj, null)));
339339

340340
}
341+
342+
public static string GetStackResourcesAsString(IList<ManagedResourceReference> list)
343+
{
344+
StringBuilder result = new StringBuilder();
345+
int listElement = 0;
346+
while (listElement < list.Count - 1)
347+
{
348+
result.AppendLine(list[listElement].Id);
349+
listElement += 1;
350+
}
351+
result.Append(list[listElement].Id);
352+
353+
return result.ToString();
354+
}
355+
356+
public static string GetStackResourcesAsString(IList<ResourceReference> list)
357+
{
358+
StringBuilder result = new StringBuilder();
359+
int listElement = 0;
360+
while (listElement < list.Count - 1)
361+
{
362+
result.AppendLine(list[listElement].Id);
363+
listElement += 1;
364+
}
365+
result.Append(list[listElement].Id);
366+
367+
return result.ToString();
368+
}
369+
370+
public static string GetStackResourcesAsString(IList<ResourceReferenceExtended> list)
371+
{
372+
StringBuilder result = new StringBuilder();
373+
int listElement = 0;
374+
string rowFormat = "{0, -" + 4 + "} {1, -" + 4 + "}\r\n";
375+
string lastRowFormat = "{0, -" + 4 + "} {1, -" + 4 + "}";
376+
while (listElement < list.Count - 1)
377+
{
378+
result.AppendFormat(rowFormat, "Id:", list[listElement].Id);
379+
result.AppendFormat(rowFormat, "Error:", list[listElement].Error.Message);
380+
result.AppendLine();
381+
listElement += 1;
382+
}
383+
result.AppendFormat(rowFormat, "Id:", list[listElement].Id);
384+
result.AppendFormat(lastRowFormat, "Error:", list[listElement].Error.Message);
385+
386+
return result.ToString();
387+
}
341388
}
342389
}

src/Resources/ResourceManager/SdkModels/DeploymentStacks/PSDeploymentStack.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Microsoft.Azure.Management.ResourceManager.Models;
1+
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.SdkExtensions;
2+
using Microsoft.Azure.Management.ResourceManager.Models;
23
using Microsoft.Rest;
34
using Microsoft.Rest.Serialization;
45
using Newtonsoft.Json;
@@ -74,6 +75,11 @@ internal PSDeploymentStack(DeploymentStack deploymentStack)
7475
this.snapshotId = deploymentStack.SnapshotId;
7576
}
7677

78+
public string managedResourcesString
79+
{
80+
get { return ResourcesExtensions.GetStackResourcesAsString(managedResources); }
81+
}
82+
7783
internal static PSDeploymentStack FromAzureSDKDeploymentStack(DeploymentStack stack)
7884
{
7985
return stack != null

src/Resources/ResourceManager/SdkModels/DeploymentStacks/PSDeploymentStackSnapshot.cs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Microsoft.Azure.Management.ResourceManager.Models;
1+
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.SdkExtensions;
2+
using Microsoft.Azure.Management.ResourceManager.Models;
23
using System;
34
using System.Collections.Generic;
45
using System.Text;
@@ -45,7 +46,7 @@ public class PSDeploymentStackSnapshot
4546

4647
public IList<ResourceReference> deletedResources { get; set; }
4748

48-
public object failedResources { get; set; }
49+
public IList<ResourceReferenceExtended> failedResources { get; set; }
4950

5051
public PSDeploymentStackSnapshot() { }
5152

@@ -73,6 +74,26 @@ internal PSDeploymentStackSnapshot(DeploymentStackSnapshot deploymentStackSnapsh
7374
this.failedResources = deploymentStackSnapshot.FailedResources;
7475
}
7576

77+
public string managedResourcesString
78+
{
79+
get { return ResourcesExtensions.GetStackResourcesAsString(managedResources); }
80+
}
81+
82+
public string detachedResourcesString
83+
{
84+
get { return ResourcesExtensions.GetStackResourcesAsString(detachedResources); }
85+
}
86+
87+
public string deletedResourcesString
88+
{
89+
get { return ResourcesExtensions.GetStackResourcesAsString(deletedResources); }
90+
}
91+
92+
public string failedResourcesString
93+
{
94+
get { return ResourcesExtensions.GetStackResourcesAsString(failedResources); }
95+
}
96+
7697
internal static PSDeploymentStackSnapshot FromAzureSDKDeploymentStack(DeploymentStackSnapshot stackSnapshot)
7798
{
7899
return stackSnapshot != null

src/Resources/Resources.Test/Resources.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
</ItemGroup>
3434

3535
<ItemGroup>
36-
<PackageReference Update="Microsoft.Azure.Management.ResourceManager" Version="3.14.7-stacks" />
36+
<PackageReference Update="Microsoft.Azure.Management.ResourceManager" Version="3.14.9-stacks" />
3737
</ItemGroup>
3838
<ItemGroup>
3939
<PackageReference Include="FluentAssertions" Version="5.9.0" />

src/Resources/Resources/Az.Resources.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# RootModule = ''
1313

1414
# Version number of this module.
15-
ModuleVersion = '4.3.6'
15+
ModuleVersion = '4.3.7'
1616

1717
# Supported PSEditions
1818
CompatiblePSEditions = 'Core', 'Desktop'

src/Resources/Resources/Resources.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<PackageReference Include="Microsoft.Azure.Graph.RBAC" Version="3.8.0-preview" />
1515
<PackageReference Include="Microsoft.Azure.Management.Authorization" Version="2.12.0-preview" />
1616
<PackageReference Include="Microsoft.Azure.Management.ManagementGroups" Version="1.1.1-preview" />
17-
<PackageReference Include="Microsoft.Azure.Management.ResourceManager" Version="3.14.7-stacks" />
17+
<PackageReference Include="Microsoft.Azure.Management.ResourceManager" Version="3.14.9-stacks" />
1818
</ItemGroup>
1919

2020
<ItemGroup>

src/Resources/Resources/Resources.format.ps1xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@
544544
<ItemSelectionCondition>
545545
<ScriptBlock>$_.managedResources -ne $null</ScriptBlock>
546546
</ItemSelectionCondition>
547-
<ScriptBlock>$managedResourcesList=@(); foreach ($managedResource in $_.managedResources){$managedResourcesList+="'$($managedResource.Id)'"}; $managedResourcesList</ScriptBlock>
547+
<ScriptBlock>$_.managedResourcesString</ScriptBlock>
548548
</ListItem>
549549
<ListItem>
550550
<Label>DeploymentId</Label>
@@ -623,28 +623,28 @@
623623
<ItemSelectionCondition>
624624
<ScriptBlock>$_.managedResources -ne $null</ScriptBlock>
625625
</ItemSelectionCondition>
626-
<ScriptBlock>$managedResourcesList=@(); foreach ($managedResource in $_.managedResources){$managedResourcesList+="'$($managedResource.Id)'"}; $managedResourcesList</ScriptBlock>
626+
<ScriptBlock>$_.managedResourcesString</ScriptBlock>
627627
</ListItem>
628628
<ListItem>
629629
<Label>DetachedResources</Label>
630630
<ItemSelectionCondition>
631631
<ScriptBlock>$_.detachedResources -ne $null</ScriptBlock>
632632
</ItemSelectionCondition>
633-
<ScriptBlock>$detachedResourcesList=@(); foreach ($detachedResource in $_.detachedResources){$detachedResourcesList+="'$($detachedResource.Id)'"}; $detachedResourcesList</ScriptBlock>
633+
<ScriptBlock>$_.detachedResourcesString</ScriptBlock>
634634
</ListItem>
635635
<ListItem>
636636
<Label>DeletedResources</Label>
637637
<ItemSelectionCondition>
638638
<ScriptBlock>$_.deletedResources -ne $null</ScriptBlock>
639639
</ItemSelectionCondition>
640-
<ScriptBlock>$deletedResourcesList=@(); foreach ($deletedResource in $_.deletedResources){$deletedResourcesList+="'$($deletedResource.Id)'"}; $deletedResourcesList</ScriptBlock>
640+
<ScriptBlock>$_.deletedResourcesString</ScriptBlock>
641641
</ListItem>
642642
<ListItem>
643643
<Label>FailedResources</Label>
644644
<ItemSelectionCondition>
645645
<ScriptBlock>$_.failedResources -ne $null</ScriptBlock>
646646
</ItemSelectionCondition>
647-
<ScriptBlock>$failedResourcesList=@(); foreach ($failedResource in $_.failedResources){$failedResourcesList+="'$($failedResource.Id)'"}; $failedResourcesList</ScriptBlock>
647+
<ScriptBlock>$_.failedResourcesString</ScriptBlock>
648648
</ListItem>
649649
<ListItem>
650650
<Label>DeploymentId</Label>

0 commit comments

Comments
 (0)