Skip to content
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

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/Accounts/Accounts.Test/SubscriptionCmdletTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ function Test-GetSubscriptionsEndToEnd
Assert-True {$mostSubscriptions.Count -gt 0}
$tenantSubscriptions = Get-AzSubscription -Tenant $tenant
Assert-True {$tenantSubscriptions.Count -gt 0}
Assert-NotNull $subscription.SubscriptionPolicies
}

<#
Expand Down
53 changes: 53 additions & 0 deletions src/Accounts/Accounts.Test/UnitTest/PSAzureSubscriptionTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
using Microsoft.Azure.Commands.Profile.Models;
using Microsoft.Azure.Internal.Subscriptions.Models;
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Newtonsoft.Json;
using System;
using Xunit;

namespace Microsoft.Azure.Commands.Profile.Test.UnitTest
{
public class PSAzureSubscriptionTest
{

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void NewPSAzureSubscription()
{
string locationPlacementId = "Internal_2014-09-01";
string quotaId= "Internal_2014-09-01";
SpendingLimit spendingLimit = SpendingLimit.Off;
var subscriptionPolicies = new SubscriptionPolicies(locationPlacementId, quotaId, spendingLimit);

// test PSAzureSubscriptionPolicies' constructors
var psAzureSubscriptionPolicies = new PSAzureSubscriptionPolicy(subscriptionPolicies);
Assert.Equal(psAzureSubscriptionPolicies.LocationPlacementId, locationPlacementId);
Assert.Equal(psAzureSubscriptionPolicies.QuotaId, quotaId);
Assert.Equal(psAzureSubscriptionPolicies.SpendingLimit, spendingLimit.ToString());

var psAzureSubscriptionPolicies2 = new PSAzureSubscriptionPolicy(JsonConvert.SerializeObject(subscriptionPolicies));
Assert.Equal(psAzureSubscriptionPolicies2.LocationPlacementId, locationPlacementId);
Assert.Equal(psAzureSubscriptionPolicies2.QuotaId, quotaId);
Assert.Equal(psAzureSubscriptionPolicies2.SpendingLimit, spendingLimit.ToString());

var sub = new AzureSubscription
{
Id = new Guid().ToString(),
Name = "Contoso Test Subscription",
State = "Enabled",
};
sub.SetAccount("me@contoso.com");
sub.SetEnvironment("testCloud");
sub.SetTenant(new Guid("3c0ff8a7-e8bb-40e8-ae66-271343379af6").ToString());
sub.SetSubscriptionPolicies(JsonConvert.SerializeObject(subscriptionPolicies));

// test PSAzureSubscription's constructor
var psAzureSubscription = new PSAzureSubscription(sub);
Assert.NotNull(psAzureSubscription.SubscriptionPolicies);
Assert.Equal(psAzureSubscription.SubscriptionPolicies.LocationPlacementId, locationPlacementId);
Assert.Equal(psAzureSubscription.SubscriptionPolicies.QuotaId, quotaId);
Assert.Equal(psAzureSubscription.SubscriptionPolicies.SpendingLimit, spendingLimit.ToString());
}
}
}
40 changes: 40 additions & 0 deletions src/Accounts/Accounts/Accounts.format.ps1xml
Original file line number Diff line number Diff line change
Expand Up @@ -171,5 +171,45 @@
</TableRowEntries>
</TableControl>
</View>
<View>
<Name>Microsoft.Azure.Commands.Profile.Models.PSAzureSubscriptionPolicy</Name>
<ViewSelectedBy>
<TypeName>Microsoft.Azure.Commands.Profile.Models.PSAzureSubscriptionPolicy</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
<TableColumnHeader>
<Alignment>Left</Alignment>
<Label>locationPlacementId</Label>
</TableColumnHeader>
<TableColumnHeader>
<Alignment>Left</Alignment>
<Label>QuotaId</Label>
</TableColumnHeader>
<TableColumnHeader>
<Alignment>Left</Alignment>
<Label>SpendingLimit</Label>
</TableColumnHeader>
</TableHeaders>
<TableRowEntries>
<TableRowEntry>
<TableColumnItems>
<TableColumnItem>
<Alignment>Left</Alignment>
<PropertyName>locationPlacementId</PropertyName>
</TableColumnItem>
<TableColumnItem>
<Alignment>Left</Alignment>
<PropertyName>QuotaId</PropertyName>
</TableColumnItem>
<TableColumnItem>
<Alignment>Left</Alignment>
<PropertyName>SpendingLimit</PropertyName>
</TableColumnItem>
</TableColumnItems>
</TableRowEntry>
</TableRowEntries>
</TableControl>
</View>
</ViewDefinitions>
</Configuration>
1 change: 1 addition & 0 deletions src/Accounts/Accounts/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Additional information about change #1
-->
## Upcoming Release
* Exposed SubscriptionPolicies in `Get-AzSubscription` [#12551]

## Version 1.9.2
* Updated `Connect-AzAccount` to accept parameter `MaxContextPopulation` [#9865]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,19 @@ public string CurrentStorageAccountName
}
}

private PSAzureSubscriptionPolicy _subscriptionPolicies;

public PSAzureSubscriptionPolicy SubscriptionPolicies {
get
{
if (this._subscriptionPolicies == null)
{
this._subscriptionPolicies= new PSAzureSubscriptionPolicy(this.GetSubscriptionPolicies());
}
return this._subscriptionPolicies;
}
}

public IDictionary<string, string> ExtendedProperties { get; } = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);

public string CurrentStorageAccount
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using Newtonsoft.Json;
using Microsoft.Azure.Internal.Subscriptions.Models;

namespace Microsoft.Azure.Commands.Profile.Models
{
public class PSAzureSubscriptionPolicy
{
/// <summary>
/// Default constructor
/// </summary>
public PSAzureSubscriptionPolicy()
{

}

/// <summary>
/// object constructor
/// </summary>
/// <param name="azureSubscriptionPolicies">Json string to convert</param>
public PSAzureSubscriptionPolicy(SubscriptionPolicies subscriptionPolicies)
{
if (subscriptionPolicies != null)
{
this.LocationPlacementId = subscriptionPolicies.LocationPlacementId;
this.QuotaId = subscriptionPolicies.QuotaId;
this.SpendingLimit = subscriptionPolicies.SpendingLimit.ToString();
}
}

/// <summary>
/// string constructor
/// </summary>
/// <param name="azureSubscriptionPolicies">Json string to convert</param>
public PSAzureSubscriptionPolicy(string azureSubscriptionPolicies) : this(string.IsNullOrEmpty(azureSubscriptionPolicies)?null:JsonConvert.DeserializeObject<SubscriptionPolicies>(azureSubscriptionPolicies)) { }

public string LocationPlacementId { get; private set; }

public string QuotaId { get; private set; }

public string SpendingLimit { get; private set; }

public override string ToString()
{
return JsonConvert.SerializeObject(this, Formatting.Indented,
new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore });
}

}
}
32 changes: 16 additions & 16 deletions tools/Common.Netcore.Dependencies.targets
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
<ItemGroup>
<PackageReference Include="Microsoft.Rest.ClientRuntime" Version="2.3.20"/>
<PackageReference Include="Microsoft.Rest.ClientRuntime.Azure" Version="3.3.19"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Aks" Version="1.3.20-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Authentication.Abstractions" Version="1.3.20-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Authorization" Version="1.3.20-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Common" Version="1.3.20-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Compute" Version="1.3.20-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Graph.Rbac" Version="1.3.20-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.KeyVault" Version="1.3.20-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Monitor" Version="1.3.20-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Network" Version="1.3.20-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.PolicyInsights" Version="1.3.20-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.ResourceManager" Version="1.3.20-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Storage" Version="1.3.20-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Storage.Management" Version="1.3.20-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Strategies" Version="1.3.20-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Websites" Version="1.3.20-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Aks" Version="1.3.21-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Authentication.Abstractions" Version="1.3.21-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Authorization" Version="1.3.21-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Common" Version="1.3.21-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Compute" Version="1.3.21-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Graph.Rbac" Version="1.3.21-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.KeyVault" Version="1.3.21-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Monitor" Version="1.3.21-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Network" Version="1.3.21-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.PolicyInsights" Version="1.3.21-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.ResourceManager" Version="1.3.21-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Storage" Version="1.3.21-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Storage.Management" Version="1.3.21-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Strategies" Version="1.3.21-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Websites" Version="1.3.21-preview"/>
</ItemGroup>
<ItemGroup Condition="'$(IsTestProject)' != 'true'">
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.4.0">
Expand All @@ -32,7 +32,7 @@
<PackageReference Include="PowerShellStandard.Library" Version="5.1.0" PrivateAssets="All" />
</ItemGroup>
<PropertyGroup>
<StorageToolsPath>$(NugetPackageRoot)\microsoft.azure.powershell.storage\1.3.20-preview\tools\</StorageToolsPath>
<StorageToolsPath>$(NugetPackageRoot)\microsoft.azure.powershell.storage\1.3.21-preview\tools\</StorageToolsPath>
</PropertyGroup>
<ItemGroup Condition="'$(OmitJsonPackage)' != 'true'">
<PackageReference Include="Newtonsoft.Json" Version="10.0.3"/>
Expand Down