diff --git a/README.md b/README.md
index b32bbd82af9c..455e0aabbf99 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,4 @@
+
# Microsoft Azure PowerShell
This repository contains a set of PowerShell cmdlets for developers and administrators to develop, deploy and manage Microsoft Azure applications.
diff --git a/src/Common/Commands.Profile/Models/PsAzureSubscription.cs b/src/Common/Commands.Profile/Models/PsAzureSubscription.cs
index 8e1e6846086e..503df09b8533 100644
--- a/src/Common/Commands.Profile/Models/PsAzureSubscription.cs
+++ b/src/Common/Commands.Profile/Models/PsAzureSubscription.cs
@@ -12,12 +12,29 @@
// limitations under the License.
// ----------------------------------------------------------------------------------
+using System.Linq;
+using Microsoft.Azure.Common.Authentication;
using Microsoft.Azure.Common.Authentication.Models;
namespace Microsoft.WindowsAzure.Commands.Profile.Models
{
public class PSAzureSubscription
{
+ public PSAzureSubscription() {}
+ public PSAzureSubscription(AzureSubscription subscription, AzureProfile profile)
+ {
+ SubscriptionId = subscription.Id.ToString();
+ SubscriptionName = subscription.Name;
+ Environment = subscription.Environment;
+ SupportedModes = subscription.GetProperty(AzureSubscription.Property.SupportedModes);
+ DefaultAccount = subscription.Account;
+ Accounts = profile.Accounts.Values.Where(a => a.HasSubscription(subscription.Id)).ToArray();
+ IsDefault = subscription.IsPropertySet(AzureSubscription.Property.Default);
+ IsCurrent = profile.Context.Subscription != null && profile.Context.Subscription.Id == subscription.Id;
+ CurrentStorageAccountName = subscription.GetProperty(AzureSubscription.Property.StorageAccount);
+ TenantId = subscription.GetPropertyAsArray(AzureSubscription.Property.Tenants).FirstOrDefault();
+ }
+
public string SubscriptionId { get; set; }
public string SubscriptionName { get; set; }
public string Environment { get; set; }
diff --git a/src/Common/Commands.Profile/Models/PsAzureSubscriptionExtended.cs b/src/Common/Commands.Profile/Models/PsAzureSubscriptionExtended.cs
index 763647ff2b26..dac56ab51dc5 100644
--- a/src/Common/Commands.Profile/Models/PsAzureSubscriptionExtended.cs
+++ b/src/Common/Commands.Profile/Models/PsAzureSubscriptionExtended.cs
@@ -29,6 +29,7 @@ public PSAzureSubscriptionExtended(PSAzureSubscription subscription)
base.Accounts = subscription.Accounts;
base.IsDefault = subscription.IsDefault;
base.IsCurrent = subscription.IsCurrent;
+ base.TenantId = subscription.TenantId;
}
public string ActiveDirectoryUserId { get; set; }
public AzureAccount Account { get; set; }
diff --git a/src/Common/Commands.Profile/Subscription/GetAzureSubscription.cs b/src/Common/Commands.Profile/Subscription/GetAzureSubscription.cs
index 88fb75bcaacd..c63ef44e2931 100644
--- a/src/Common/Commands.Profile/Subscription/GetAzureSubscription.cs
+++ b/src/Common/Commands.Profile/Subscription/GetAzureSubscription.cs
@@ -32,7 +32,7 @@ namespace Microsoft.WindowsAzure.Commands.Profile
/// the AzureProfile layer.
///
[Cmdlet(VerbsCommon.Get, "AzureSubscription", DefaultParameterSetName = "ByName")]
- [OutputType(typeof(AzureSubscription))]
+ [OutputType(typeof(PSAzureSubscription))]
public class GetAzureSubscriptionCommand : SubscriptionCmdletBase
{
public GetAzureSubscriptionCommand()
@@ -141,29 +141,12 @@ private void WriteSubscriptions(IEnumerable subscriptions)
}
else
{
- subscriptionOutput = subscriptions.Select(ConstructPsAzureSubscription);
+ subscriptionOutput = subscriptions.Select(s => new PSAzureSubscription(s, ProfileClient.Profile));
}
WriteObject(subscriptionOutput, true);
}
- private PSAzureSubscription ConstructPsAzureSubscription(AzureSubscription subscription)
- {
- PSAzureSubscription psObject = new PSAzureSubscription();
-
- psObject.SubscriptionId = subscription.Id.ToString();
- psObject.SubscriptionName = subscription.Name;
- psObject.Environment = subscription.Environment;
- psObject.SupportedModes = subscription.GetProperty(AzureSubscription.Property.SupportedModes);
- psObject.DefaultAccount = subscription.Account;
- psObject.Accounts = ProfileClient.Profile.Accounts.Values.Where(a => a.HasSubscription(subscription.Id)).ToArray();
- psObject.IsDefault = subscription.IsPropertySet(AzureSubscription.Property.Default);
- psObject.IsCurrent = Profile.Context.Subscription != null && Profile.Context.Subscription.Id == subscription.Id;
- psObject.CurrentStorageAccountName = subscription.GetProperty(AzureSubscription.Property.StorageAccount);
- psObject.TenantId = subscription.GetPropertyAsArray(AzureSubscription.Property.Tenants).FirstOrDefault();
- return psObject;
- }
-
private PSAzureSubscriptionExtended ConstructPsAzureSubscriptionExtended(AzureSubscription subscription, IClientFactory clientFactory)
{
using (var client = clientFactory.CreateClient(Profile, subscription, AzureEnvironment.Endpoint.ServiceManagement))
@@ -172,8 +155,8 @@ private PSAzureSubscriptionExtended ConstructPsAzureSubscriptionExtended(AzureSu
var environment = ProfileClient.GetEnvironmentOrDefault(subscription.Environment);
var account = ProfileClient.Profile.Accounts[subscription.Account];
bool isCert = account.Type == AzureAccount.AccountType.Certificate;
-
- PSAzureSubscriptionExtended result = new PSAzureSubscriptionExtended(ConstructPsAzureSubscription(subscription))
+ var psAzureSubscription = new PSAzureSubscription(subscription, ProfileClient.Profile);
+ PSAzureSubscriptionExtended result = new PSAzureSubscriptionExtended(psAzureSubscription)
{
AccountAdminLiveEmailId = response.AccountAdminLiveEmailId,
ActiveDirectoryUserId = subscription.Account,
diff --git a/src/Common/Commands.Profile/Subscription/SelectAzureSubscription.cs b/src/Common/Commands.Profile/Subscription/SelectAzureSubscription.cs
index 1f5c08f2023d..8e0d3ed0136a 100644
--- a/src/Common/Commands.Profile/Subscription/SelectAzureSubscription.cs
+++ b/src/Common/Commands.Profile/Subscription/SelectAzureSubscription.cs
@@ -20,13 +20,14 @@
using Microsoft.WindowsAzure.Commands.Common.Properties;
using Microsoft.WindowsAzure.Commands.Utilities.Profile;
using Microsoft.Azure.Common.Authentication;
+using Microsoft.WindowsAzure.Commands.Profile.Models;
namespace Microsoft.WindowsAzure.Commands.Profile
{
[Cmdlet(VerbsCommon.Select, "AzureSubscription", DefaultParameterSetName = SelectSubscriptionByNameParameterSet)]
- [OutputType(typeof(AzureSubscription))]
+ [OutputType(typeof(PSAzureSubscription))]
public class SelectAzureSubscriptionCommand : SubscriptionCmdletBase
{
private const string SelectSubscriptionByIdParameterSet = "SelectSubscriptionByIdParameterSet";
@@ -123,7 +124,7 @@ public override void ExecuteCmdlet()
if (PassThru.IsPresent && azureSubscription != null)
{
- WriteObject(azureSubscription);
+ WriteObject(new PSAzureSubscription(azureSubscription, ProfileClient.Profile));
}
}
diff --git a/src/ServiceManagement/Services/Commands.Test/Profile/ProfileCmdltsTests.cs b/src/ServiceManagement/Services/Commands.Test/Profile/ProfileCmdltsTests.cs
index 705b9fde57ab..081523905fbe 100644
--- a/src/ServiceManagement/Services/Commands.Test/Profile/ProfileCmdltsTests.cs
+++ b/src/ServiceManagement/Services/Commands.Test/Profile/ProfileCmdltsTests.cs
@@ -23,6 +23,7 @@
using Microsoft.WindowsAzure.Commands.Common;
using Microsoft.WindowsAzure.Commands.Common.Test.Mocks;
using Microsoft.WindowsAzure.Commands.Profile;
+using Microsoft.WindowsAzure.Commands.Profile.Models;
using Microsoft.WindowsAzure.Commands.Utilities.Common;
using System;
using System.Collections.Generic;
@@ -731,7 +732,7 @@ public void SelectAzureSubscriptionWithPassthroughPrintsSubscription()
// Verify
Assert.Equal(1, commandRuntimeMock.OutputPipeline.Count);
- Assert.True(commandRuntimeMock.OutputPipeline[0] is AzureSubscription);
+ Assert.True(commandRuntimeMock.OutputPipeline[0] is PSAzureSubscription);
}
[Fact]