Skip to content

Commit 015c51a

Browse files
authored
Updated Az.Resources .NET SDK reference to 3.10.0-preview (#12656)
The new version includes the latest contract for Azure Policy aliases, where each alias includes additional metadata indicating whether it can be used in modify policies.
1 parent b81de1a commit 015c51a

File tree

6 files changed

+41
-6
lines changed

6 files changed

+41
-6
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.9.0-preview" />
16+
<PackageReference Include="Microsoft.Azure.Management.ResourceManager" Version="3.10.0-preview" />
1717
<PackageReference Include="Microsoft.CSharp" Version="4.5.0" />
1818
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="2.2.0" />
1919
</ItemGroup>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
</ItemGroup>
3232

3333
<ItemGroup>
34-
<PackageReference Update="Microsoft.Azure.Management.ResourceManager" Version="3.9.0-preview" />
34+
<PackageReference Update="Microsoft.Azure.Management.ResourceManager" Version="3.10.0-preview" />
3535
</ItemGroup>
3636
<ItemGroup>
3737
<PackageReference Include="FluentAssertions" Version="5.9.0" />

src/Resources/Resources.Test/ScenarioTests/PolicyAliasTests.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,27 @@ public void TestGetAzureRmPolicyAliasAllParameters()
441441
this.VerifyListCallPatternAndReset();
442442
}
443443

444+
[Fact]
445+
[Trait(Category.AcceptanceType, Category.CheckIn)]
446+
public void TestGetAzureRmPolicyAliasWithPathMetadata()
447+
{
448+
var providers = new ProviderListBuilder();
449+
var provider = providers.AddProvider("Provider1");
450+
var resourceTypes = provider.AddResourceType("ResourceType1");
451+
var alias = resourceTypes.AddAlias("Alias1");
452+
alias.AddDefaultAliasPathMetadata(AliasPathAttributes.Modifiable, AliasPathTokenType.String);
453+
alias.AddAliasPath("properties.alias1", new List<string> { "2020-01-01" }, new AliasPathMetadata(AliasPathAttributes.Modifiable, AliasPathTokenType.Object));
454+
455+
var listResult = providers.List;
456+
this.SetupAliasListResult(listResult);
457+
458+
this.commandRuntimeMock
459+
.Setup(m => m.WriteObject(It.IsAny<object>(), It.IsAny<bool>()))
460+
.Callback((object obj, bool listAll) => { this.AssertResult(obj, listResult, 1); });
461+
462+
this.cmdlet.ExecuteCmdlet();
463+
this.VerifyListCallPatternAndReset();
464+
}
444465
/// <summary>
445466
/// Helper method that sets up the expected result of the alias list cmdlet
446467
/// </summary>
@@ -497,6 +518,9 @@ private void AssertResult(object resultObject, IEnumerable<Provider> expectedPro
497518
var expectedAlias = expectedResourceType.Aliases.SingleOrDefault(item => item.Name.EqualsInsensitively(actualAlias.Name));
498519
Assert.NotNull(expectedAlias);
499520

521+
Assert.Equal(expectedAlias.DefaultMetadata?.Attributes, actualAlias.DefaultMetadata?.Attributes);
522+
Assert.Equal(expectedAlias.DefaultMetadata?.Type, actualAlias.DefaultMetadata?.Type);
523+
500524
// verify paths collection
501525
if (actualAlias.Paths == null)
502526
{
@@ -509,6 +533,9 @@ private void AssertResult(object resultObject, IEnumerable<Provider> expectedPro
509533
var expectedPath = expectedAlias.Paths.SingleOrDefault(item => item.Path.EqualsInsensitively(actualPath.Path));
510534
Assert.NotNull(expectedPath);
511535

536+
Assert.Equal(actualPath.Metadata?.Attributes, expectedPath.Metadata?.Attributes);
537+
Assert.Equal(actualPath.Metadata?.Type, expectedPath.Metadata?.Type);
538+
512539
// verify API version collection
513540
if (actualPath.ApiVersions == null)
514541
{

src/Resources/Resources.Test/ScenarioTests/ProviderListBuilder.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,21 +91,28 @@ public class AliasBuilder
9191
public static IList<string> DefaultApiVersions { get; } = new List<string> { "2018-01-01", "2016-01-01" };
9292
private string Name { get; }
9393
private List<AliasPath> Paths { get; } = new List<AliasPath>();
94+
private AliasPathMetadata DefaultAliasPathMetadata { get; set; }
9495

9596
public AliasBuilder(string name)
9697
{
9798
this.Name = name;
9899
}
99100

100-
public Alias Alias => new Alias
101+
public Alias Alias => new Alias(defaultMetadata: this.DefaultAliasPathMetadata)
101102
{
102103
Name = this.Name,
103104
Paths = this.Paths
104105
};
105106

106-
public AliasPath AddAliasPath(string path, IEnumerable<string> apiVersions = null)
107+
public AliasPathMetadata AddDefaultAliasPathMetadata(string attributes, string type)
107108
{
108-
var rv = new AliasPath
109+
this.DefaultAliasPathMetadata = new AliasPathMetadata(attributes, type);
110+
return this.DefaultAliasPathMetadata;
111+
}
112+
113+
public AliasPath AddAliasPath(string path, IEnumerable<string> apiVersions = null, AliasPathMetadata metadata= null)
114+
{
115+
var rv = new AliasPath(metadata: metadata)
109116
{
110117
Path = path,
111118
ApiVersions = apiVersions?.ToList() ?? AliasBuilder.DefaultApiVersions

src/Resources/Resources/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21+
* Updated `Get-AzPolicyAlias` response to include information indicating whether the alias is modifiable by Azure Policy.
2122
* Created new cmdlet `Set-AzRoleAssignment`
2223
* Added `Get-AzDeploymentManagementGroupWhatIfResult` for getting ARM template What-If results at management Group scope
2324
* Added `Get-AzTenantWhatIfResult` new cmdlet for getting ARM template What-If results at tenant scope

src/Resources/Tags/Tags.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</PropertyGroup>
1313

1414
<ItemGroup>
15-
<PackageReference Include="Microsoft.Azure.Management.ResourceManager" Version="3.9.0-preview" />
15+
<PackageReference Include="Microsoft.Azure.Management.ResourceManager" Version="3.10.0-preview" />
1616
</ItemGroup>
1717

1818
</Project>

0 commit comments

Comments
 (0)