From e82498b67fdd03fc4a97e4e2171bc26156427226 Mon Sep 17 00:00:00 2001 From: Hovsep Mkrtchyan Date: Wed, 21 Oct 2015 15:59:36 -0700 Subject: [PATCH 1/5] [#105517922] Update Select-AzureRmSubscription to pass in subscriptionId only or subscriptionName only --- .../Context/SetAzureRMContext.cs | 60 +++++++++++++------ .../Models/RMProfileClient.cs | 12 ++-- .../Properties/Resources.Designer.cs | 18 ++++++ .../Properties/Resources.resx | 6 ++ 4 files changed, 74 insertions(+), 22 deletions(-) diff --git a/src/ResourceManager/Profile/Commands.Profile/Context/SetAzureRMContext.cs b/src/ResourceManager/Profile/Commands.Profile/Context/SetAzureRMContext.cs index a0a4f38fb9b5..603ae5c795d9 100644 --- a/src/ResourceManager/Profile/Commands.Profile/Context/SetAzureRMContext.cs +++ b/src/ResourceManager/Profile/Commands.Profile/Context/SetAzureRMContext.cs @@ -17,38 +17,36 @@ using Microsoft.Azure.Commands.Profile.Models; using Microsoft.Azure.Commands.ResourceManager.Common; using Microsoft.WindowsAzure.Commands.Common; +using Microsoft.Azure.Commands.Profile.Properties; namespace Microsoft.Azure.Commands.Profile { /// /// Cmdlet to change current Azure context. /// - [Cmdlet(VerbsCommon.Set, "AzureRmContext", DefaultParameterSetName =TenantIdAndSubscriptionIdParameterSet)] + [Cmdlet(VerbsCommon.Set, "AzureRmContext", DefaultParameterSetName = SubscriptionNameParameterSet)] [Alias("Select-AzureRmSubscription")] [OutputType(typeof(PSAzureContext))] public class SetAzureRMContextCommand : AzureRMCmdlet { - private const string TenantIdParameterSet = "TenantId"; - private const string SubscriptionIdParameterSet = "Subscription"; - private const string TenantIdAndSubscriptionIdParameterSet = "TenantIdAndSubscriptionId"; + private const string SubscriptionNameParameterSet = "SubscriptionName"; + private const string SubscriptionIdParameterSet = "SubscriptionId"; private const string ContextParameterSet = "Context"; - [Parameter(ParameterSetName = TenantIdParameterSet, Mandatory = false, HelpMessage = "TenantId name or ID", ValueFromPipelineByPropertyName=true)] - [Parameter(ParameterSetName = TenantIdAndSubscriptionIdParameterSet, Mandatory = false, HelpMessage = "TenantId name or ID", ValueFromPipelineByPropertyName=true)] + [Parameter(ParameterSetName = SubscriptionNameParameterSet, Mandatory = false, HelpMessage = "TenantId name or ID", ValueFromPipelineByPropertyName = true)] + [Parameter(ParameterSetName = SubscriptionIdParameterSet, Mandatory = false, HelpMessage = "TenantId name or ID", ValueFromPipelineByPropertyName = true)] [ValidateNotNullOrEmpty] public string TenantId { get; set; } - - [Parameter(ParameterSetName = SubscriptionIdParameterSet, Mandatory = true, HelpMessage = "Subscription", ValueFromPipelineByPropertyName=true)] - [Parameter(ParameterSetName = TenantIdAndSubscriptionIdParameterSet, Mandatory = true, HelpMessage = "Subscription", ValueFromPipelineByPropertyName=true)] + + [Parameter(ParameterSetName = SubscriptionIdParameterSet, Mandatory = true, HelpMessage = "Subscription", ValueFromPipelineByPropertyName = true)] [ValidateNotNullOrEmpty] public string SubscriptionId { get; set; } - [Parameter(ParameterSetName = SubscriptionIdParameterSet, Mandatory = false, HelpMessage = "Subscription Name", ValueFromPipelineByPropertyName=true)] - [Parameter(ParameterSetName = TenantIdAndSubscriptionIdParameterSet, Mandatory = false, HelpMessage = "Subscription Name", ValueFromPipelineByPropertyName=true)] + [Parameter(ParameterSetName = SubscriptionNameParameterSet, Mandatory = true, HelpMessage = "Subscription Name", ValueFromPipelineByPropertyName = true)] [ValidateNotNullOrEmpty] - public string SubscriptionName{ get; set; } - - [Parameter(ParameterSetName = ContextParameterSet, Mandatory = true, HelpMessage = "Context", ValueFromPipeline=true)] + public string SubscriptionName { get; set; } + + [Parameter(ParameterSetName = ContextParameterSet, Mandatory = true, HelpMessage = "Context", ValueFromPipeline = true)] public PSAzureContext Context { get; set; } protected override void ProcessRecord() @@ -58,14 +56,40 @@ protected override void ProcessRecord() AzureRmProfileProvider.Instance.Profile.SetContextWithCache(new AzureContext(Context.Subscription, Context.Account, Context.Environment, Context.Tenant)); } - else + else if (ParameterSetName == SubscriptionNameParameterSet) { var profileClient = new RMProfileClient(AzureRmProfileProvider.Instance.Profile); - profileClient.SetCurrentContext(SubscriptionId, TenantId); - if (!string.IsNullOrWhiteSpace(SubscriptionName)) + AzureSubscription subscription = null; + string tenantId = AzureRmProfileProvider.Instance.Profile.Context.Tenant.Id.ToString(); + + if (string.IsNullOrWhiteSpace(TenantId)) + { + WriteWarning( + string.Format( + Resources.CurrentTenantInUse, + tenantId)); + } + else { - AzureRmProfileProvider.Instance.Profile.Context.Subscription.Name = SubscriptionName; + tenantId = TenantId; } + + if (!profileClient.TryGetSubscriptionByName( + tenantId, + SubscriptionName, + out subscription)) + { + throw new ItemNotFoundException( + string.Format(Resources.SubscriptionNameNotFoundError, SubscriptionName)); + } + + profileClient.SetCurrentContext(subscription.Id.ToString(), tenantId, verifySubscription: false); + AzureRmProfileProvider.Instance.Profile.Context.Subscription.Name = SubscriptionName; + } + else if (ParameterSetName == SubscriptionIdParameterSet) + { + var profileClient = new RMProfileClient(AzureRmProfileProvider.Instance.Profile); + profileClient.SetCurrentContext(SubscriptionId, TenantId); } WriteObject((PSAzureContext)AzureRmProfileProvider.Instance.Profile.Context); } diff --git a/src/ResourceManager/Profile/Commands.Profile/Models/RMProfileClient.cs b/src/ResourceManager/Profile/Commands.Profile/Models/RMProfileClient.cs index dcec21991609..de7e6a3dfb4e 100644 --- a/src/ResourceManager/Profile/Commands.Profile/Models/RMProfileClient.cs +++ b/src/ResourceManager/Profile/Commands.Profile/Models/RMProfileClient.cs @@ -101,7 +101,7 @@ public AzureRMProfile Login(AzureAccount account, AzureEnvironment environment, return _profile; } - public AzureContext SetCurrentContext(string subscriptionId, string tenantId) + public AzureContext SetCurrentContext(string subscriptionId, string tenantId, bool verifySubscription = true) { if (!string.IsNullOrWhiteSpace(tenantId)) { @@ -123,8 +123,12 @@ public AzureContext SetCurrentContext(string subscriptionId, string tenantId) if (!string.IsNullOrWhiteSpace(subscriptionId)) { - if (!ListSubscriptions(_profile.Context.Tenant.Id.ToString()).Any(s => - string.Equals(s.Id.ToString(), subscriptionId, StringComparison.OrdinalIgnoreCase) ) ) + var subscription = ListSubscriptions(_profile.Context.Tenant.Id.ToString()) + .FirstOrDefault(s => + string.Equals(s.Id.ToString(), subscriptionId, StringComparison.OrdinalIgnoreCase)); + + if (verifySubscription && + subscription == null) { throw new ArgumentException(string.Format( "Provided subscription {0} does not exist under current tenant {1}", subscriptionId, _profile.Context.Tenant.Id)); @@ -136,7 +140,7 @@ public AzureContext SetCurrentContext(string subscriptionId, string tenantId) newSubscription.Account = _profile.Context.Subscription.Account; newSubscription.Environment = _profile.Context.Subscription.Environment; newSubscription.Properties = _profile.Context.Subscription.Properties; - newSubscription.Name = null; + newSubscription.Name = (subscription == null) ? null : subscription.Name; } _profile.SetContextWithCache(new AzureContext( diff --git a/src/ResourceManager/Profile/Commands.Profile/Properties/Resources.Designer.cs b/src/ResourceManager/Profile/Commands.Profile/Properties/Resources.Designer.cs index 4a66c728e1aa..3fcf05ff0618 100644 --- a/src/ResourceManager/Profile/Commands.Profile/Properties/Resources.Designer.cs +++ b/src/ResourceManager/Profile/Commands.Profile/Properties/Resources.Designer.cs @@ -105,6 +105,15 @@ internal static string CommonTenantAuthFailed { } } + /// + /// Looks up a localized string similar to Current tenant with Id '{0}' will be used.. + /// + internal static string CurrentTenantInUse { + get { + return ResourceManager.GetString("CurrentTenantInUse", resourceCulture); + } + } + /// /// Looks up a localized string similar to The provided subscription ID "{0}" is not a valid Guid.. /// @@ -132,6 +141,15 @@ internal static string NoValidTenant { } } + /// + /// Looks up a localized string similar to Unable to find subscription with name '{0}'.. + /// + internal static string SubscriptionNameNotFoundError { + get { + return ResourceManager.GetString("SubscriptionNameNotFoundError", resourceCulture); + } + } + /// /// Looks up a localized string similar to Subscription {0} was not found in tenant {1}. Please verify that the subscription exists in this tenant.. /// diff --git a/src/ResourceManager/Profile/Commands.Profile/Properties/Resources.resx b/src/ResourceManager/Profile/Commands.Profile/Properties/Resources.resx index 9e39364a5eff..56f05dacb496 100644 --- a/src/ResourceManager/Profile/Commands.Profile/Properties/Resources.resx +++ b/src/ResourceManager/Profile/Commands.Profile/Properties/Resources.resx @@ -132,6 +132,9 @@ Could not authenticate your user account {0} with the common tenant. Please login again using Login-AzureRmAccount. + + Current tenant with Id '{0}' will be used. + The provided subscription ID "{0}" is not a valid Guid. @@ -141,6 +144,9 @@ Please provide a valid tenant Id on the command line or execute Login-AzureRmAccount. + + Unable to find subscription with name '{0}'. + Subscription {0} was not found in tenant {1}. Please verify that the subscription exists in this tenant. From c5c79e292da882bb0b18fd1a7affdb4e37595aaa Mon Sep 17 00:00:00 2001 From: Hovsep Mkrtchyan Date: Wed, 21 Oct 2015 16:44:33 -0700 Subject: [PATCH 2/5] Fixed failing tests --- .../ContextCmdletTests.cs | 6 +- .../PipingWithRmContextWorks.json | 160 ++++++++++++++---- 2 files changed, 132 insertions(+), 34 deletions(-) diff --git a/src/ResourceManager/Profile/Commands.Profile.Test/ContextCmdletTests.cs b/src/ResourceManager/Profile/Commands.Profile.Test/ContextCmdletTests.cs index 462f785dd2ed..08878f8fbd46 100644 --- a/src/ResourceManager/Profile/Commands.Profile.Test/ContextCmdletTests.cs +++ b/src/ResourceManager/Profile/Commands.Profile.Test/ContextCmdletTests.cs @@ -24,6 +24,7 @@ using System; using Microsoft.Azure.Commands.Profile.Models; using Microsoft.WindowsAzure.Commands.Test.Utilities.Common; +using System.Management.Automation; namespace Microsoft.Azure.Commands.ResourceManager.Profile.Test { @@ -58,7 +59,7 @@ public void GetAzureContext() var context = (PSAzureContext) commandRuntimeMock.OutputPipeline[0]; Assert.Equal("test", context.Subscription.SubscriptionName); } - + [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void SelectAzureContextWithNoSubscriptionAndTenant() @@ -76,7 +77,8 @@ public void SelectAzureContextWithNoSubscriptionAndTenant() // Verify Assert.True(commandRuntimeMock.OutputPipeline.Count == 1); var context = (PSAzureContext)commandRuntimeMock.OutputPipeline[0]; - Assert.Equal("72f988bf-86f1-41af-91ab-2d7cd011db47", context.Tenant.TenantId); + // TenantId is not sufficient to change the context. + Assert.NotEqual("72f988bf-86f1-41af-91ab-2d7cd011db47", context.Tenant.TenantId); } [Fact] diff --git a/src/ResourceManager/Profile/Commands.Profile.Test/SessionRecords/Microsoft.Azure.Commands.Profile.Test.SubscriptionCmdletTests/PipingWithRmContextWorks.json b/src/ResourceManager/Profile/Commands.Profile.Test/SessionRecords/Microsoft.Azure.Commands.Profile.Test.SubscriptionCmdletTests/PipingWithRmContextWorks.json index c81f631c6bd2..b4dd48c3dc57 100644 --- a/src/ResourceManager/Profile/Commands.Profile.Test/SessionRecords/Microsoft.Azure.Commands.Profile.Test.SubscriptionCmdletTests/PipingWithRmContextWorks.json +++ b/src/ResourceManager/Profile/Commands.Profile.Test/SessionRecords/Microsoft.Azure.Commands.Profile.Test.SubscriptionCmdletTests/PipingWithRmContextWorks.json @@ -10,10 +10,10 @@ "Microsoft.Azure.Subscriptions.SubscriptionClient/2.0.0.0" ] }, - "ResponseBody": "{\r\n \"value\": [\r\n {\r\n \"id\": \"/subscriptions/00977cdb-163f-435f-9c32-39ec8ae61f4d\",\r\n \"subscriptionId\": \"00977cdb-163f-435f-9c32-39ec8ae61f4d\",\r\n \"displayName\": \"node\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/279b0675-cf67-467f-98f0-67ae31eb540f\",\r\n \"subscriptionId\": \"279b0675-cf67-467f-98f0-67ae31eb540f\",\r\n \"displayName\": \"Azure SDK CI\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/2c224e7e-3ef5-431d-a57b-e71f4662e3a6\",\r\n \"subscriptionId\": \"2c224e7e-3ef5-431d-a57b-e71f4662e3a6\",\r\n \"displayName\": \"Node CLI Test\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/69801886-4b2b-493b-ba5b-3b26dabadadc\",\r\n \"subscriptionId\": \"69801886-4b2b-493b-ba5b-3b26dabadadc\",\r\n \"displayName\": \"WebStackAndEF_TestInfra\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/6b085460-5f21-477e-ba44-1035046e9101\",\r\n \"subscriptionId\": \"6b085460-5f21-477e-ba44-1035046e9101\",\r\n \"displayName\": \"Azure SDK Infrastructure\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/9ed7cca5-c306-4f66-9d1c-2766e67013d8\",\r\n \"subscriptionId\": \"9ed7cca5-c306-4f66-9d1c-2766e67013d8\",\r\n \"displayName\": \"FISMA Pen Testing Subscription\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/c9cbd920-c00c-427c-852b-8aaf38badaeb\",\r\n \"subscriptionId\": \"c9cbd920-c00c-427c-852b-8aaf38badaeb\",\r\n \"displayName\": \"Azure SDK Powershell Test\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/d1e52cbc-b073-42e2-a0a0-c2f547118a6e\",\r\n \"subscriptionId\": \"d1e52cbc-b073-42e2-a0a0-c2f547118a6e\",\r\n \"displayName\": \"Test Subscription 1 for Migration\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/db1ab6f0-4769-4b27-930e-01e2ef9c123c\",\r\n \"subscriptionId\": \"db1ab6f0-4769-4b27-930e-01e2ef9c123c\",\r\n \"displayName\": \"Azure SDK sandbox\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/b6b78feb-3074-4129-8748-42cee6c73020\",\r\n \"subscriptionId\": \"b6b78feb-3074-4129-8748-42cee6c73020\",\r\n \"displayName\": \"XFD Data Systems - Public\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n }\r\n ]\r\n}", + "ResponseBody": "{\r\n \"value\": [\r\n {\r\n \"id\": \"/subscriptions/00977cdb-163f-435f-9c32-39ec8ae61f4d\",\r\n \"subscriptionId\": \"00977cdb-163f-435f-9c32-39ec8ae61f4d\",\r\n \"displayName\": \"node\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/2c224e7e-3ef5-431d-a57b-e71f4662e3a6\",\r\n \"subscriptionId\": \"2c224e7e-3ef5-431d-a57b-e71f4662e3a6\",\r\n \"displayName\": \"Node CLI Test\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/6b085460-5f21-477e-ba44-1035046e9101\",\r\n \"subscriptionId\": \"6b085460-5f21-477e-ba44-1035046e9101\",\r\n \"displayName\": \"Azure SDK Infrastructure\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/db1ab6f0-4769-4b27-930e-01e2ef9c123c\",\r\n \"subscriptionId\": \"db1ab6f0-4769-4b27-930e-01e2ef9c123c\",\r\n \"displayName\": \"Azure SDK sandbox\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n }\r\n ]\r\n}", "ResponseHeaders": { "Content-Length": [ - "2747" + "1081" ], "Content-Type": [ "application/json; charset=utf-8" @@ -25,16 +25,16 @@ "no-cache" ], "x-ms-ratelimit-remaining-tenant-reads": [ - "14994" + "14997" ], "x-ms-request-id": [ - "6a51dccb-b1f8-4484-a75b-2dc9c62a91f3" + "284d131d-ec1d-473e-82b2-022824dbd382" ], "x-ms-correlation-request-id": [ - "6a51dccb-b1f8-4484-a75b-2dc9c62a91f3" + "284d131d-ec1d-473e-82b2-022824dbd382" ], "x-ms-routing-request-id": [ - "WESTUS:20151002T035449Z:6a51dccb-b1f8-4484-a75b-2dc9c62a91f3" + "WESTUS:20151022T003227Z:284d131d-ec1d-473e-82b2-022824dbd382" ], "Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" @@ -43,7 +43,7 @@ "no-cache" ], "Date": [ - "Fri, 02 Oct 2015 03:54:49 GMT" + "Thu, 22 Oct 2015 00:32:27 GMT" ] }, "StatusCode": 200 @@ -58,10 +58,10 @@ "Microsoft.Azure.Subscriptions.SubscriptionClient/2.0.0.0" ] }, - "ResponseBody": "{\r\n \"value\": [\r\n {\r\n \"id\": \"/subscriptions/00977cdb-163f-435f-9c32-39ec8ae61f4d\",\r\n \"subscriptionId\": \"00977cdb-163f-435f-9c32-39ec8ae61f4d\",\r\n \"displayName\": \"node\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/279b0675-cf67-467f-98f0-67ae31eb540f\",\r\n \"subscriptionId\": \"279b0675-cf67-467f-98f0-67ae31eb540f\",\r\n \"displayName\": \"Azure SDK CI\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/2c224e7e-3ef5-431d-a57b-e71f4662e3a6\",\r\n \"subscriptionId\": \"2c224e7e-3ef5-431d-a57b-e71f4662e3a6\",\r\n \"displayName\": \"Node CLI Test\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/69801886-4b2b-493b-ba5b-3b26dabadadc\",\r\n \"subscriptionId\": \"69801886-4b2b-493b-ba5b-3b26dabadadc\",\r\n \"displayName\": \"WebStackAndEF_TestInfra\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/6b085460-5f21-477e-ba44-1035046e9101\",\r\n \"subscriptionId\": \"6b085460-5f21-477e-ba44-1035046e9101\",\r\n \"displayName\": \"Azure SDK Infrastructure\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/9ed7cca5-c306-4f66-9d1c-2766e67013d8\",\r\n \"subscriptionId\": \"9ed7cca5-c306-4f66-9d1c-2766e67013d8\",\r\n \"displayName\": \"FISMA Pen Testing Subscription\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/c9cbd920-c00c-427c-852b-8aaf38badaeb\",\r\n \"subscriptionId\": \"c9cbd920-c00c-427c-852b-8aaf38badaeb\",\r\n \"displayName\": \"Azure SDK Powershell Test\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/d1e52cbc-b073-42e2-a0a0-c2f547118a6e\",\r\n \"subscriptionId\": \"d1e52cbc-b073-42e2-a0a0-c2f547118a6e\",\r\n \"displayName\": \"Test Subscription 1 for Migration\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/db1ab6f0-4769-4b27-930e-01e2ef9c123c\",\r\n \"subscriptionId\": \"db1ab6f0-4769-4b27-930e-01e2ef9c123c\",\r\n \"displayName\": \"Azure SDK sandbox\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/b6b78feb-3074-4129-8748-42cee6c73020\",\r\n \"subscriptionId\": \"b6b78feb-3074-4129-8748-42cee6c73020\",\r\n \"displayName\": \"XFD Data Systems - Public\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n }\r\n ]\r\n}", + "ResponseBody": "{\r\n \"value\": [\r\n {\r\n \"id\": \"/subscriptions/00977cdb-163f-435f-9c32-39ec8ae61f4d\",\r\n \"subscriptionId\": \"00977cdb-163f-435f-9c32-39ec8ae61f4d\",\r\n \"displayName\": \"node\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/2c224e7e-3ef5-431d-a57b-e71f4662e3a6\",\r\n \"subscriptionId\": \"2c224e7e-3ef5-431d-a57b-e71f4662e3a6\",\r\n \"displayName\": \"Node CLI Test\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/6b085460-5f21-477e-ba44-1035046e9101\",\r\n \"subscriptionId\": \"6b085460-5f21-477e-ba44-1035046e9101\",\r\n \"displayName\": \"Azure SDK Infrastructure\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/db1ab6f0-4769-4b27-930e-01e2ef9c123c\",\r\n \"subscriptionId\": \"db1ab6f0-4769-4b27-930e-01e2ef9c123c\",\r\n \"displayName\": \"Azure SDK sandbox\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n }\r\n ]\r\n}", "ResponseHeaders": { "Content-Length": [ - "2747" + "1081" ], "Content-Type": [ "application/json; charset=utf-8" @@ -73,16 +73,16 @@ "no-cache" ], "x-ms-ratelimit-remaining-tenant-reads": [ - "14993" + "14996" ], "x-ms-request-id": [ - "7d01be5f-25e0-4246-abab-9565e9bf07bb" + "55b62765-1a90-4adf-86a8-68ad7640328a" ], "x-ms-correlation-request-id": [ - "7d01be5f-25e0-4246-abab-9565e9bf07bb" + "55b62765-1a90-4adf-86a8-68ad7640328a" ], "x-ms-routing-request-id": [ - "WESTUS:20151002T035450Z:7d01be5f-25e0-4246-abab-9565e9bf07bb" + "WESTUS:20151022T003228Z:55b62765-1a90-4adf-86a8-68ad7640328a" ], "Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" @@ -91,7 +91,7 @@ "no-cache" ], "Date": [ - "Fri, 02 Oct 2015 03:54:49 GMT" + "Thu, 22 Oct 2015 00:32:28 GMT" ] }, "StatusCode": 200 @@ -106,10 +106,10 @@ "Microsoft.Azure.Subscriptions.SubscriptionClient/2.0.0.0" ] }, - "ResponseBody": "{\r\n \"value\": [\r\n {\r\n \"id\": \"/subscriptions/00977cdb-163f-435f-9c32-39ec8ae61f4d\",\r\n \"subscriptionId\": \"00977cdb-163f-435f-9c32-39ec8ae61f4d\",\r\n \"displayName\": \"node\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/279b0675-cf67-467f-98f0-67ae31eb540f\",\r\n \"subscriptionId\": \"279b0675-cf67-467f-98f0-67ae31eb540f\",\r\n \"displayName\": \"Azure SDK CI\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/2c224e7e-3ef5-431d-a57b-e71f4662e3a6\",\r\n \"subscriptionId\": \"2c224e7e-3ef5-431d-a57b-e71f4662e3a6\",\r\n \"displayName\": \"Node CLI Test\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/69801886-4b2b-493b-ba5b-3b26dabadadc\",\r\n \"subscriptionId\": \"69801886-4b2b-493b-ba5b-3b26dabadadc\",\r\n \"displayName\": \"WebStackAndEF_TestInfra\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/6b085460-5f21-477e-ba44-1035046e9101\",\r\n \"subscriptionId\": \"6b085460-5f21-477e-ba44-1035046e9101\",\r\n \"displayName\": \"Azure SDK Infrastructure\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/9ed7cca5-c306-4f66-9d1c-2766e67013d8\",\r\n \"subscriptionId\": \"9ed7cca5-c306-4f66-9d1c-2766e67013d8\",\r\n \"displayName\": \"FISMA Pen Testing Subscription\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/c9cbd920-c00c-427c-852b-8aaf38badaeb\",\r\n \"subscriptionId\": \"c9cbd920-c00c-427c-852b-8aaf38badaeb\",\r\n \"displayName\": \"Azure SDK Powershell Test\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/d1e52cbc-b073-42e2-a0a0-c2f547118a6e\",\r\n \"subscriptionId\": \"d1e52cbc-b073-42e2-a0a0-c2f547118a6e\",\r\n \"displayName\": \"Test Subscription 1 for Migration\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/db1ab6f0-4769-4b27-930e-01e2ef9c123c\",\r\n \"subscriptionId\": \"db1ab6f0-4769-4b27-930e-01e2ef9c123c\",\r\n \"displayName\": \"Azure SDK sandbox\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/b6b78feb-3074-4129-8748-42cee6c73020\",\r\n \"subscriptionId\": \"b6b78feb-3074-4129-8748-42cee6c73020\",\r\n \"displayName\": \"XFD Data Systems - Public\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n }\r\n ]\r\n}", + "ResponseBody": "{\r\n \"value\": [\r\n {\r\n \"id\": \"/subscriptions/00977cdb-163f-435f-9c32-39ec8ae61f4d\",\r\n \"subscriptionId\": \"00977cdb-163f-435f-9c32-39ec8ae61f4d\",\r\n \"displayName\": \"node\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/2c224e7e-3ef5-431d-a57b-e71f4662e3a6\",\r\n \"subscriptionId\": \"2c224e7e-3ef5-431d-a57b-e71f4662e3a6\",\r\n \"displayName\": \"Node CLI Test\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/6b085460-5f21-477e-ba44-1035046e9101\",\r\n \"subscriptionId\": \"6b085460-5f21-477e-ba44-1035046e9101\",\r\n \"displayName\": \"Azure SDK Infrastructure\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/db1ab6f0-4769-4b27-930e-01e2ef9c123c\",\r\n \"subscriptionId\": \"db1ab6f0-4769-4b27-930e-01e2ef9c123c\",\r\n \"displayName\": \"Azure SDK sandbox\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n }\r\n ]\r\n}", "ResponseHeaders": { "Content-Length": [ - "2747" + "1081" ], "Content-Type": [ "application/json; charset=utf-8" @@ -121,16 +121,112 @@ "no-cache" ], "x-ms-ratelimit-remaining-tenant-reads": [ - "14992" + "14995" + ], + "x-ms-request-id": [ + "e56eae11-deb0-40ff-8247-33e26f6584d4" + ], + "x-ms-correlation-request-id": [ + "e56eae11-deb0-40ff-8247-33e26f6584d4" + ], + "x-ms-routing-request-id": [ + "WESTUS:20151022T003236Z:e56eae11-deb0-40ff-8247-33e26f6584d4" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Thu, 22 Oct 2015 00:32:36 GMT" + ] + }, + "StatusCode": 200 + }, + { + "RequestUri": "/subscriptions?api-version=2014-04-01-preview", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnM/YXBpLXZlcnNpb249MjAxNC0wNC0wMS1wcmV2aWV3", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "User-Agent": [ + "Microsoft.Azure.Subscriptions.SubscriptionClient/2.0.0.0" + ] + }, + "ResponseBody": "{\r\n \"value\": [\r\n {\r\n \"id\": \"/subscriptions/00977cdb-163f-435f-9c32-39ec8ae61f4d\",\r\n \"subscriptionId\": \"00977cdb-163f-435f-9c32-39ec8ae61f4d\",\r\n \"displayName\": \"node\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/2c224e7e-3ef5-431d-a57b-e71f4662e3a6\",\r\n \"subscriptionId\": \"2c224e7e-3ef5-431d-a57b-e71f4662e3a6\",\r\n \"displayName\": \"Node CLI Test\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/6b085460-5f21-477e-ba44-1035046e9101\",\r\n \"subscriptionId\": \"6b085460-5f21-477e-ba44-1035046e9101\",\r\n \"displayName\": \"Azure SDK Infrastructure\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/db1ab6f0-4769-4b27-930e-01e2ef9c123c\",\r\n \"subscriptionId\": \"db1ab6f0-4769-4b27-930e-01e2ef9c123c\",\r\n \"displayName\": \"Azure SDK sandbox\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n }\r\n ]\r\n}", + "ResponseHeaders": { + "Content-Length": [ + "1081" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-tenant-reads": [ + "14994" + ], + "x-ms-request-id": [ + "dc675c1b-2b93-46f0-8398-71b55a651c1c" + ], + "x-ms-correlation-request-id": [ + "dc675c1b-2b93-46f0-8398-71b55a651c1c" + ], + "x-ms-routing-request-id": [ + "WESTUS:20151022T003237Z:dc675c1b-2b93-46f0-8398-71b55a651c1c" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Thu, 22 Oct 2015 00:32:37 GMT" + ] + }, + "StatusCode": 200 + }, + { + "RequestUri": "/subscriptions?api-version=2014-04-01-preview", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnM/YXBpLXZlcnNpb249MjAxNC0wNC0wMS1wcmV2aWV3", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "User-Agent": [ + "Microsoft.Azure.Subscriptions.SubscriptionClient/2.0.0.0" + ] + }, + "ResponseBody": "{\r\n \"value\": [\r\n {\r\n \"id\": \"/subscriptions/00977cdb-163f-435f-9c32-39ec8ae61f4d\",\r\n \"subscriptionId\": \"00977cdb-163f-435f-9c32-39ec8ae61f4d\",\r\n \"displayName\": \"node\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/2c224e7e-3ef5-431d-a57b-e71f4662e3a6\",\r\n \"subscriptionId\": \"2c224e7e-3ef5-431d-a57b-e71f4662e3a6\",\r\n \"displayName\": \"Node CLI Test\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/6b085460-5f21-477e-ba44-1035046e9101\",\r\n \"subscriptionId\": \"6b085460-5f21-477e-ba44-1035046e9101\",\r\n \"displayName\": \"Azure SDK Infrastructure\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/db1ab6f0-4769-4b27-930e-01e2ef9c123c\",\r\n \"subscriptionId\": \"db1ab6f0-4769-4b27-930e-01e2ef9c123c\",\r\n \"displayName\": \"Azure SDK sandbox\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n }\r\n ]\r\n}", + "ResponseHeaders": { + "Content-Length": [ + "1081" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-tenant-reads": [ + "14993" ], "x-ms-request-id": [ - "e33163a6-34c3-4f09-80ba-2f7f827c9415" + "c2c75a0f-db5e-4899-8957-699be8cab5d6" ], "x-ms-correlation-request-id": [ - "e33163a6-34c3-4f09-80ba-2f7f827c9415" + "c2c75a0f-db5e-4899-8957-699be8cab5d6" ], "x-ms-routing-request-id": [ - "WESTUS:20151002T035450Z:e33163a6-34c3-4f09-80ba-2f7f827c9415" + "WESTUS:20151022T003238Z:c2c75a0f-db5e-4899-8957-699be8cab5d6" ], "Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" @@ -139,7 +235,7 @@ "no-cache" ], "Date": [ - "Fri, 02 Oct 2015 03:54:49 GMT" + "Thu, 22 Oct 2015 00:32:38 GMT" ] }, "StatusCode": 200 @@ -154,10 +250,10 @@ "Microsoft.Azure.Subscriptions.SubscriptionClient/2.0.0.0" ] }, - "ResponseBody": "{\r\n \"value\": [\r\n {\r\n \"id\": \"/subscriptions/00977cdb-163f-435f-9c32-39ec8ae61f4d\",\r\n \"subscriptionId\": \"00977cdb-163f-435f-9c32-39ec8ae61f4d\",\r\n \"displayName\": \"node\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/279b0675-cf67-467f-98f0-67ae31eb540f\",\r\n \"subscriptionId\": \"279b0675-cf67-467f-98f0-67ae31eb540f\",\r\n \"displayName\": \"Azure SDK CI\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/2c224e7e-3ef5-431d-a57b-e71f4662e3a6\",\r\n \"subscriptionId\": \"2c224e7e-3ef5-431d-a57b-e71f4662e3a6\",\r\n \"displayName\": \"Node CLI Test\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/69801886-4b2b-493b-ba5b-3b26dabadadc\",\r\n \"subscriptionId\": \"69801886-4b2b-493b-ba5b-3b26dabadadc\",\r\n \"displayName\": \"WebStackAndEF_TestInfra\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/6b085460-5f21-477e-ba44-1035046e9101\",\r\n \"subscriptionId\": \"6b085460-5f21-477e-ba44-1035046e9101\",\r\n \"displayName\": \"Azure SDK Infrastructure\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/9ed7cca5-c306-4f66-9d1c-2766e67013d8\",\r\n \"subscriptionId\": \"9ed7cca5-c306-4f66-9d1c-2766e67013d8\",\r\n \"displayName\": \"FISMA Pen Testing Subscription\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/c9cbd920-c00c-427c-852b-8aaf38badaeb\",\r\n \"subscriptionId\": \"c9cbd920-c00c-427c-852b-8aaf38badaeb\",\r\n \"displayName\": \"Azure SDK Powershell Test\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/d1e52cbc-b073-42e2-a0a0-c2f547118a6e\",\r\n \"subscriptionId\": \"d1e52cbc-b073-42e2-a0a0-c2f547118a6e\",\r\n \"displayName\": \"Test Subscription 1 for Migration\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/db1ab6f0-4769-4b27-930e-01e2ef9c123c\",\r\n \"subscriptionId\": \"db1ab6f0-4769-4b27-930e-01e2ef9c123c\",\r\n \"displayName\": \"Azure SDK sandbox\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/b6b78feb-3074-4129-8748-42cee6c73020\",\r\n \"subscriptionId\": \"b6b78feb-3074-4129-8748-42cee6c73020\",\r\n \"displayName\": \"XFD Data Systems - Public\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n }\r\n ]\r\n}", + "ResponseBody": "{\r\n \"value\": [\r\n {\r\n \"id\": \"/subscriptions/00977cdb-163f-435f-9c32-39ec8ae61f4d\",\r\n \"subscriptionId\": \"00977cdb-163f-435f-9c32-39ec8ae61f4d\",\r\n \"displayName\": \"node\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/2c224e7e-3ef5-431d-a57b-e71f4662e3a6\",\r\n \"subscriptionId\": \"2c224e7e-3ef5-431d-a57b-e71f4662e3a6\",\r\n \"displayName\": \"Node CLI Test\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/6b085460-5f21-477e-ba44-1035046e9101\",\r\n \"subscriptionId\": \"6b085460-5f21-477e-ba44-1035046e9101\",\r\n \"displayName\": \"Azure SDK Infrastructure\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/db1ab6f0-4769-4b27-930e-01e2ef9c123c\",\r\n \"subscriptionId\": \"db1ab6f0-4769-4b27-930e-01e2ef9c123c\",\r\n \"displayName\": \"Azure SDK sandbox\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n }\r\n ]\r\n}", "ResponseHeaders": { "Content-Length": [ - "2747" + "1081" ], "Content-Type": [ "application/json; charset=utf-8" @@ -169,16 +265,16 @@ "no-cache" ], "x-ms-ratelimit-remaining-tenant-reads": [ - "14991" + "14992" ], "x-ms-request-id": [ - "6a858a8b-5996-41e3-96f6-f13bfb8d607d" + "5ad9419b-700e-4541-9599-356c1a8fd765" ], "x-ms-correlation-request-id": [ - "6a858a8b-5996-41e3-96f6-f13bfb8d607d" + "5ad9419b-700e-4541-9599-356c1a8fd765" ], "x-ms-routing-request-id": [ - "WESTUS:20151002T035450Z:6a858a8b-5996-41e3-96f6-f13bfb8d607d" + "WESTUS:20151022T003239Z:5ad9419b-700e-4541-9599-356c1a8fd765" ], "Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" @@ -187,7 +283,7 @@ "no-cache" ], "Date": [ - "Fri, 02 Oct 2015 03:54:50 GMT" + "Thu, 22 Oct 2015 00:32:39 GMT" ] }, "StatusCode": 200 @@ -220,13 +316,13 @@ "14999" ], "x-ms-request-id": [ - "ff94ac85-24fd-4d59-936c-90a4bbe24ebe" + "6c65c5d8-7009-4a55-8eae-7433886b8425" ], "x-ms-correlation-request-id": [ - "ff94ac85-24fd-4d59-936c-90a4bbe24ebe" + "6c65c5d8-7009-4a55-8eae-7433886b8425" ], "x-ms-routing-request-id": [ - "WESTUS:20151002T035450Z:ff94ac85-24fd-4d59-936c-90a4bbe24ebe" + "WESTUS:20151022T003238Z:6c65c5d8-7009-4a55-8eae-7433886b8425" ], "Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" @@ -235,7 +331,7 @@ "no-cache" ], "Date": [ - "Fri, 02 Oct 2015 03:54:49 GMT" + "Thu, 22 Oct 2015 00:32:37 GMT" ] }, "StatusCode": 200 From 3f2656b6bea2fd8819b1cbb993e650c2736b4faf Mon Sep 17 00:00:00 2001 From: Hovsep Mkrtchyan Date: Thu, 22 Oct 2015 11:07:40 -0700 Subject: [PATCH 3/5] Addressing review comments --- .../PipingWithRmContextWorks.json | 152 ++++++++++++++---- .../SubscriptionCmdletTests.ps1 | 6 + .../Context/SetAzureRMContext.cs | 2 +- 3 files changed, 131 insertions(+), 29 deletions(-) diff --git a/src/ResourceManager/Profile/Commands.Profile.Test/SessionRecords/Microsoft.Azure.Commands.Profile.Test.SubscriptionCmdletTests/PipingWithRmContextWorks.json b/src/ResourceManager/Profile/Commands.Profile.Test/SessionRecords/Microsoft.Azure.Commands.Profile.Test.SubscriptionCmdletTests/PipingWithRmContextWorks.json index b4dd48c3dc57..4a6878776774 100644 --- a/src/ResourceManager/Profile/Commands.Profile.Test/SessionRecords/Microsoft.Azure.Commands.Profile.Test.SubscriptionCmdletTests/PipingWithRmContextWorks.json +++ b/src/ResourceManager/Profile/Commands.Profile.Test/SessionRecords/Microsoft.Azure.Commands.Profile.Test.SubscriptionCmdletTests/PipingWithRmContextWorks.json @@ -1,5 +1,101 @@ { "Entries": [ + { + "RequestUri": "/subscriptions?api-version=2014-04-01-preview", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnM/YXBpLXZlcnNpb249MjAxNC0wNC0wMS1wcmV2aWV3", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "User-Agent": [ + "Microsoft.Azure.Subscriptions.SubscriptionClient/2.0.0.0" + ] + }, + "ResponseBody": "{\r\n \"value\": [\r\n {\r\n \"id\": \"/subscriptions/00977cdb-163f-435f-9c32-39ec8ae61f4d\",\r\n \"subscriptionId\": \"00977cdb-163f-435f-9c32-39ec8ae61f4d\",\r\n \"displayName\": \"node\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/2c224e7e-3ef5-431d-a57b-e71f4662e3a6\",\r\n \"subscriptionId\": \"2c224e7e-3ef5-431d-a57b-e71f4662e3a6\",\r\n \"displayName\": \"Node CLI Test\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/6b085460-5f21-477e-ba44-1035046e9101\",\r\n \"subscriptionId\": \"6b085460-5f21-477e-ba44-1035046e9101\",\r\n \"displayName\": \"Azure SDK Infrastructure\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/db1ab6f0-4769-4b27-930e-01e2ef9c123c\",\r\n \"subscriptionId\": \"db1ab6f0-4769-4b27-930e-01e2ef9c123c\",\r\n \"displayName\": \"Azure SDK sandbox\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n }\r\n ]\r\n}", + "ResponseHeaders": { + "Content-Length": [ + "1081" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-tenant-reads": [ + "14999" + ], + "x-ms-request-id": [ + "ab8756d0-4404-4a60-ae6e-2653656c0b23" + ], + "x-ms-correlation-request-id": [ + "ab8756d0-4404-4a60-ae6e-2653656c0b23" + ], + "x-ms-routing-request-id": [ + "WESTUS:20151022T180626Z:ab8756d0-4404-4a60-ae6e-2653656c0b23" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Thu, 22 Oct 2015 18:06:26 GMT" + ] + }, + "StatusCode": 200 + }, + { + "RequestUri": "/subscriptions?api-version=2014-04-01-preview", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnM/YXBpLXZlcnNpb249MjAxNC0wNC0wMS1wcmV2aWV3", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "User-Agent": [ + "Microsoft.Azure.Subscriptions.SubscriptionClient/2.0.0.0" + ] + }, + "ResponseBody": "{\r\n \"value\": [\r\n {\r\n \"id\": \"/subscriptions/00977cdb-163f-435f-9c32-39ec8ae61f4d\",\r\n \"subscriptionId\": \"00977cdb-163f-435f-9c32-39ec8ae61f4d\",\r\n \"displayName\": \"node\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/2c224e7e-3ef5-431d-a57b-e71f4662e3a6\",\r\n \"subscriptionId\": \"2c224e7e-3ef5-431d-a57b-e71f4662e3a6\",\r\n \"displayName\": \"Node CLI Test\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/6b085460-5f21-477e-ba44-1035046e9101\",\r\n \"subscriptionId\": \"6b085460-5f21-477e-ba44-1035046e9101\",\r\n \"displayName\": \"Azure SDK Infrastructure\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/db1ab6f0-4769-4b27-930e-01e2ef9c123c\",\r\n \"subscriptionId\": \"db1ab6f0-4769-4b27-930e-01e2ef9c123c\",\r\n \"displayName\": \"Azure SDK sandbox\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n }\r\n ]\r\n}", + "ResponseHeaders": { + "Content-Length": [ + "1081" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-tenant-reads": [ + "14998" + ], + "x-ms-request-id": [ + "26b98034-05ee-4844-ac72-a8c02a305858" + ], + "x-ms-correlation-request-id": [ + "26b98034-05ee-4844-ac72-a8c02a305858" + ], + "x-ms-routing-request-id": [ + "WESTUS:20151022T180627Z:26b98034-05ee-4844-ac72-a8c02a305858" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Thu, 22 Oct 2015 18:06:26 GMT" + ] + }, + "StatusCode": 200 + }, { "RequestUri": "/subscriptions?api-version=2014-04-01-preview", "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnM/YXBpLXZlcnNpb249MjAxNC0wNC0wMS1wcmV2aWV3", @@ -28,13 +124,13 @@ "14997" ], "x-ms-request-id": [ - "284d131d-ec1d-473e-82b2-022824dbd382" + "af0e42bf-875b-4457-963e-24fa3470061e" ], "x-ms-correlation-request-id": [ - "284d131d-ec1d-473e-82b2-022824dbd382" + "af0e42bf-875b-4457-963e-24fa3470061e" ], "x-ms-routing-request-id": [ - "WESTUS:20151022T003227Z:284d131d-ec1d-473e-82b2-022824dbd382" + "WESTUS:20151022T180627Z:af0e42bf-875b-4457-963e-24fa3470061e" ], "Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" @@ -43,7 +139,7 @@ "no-cache" ], "Date": [ - "Thu, 22 Oct 2015 00:32:27 GMT" + "Thu, 22 Oct 2015 18:06:27 GMT" ] }, "StatusCode": 200 @@ -76,13 +172,13 @@ "14996" ], "x-ms-request-id": [ - "55b62765-1a90-4adf-86a8-68ad7640328a" + "4bc6ff63-684d-423f-87c4-ede93d0b098a" ], "x-ms-correlation-request-id": [ - "55b62765-1a90-4adf-86a8-68ad7640328a" + "4bc6ff63-684d-423f-87c4-ede93d0b098a" ], "x-ms-routing-request-id": [ - "WESTUS:20151022T003228Z:55b62765-1a90-4adf-86a8-68ad7640328a" + "WESTUS:20151022T180627Z:4bc6ff63-684d-423f-87c4-ede93d0b098a" ], "Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" @@ -91,7 +187,7 @@ "no-cache" ], "Date": [ - "Thu, 22 Oct 2015 00:32:28 GMT" + "Thu, 22 Oct 2015 18:06:27 GMT" ] }, "StatusCode": 200 @@ -124,13 +220,13 @@ "14995" ], "x-ms-request-id": [ - "e56eae11-deb0-40ff-8247-33e26f6584d4" + "20764464-9863-4fc0-9228-3bacb5690b52" ], "x-ms-correlation-request-id": [ - "e56eae11-deb0-40ff-8247-33e26f6584d4" + "20764464-9863-4fc0-9228-3bacb5690b52" ], "x-ms-routing-request-id": [ - "WESTUS:20151022T003236Z:e56eae11-deb0-40ff-8247-33e26f6584d4" + "WESTUS:20151022T180628Z:20764464-9863-4fc0-9228-3bacb5690b52" ], "Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" @@ -139,7 +235,7 @@ "no-cache" ], "Date": [ - "Thu, 22 Oct 2015 00:32:36 GMT" + "Thu, 22 Oct 2015 18:06:27 GMT" ] }, "StatusCode": 200 @@ -172,13 +268,13 @@ "14994" ], "x-ms-request-id": [ - "dc675c1b-2b93-46f0-8398-71b55a651c1c" + "dc63ecd4-c5ee-46a4-876e-fb6ffc3ac8fe" ], "x-ms-correlation-request-id": [ - "dc675c1b-2b93-46f0-8398-71b55a651c1c" + "dc63ecd4-c5ee-46a4-876e-fb6ffc3ac8fe" ], "x-ms-routing-request-id": [ - "WESTUS:20151022T003237Z:dc675c1b-2b93-46f0-8398-71b55a651c1c" + "WESTUS:20151022T180628Z:dc63ecd4-c5ee-46a4-876e-fb6ffc3ac8fe" ], "Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" @@ -187,7 +283,7 @@ "no-cache" ], "Date": [ - "Thu, 22 Oct 2015 00:32:37 GMT" + "Thu, 22 Oct 2015 18:06:28 GMT" ] }, "StatusCode": 200 @@ -220,13 +316,13 @@ "14993" ], "x-ms-request-id": [ - "c2c75a0f-db5e-4899-8957-699be8cab5d6" + "2ee70574-ce24-40e7-81a2-d94a9f7bd48b" ], "x-ms-correlation-request-id": [ - "c2c75a0f-db5e-4899-8957-699be8cab5d6" + "2ee70574-ce24-40e7-81a2-d94a9f7bd48b" ], "x-ms-routing-request-id": [ - "WESTUS:20151022T003238Z:c2c75a0f-db5e-4899-8957-699be8cab5d6" + "WESTUS:20151022T180629Z:2ee70574-ce24-40e7-81a2-d94a9f7bd48b" ], "Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" @@ -235,7 +331,7 @@ "no-cache" ], "Date": [ - "Thu, 22 Oct 2015 00:32:38 GMT" + "Thu, 22 Oct 2015 18:06:28 GMT" ] }, "StatusCode": 200 @@ -268,13 +364,13 @@ "14992" ], "x-ms-request-id": [ - "5ad9419b-700e-4541-9599-356c1a8fd765" + "fc489996-6e3a-42c3-9a2f-8c4d13daf330" ], "x-ms-correlation-request-id": [ - "5ad9419b-700e-4541-9599-356c1a8fd765" + "fc489996-6e3a-42c3-9a2f-8c4d13daf330" ], "x-ms-routing-request-id": [ - "WESTUS:20151022T003239Z:5ad9419b-700e-4541-9599-356c1a8fd765" + "WESTUS:20151022T180629Z:fc489996-6e3a-42c3-9a2f-8c4d13daf330" ], "Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" @@ -283,7 +379,7 @@ "no-cache" ], "Date": [ - "Thu, 22 Oct 2015 00:32:39 GMT" + "Thu, 22 Oct 2015 18:06:28 GMT" ] }, "StatusCode": 200 @@ -316,13 +412,13 @@ "14999" ], "x-ms-request-id": [ - "6c65c5d8-7009-4a55-8eae-7433886b8425" + "6830d8eb-637a-4150-b016-7aa4f69013de" ], "x-ms-correlation-request-id": [ - "6c65c5d8-7009-4a55-8eae-7433886b8425" + "6830d8eb-637a-4150-b016-7aa4f69013de" ], "x-ms-routing-request-id": [ - "WESTUS:20151022T003238Z:6c65c5d8-7009-4a55-8eae-7433886b8425" + "WESTUS:20151022T180627Z:6830d8eb-637a-4150-b016-7aa4f69013de" ], "Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" @@ -331,7 +427,7 @@ "no-cache" ], "Date": [ - "Thu, 22 Oct 2015 00:32:37 GMT" + "Thu, 22 Oct 2015 18:06:27 GMT" ] }, "StatusCode": 200 diff --git a/src/ResourceManager/Profile/Commands.Profile.Test/SubscriptionCmdletTests.ps1 b/src/ResourceManager/Profile/Commands.Profile.Test/SubscriptionCmdletTests.ps1 index e43d95ad10b5..433413fd5d42 100644 --- a/src/ResourceManager/Profile/Commands.Profile.Test/SubscriptionCmdletTests.ps1 +++ b/src/ResourceManager/Profile/Commands.Profile.Test/SubscriptionCmdletTests.ps1 @@ -52,6 +52,7 @@ function Test-PipingWithContext $name = $firstSubscription.SubscriptionName $nameContext = Get-AzureRmSubscription -SubscriptionName $name | Set-AzureRmContext $idContext = Get-AzureRmSubscription -SubscriptionId $id | Set-AzureRmContext + $contextByName = Set-AzureRmContext -SubscriptionName $name Assert-True { $nameContext -ne $null } Assert-True { $nameContext.Subscription -ne $null } Assert-True { $nameContext.Subscription.SubscriptionId -ne $null } @@ -62,6 +63,11 @@ function Test-PipingWithContext Assert-True { $idContext.Subscription.SubscriptionName -ne $null } Assert-AreEqual $idContext.Subscription.SubscriptionId $nameContext.Subscription.SubscriptionId Assert-AreEqual $idContext.Subscription.SubscriptionName $nameContext.Subscription.SubscriptionName + Assert-True { $contextByName -ne $null } + Assert-True { $contextByName.Subscription -ne $null } + Assert-True { $contextByName.Subscription.SubscriptionId -ne $null } + Assert-True { $contextByName.Subscription.SubscriptionName -ne $null } + Assert-AreEqual $contextByName.Subscription.SubscriptionName $nameContext.Subscription.SubscriptionName } function Test-SetAzureRmContextEndToEnd diff --git a/src/ResourceManager/Profile/Commands.Profile/Context/SetAzureRMContext.cs b/src/ResourceManager/Profile/Commands.Profile/Context/SetAzureRMContext.cs index 603ae5c795d9..43f4362a9f60 100644 --- a/src/ResourceManager/Profile/Commands.Profile/Context/SetAzureRMContext.cs +++ b/src/ResourceManager/Profile/Commands.Profile/Context/SetAzureRMContext.cs @@ -64,7 +64,7 @@ protected override void ProcessRecord() if (string.IsNullOrWhiteSpace(TenantId)) { - WriteWarning( + WriteVerbose( string.Format( Resources.CurrentTenantInUse, tenantId)); From 3f92c7ebdaf6a66c48851b0e7030ffdf530a4a77 Mon Sep 17 00:00:00 2001 From: Hovsep Mkrtchyan Date: Thu, 22 Oct 2015 11:47:09 -0700 Subject: [PATCH 4/5] [#106171538] Changed Tenant to TenantId in cmdletst --- .../Account/AddAzureRmAccount.cs | 3 +- ...rosoft.Azure.Commands.Profile.dll-Help.xml | 62 +++++++++---------- ...osoft.Azure.Commands.Profile.format.ps1xml | 10 +-- .../Tenant/GetAzureRMTenant.cs | 4 +- .../Account/AddAzureAccount.cs | 1 + .../Profile/NewAzureProfile.cs | 1 + 6 files changed, 43 insertions(+), 38 deletions(-) diff --git a/src/ResourceManager/Profile/Commands.Profile/Account/AddAzureRmAccount.cs b/src/ResourceManager/Profile/Commands.Profile/Account/AddAzureRmAccount.cs index 4f9a53d31fe5..af177f59fcbe 100644 --- a/src/ResourceManager/Profile/Commands.Profile/Account/AddAzureRmAccount.cs +++ b/src/ResourceManager/Profile/Commands.Profile/Account/AddAzureRmAccount.cs @@ -48,8 +48,9 @@ public class AddAzureRMAccountCommand : AzureRMCmdlet , IModuleAssemblyInitializ [Parameter(ParameterSetName = "User", Mandatory = false, HelpMessage = "Optional tenant name or ID")] [Parameter(ParameterSetName = "ServicePrincipal", Mandatory = true, HelpMessage = "TenantId name or ID")] [Parameter(ParameterSetName = "AccessToken", Mandatory = false, HelpMessage = "TenantId name or ID")] + [Alias("Tenant")] [ValidateNotNullOrEmpty] - public string Tenant { get; set; } + public string TenantId { get; set; } [Parameter(ParameterSetName = "AccessToken", Mandatory = true, HelpMessage = "AccessToken")] [ValidateNotNullOrEmpty] diff --git a/src/ResourceManager/Profile/Commands.Profile/Microsoft.Azure.Commands.Profile.dll-Help.xml b/src/ResourceManager/Profile/Commands.Profile/Microsoft.Azure.Commands.Profile.dll-Help.xml index cae9dfa3e623..b76a5f0ff7d1 100644 --- a/src/ResourceManager/Profile/Commands.Profile/Microsoft.Azure.Commands.Profile.dll-Help.xml +++ b/src/ResourceManager/Profile/Commands.Profile/Microsoft.Azure.Commands.Profile.dll-Help.xml @@ -16,7 +16,7 @@ NOTE THAT THIS CMDLET AUTHENTICATES ONLY AZURE RESOURCE MANAGER CMDLETS. SERVICE MANAGEMENT CMDLETS MUST BE SEPARATELY AUTHENTICATED USING THE ADD-AZUREACCOUNT OR IMPORT-AZUREPUBLISHSETTINGSFILE CMDLETS. - Log in to Azure Resource manager to provide authentication for management cmdlets. Microsoft Account (Live Id) and Oragnization Id credentials may be provided through the dialog prompt. Organizational ID and Service Principal credentials may be provided through a -Credential parameter. Access Token credentials may be provided through the AccessToken credential. By default, user is authenticated agains all available teants. The TenantId parameter may be provided to streamline authentication when access to only a single teant is needed. The SubscriptionId parameter may be provided to select a particular subscription by default, otherwise the first listed subscription will be selected. + Log in to Azure Resource manager to provide authentication for management cmdlets. Microsoft Account (Live Id) and Organization Id credentials may be provided through the dialog prompt. Organizational ID and Service Principal credentials may be provided through a -Credential parameter. Access Token credentials may be provided through the AccessToken credential. By default, user is authenticated against all available tenants. The TenantId parameter may be provided to streamline authentication when access to only a single tenant is needed. The SubscriptionId parameter may be provided to select a particular subscription by default, otherwise the first listed subscription will be selected. @@ -31,12 +31,12 @@ Credential - Securely provide the user id and password for Organization Id credentials or the Application Id and Secret for Service Principal credentials. The provided credentials will be sued to acquire tokens for authenticataing ARM cmdlets with Azure. + Securely provide the user id and password for Organization Id credentials or the Application Id and Secret for Service Principal credentials. The provided credentials will be used to acquire tokens for authenticating ARM cmdlets with Azure. PSCredential - Tenant + TenantId If provided, limit authentication to only the provided tenant. This parameter is required for authentication as a service principal. @@ -76,19 +76,19 @@ Credential - Securely provide the user id and password for Organization Id credentials or the Application Id and Secret for Service Principal credentials. The provided credentials will be sued to acquire tokens for authenticataing ARM cmdlets with Azure. + Securely provide the user id and password for Organization Id credentials or the Application Id and Secret for Service Principal credentials. The provided credentials will be sued to acquire tokens for authenticating ARM cmdlets with Azure. PSCredential ServicePrincipal - When provided, indicates that service princiapl credentials will be provided via the Credential parameter and the Tenant containing the given Servicew Principal will be provided in the TenantId parameter. + When provided, indicates that service principal credentials will be provided via the Credential parameter and the Tenant containing the given Service Principal will be provided in the TenantId parameter. SwitchParameter - Tenant + TenantId If provided, limit authentication to only the provided tenant. This parameter is required for authentication as a service principal. @@ -126,7 +126,7 @@ AzureEnvironment - Tenant + TenantId If provided, limit authentication to only the provided tenant. This parameter is required for authentication as a service principal. @@ -178,7 +178,7 @@ Credential - Securely provide the user id and password for Organization Id credentials or the Application Id and Secret for Service Principal credentials. The provided credentials will be sued to acquire tokens for authenticataing ARM cmdlets with Azure. + Securely provide the user id and password for Organization Id credentials or the Application Id and Secret for Service Principal credentials. The provided credentials will be used to acquire tokens for authenticating ARM cmdlets with Azure. PSCredential @@ -188,7 +188,7 @@ None - Tenant + TenantId If provided, limit authentication to only the provided tenant. This parameter is required for authentication as a service principal. @@ -240,7 +240,7 @@ ServicePrincipal - When provided, indicates that service princiapl credentials will be provided via the Credential parameter and the Tenant containing the given Servicew Principal will be provided in the TenantId parameter. + When provided, indicates that service principal credentials will be provided via the Credential parameter and the Tenant containing the given Service Principal will be provided in the TenantId parameter. SwitchParameter @@ -310,13 +310,13 @@ Add-AzureRmAccount - Displays a dialog where Microsoft Account or Oragnizational Id credentials may be provided. The given credentials will be used to acquire a token for authentication with Azure Resource Manager. Note that if multi-factor authentication (MFA) is enabled for your credentials, you must log in using the interactive option, or use Service Principal authentication. + Displays a dialog where Microsoft Account or Organizational Id credentials may be provided. The given credentials will be used to acquire a token for authentication with Azure Resource Manager. Note that if multi-factor authentication (MFA) is enabled for your credentials, you must log in using the interactive option, or use Service Principal authentication. Account: azureuser@contoso.com Environment: AzureCloud -Subscription: xxxx-xxxx-xxxx-xxxx -Tenant: xxxx-xxxx-xxxx-xxxx +SubscriptionId: xxxx-xxxx-xxxx-xxxx +TenantId: xxxx-xxxx-xxxx-xxxx @@ -340,8 +340,8 @@ Add-AzureRmAccount -Credential $credential Account: azureuser@contoso.onmicrosoft.cn Environment: AzureChinacloud -Subscription: xxxx-xxxx-xxxx-xxxx -Tenant: xxxx-xxxx-xxxx-xxxx +SubscriptionId: xxxx-xxxx-xxxx-xxxx +TenantId: xxxx-xxxx-xxxx-xxxx @@ -387,8 +387,8 @@ Tenant: zzzz-zzzz-zzzz-zzzz Account: user@example.com Environment: AzureCloud -Subscription: yyyy-yyyy-yyyy-yyyy -Tenant: xxxx-xxxx-xxxx-xxxx +SubscriptionId: yyyy-yyyy-yyyy-yyyy +TenantId: xxxx-xxxx-xxxx-xxxx @@ -467,7 +467,7 @@ Tenant: xxxx-xxxx-xxxx-xxxx - Add endpoints and metdaata that allow Azure Resource Manager cmdlets to connect with a new instance of Azure Resource Manager. Built-in environments AzureCloud and AzureChinaCloud target existing public instances of Azure Resource Manager. + Add endpoints and metdata that allow Azure Resource Manager cmdlets to connect with a new instance of Azure Resource Manager. Built-in environments AzureCloud and AzureChinaCloud target existing public instances of Azure Resource Manager. @@ -580,7 +580,7 @@ Tenant: xxxx-xxxx-xxxx-xxxx AdTenant - The default Active Direcotyr Tenant. + The default Active Directory Tenant. String @@ -799,7 +799,7 @@ Tenant: xxxx-xxxx-xxxx-xxxx AdTenant - The default Active Direcotyr Tenant. + The default Active Directory Tenant. String @@ -1168,7 +1168,7 @@ Tenant: xxxx-xxxx-xxxx-xxxx - Get detailed information, inbclusing subscription id, subscription name, and home tenant about subscriptions the current account can access. + Get detailed information, including subscription id, subscription name, and home tenant about subscriptions the current account can access. @@ -1500,7 +1500,7 @@ Subscription Name: Contoso Subscription 1 Get-AzureRmTenant - Tenant + TenantId Tenant to get information about. If not provided, all authorized tenants are returned. @@ -1524,7 +1524,7 @@ Subscription Name: Contoso Subscription 1 - Tenant + TenantId Tenant to get information about. If not provided, all authorized tenants are returned. @@ -2182,9 +2182,9 @@ Subscription Name: Contoso Subscription 1 Set-AzureRmContext - Tenant + TenantId - The tenant to taret in this session. + The tenant to target in this session. AzureTenant @@ -2265,9 +2265,9 @@ Subscription Name: Contoso Subscription 1 - Tenant + TenantId - The tenant to taret in this session. + The tenant to target in this session. AzureTenant @@ -2344,8 +2344,8 @@ Subscription Name: Contoso Subscription 1 Account: user@contoso.com Environment: AzureCloud -Subscription: xxxx-xxxx-xxxx-xxxx -Tenant: yyyy-yyyy-yyyy-yyyy +SubscriptionId: xxxx-xxxx-xxxx-xxxx +TenantId: yyyy-yyyy-yyyy-yyyy @@ -2497,7 +2497,7 @@ Tenant: yyyy-yyyy-yyyy-yyyy AdTenant - The default Active Direcotyr Tenant. + The default Active Directory Tenant. String @@ -2716,7 +2716,7 @@ Tenant: yyyy-yyyy-yyyy-yyyy AdTenant - The default Active Direcotyr Tenant. + The default Active Directory Tenant. String diff --git a/src/ResourceManager/Profile/Commands.Profile/Microsoft.Azure.Commands.Profile.format.ps1xml b/src/ResourceManager/Profile/Commands.Profile/Microsoft.Azure.Commands.Profile.format.ps1xml index 3b39e514b657..76cc3f806a77 100644 --- a/src/ResourceManager/Profile/Commands.Profile/Microsoft.Azure.Commands.Profile.format.ps1xml +++ b/src/ResourceManager/Profile/Commands.Profile/Microsoft.Azure.Commands.Profile.format.ps1xml @@ -19,11 +19,11 @@ $_.Context.Account.ToString() - + $_.Context.Tenant.ToString() - + $_.Context.Subscription.ToString() @@ -51,10 +51,12 @@ Account - Tenant + + $_.Tenant.ToString() - Subscription + + $_.Subscription.ToString() diff --git a/src/ResourceManager/Profile/Commands.Profile/Tenant/GetAzureRMTenant.cs b/src/ResourceManager/Profile/Commands.Profile/Tenant/GetAzureRMTenant.cs index fd2153b48278..48b89ea3ab86 100644 --- a/src/ResourceManager/Profile/Commands.Profile/Tenant/GetAzureRMTenant.cs +++ b/src/ResourceManager/Profile/Commands.Profile/Tenant/GetAzureRMTenant.cs @@ -29,9 +29,9 @@ namespace Microsoft.Azure.Commands.Profile public class GetAzureRMTenantCommand : AzureRMCmdlet { [Parameter(Mandatory = false, Position = 0, ValueFromPipelineByPropertyName = true)] - [Alias("Domain")] + [Alias("Domain", "Tenant")] [ValidateNotNullOrEmpty] - public string Tenant { get; set; } + public string TenantId { get; set; } protected override void ProcessRecord() { diff --git a/src/ServiceManagement/Profile/Commands.Profile/Account/AddAzureAccount.cs b/src/ServiceManagement/Profile/Commands.Profile/Account/AddAzureAccount.cs index d6b81d57ef72..ca8d08d1e60e 100644 --- a/src/ServiceManagement/Profile/Commands.Profile/Account/AddAzureAccount.cs +++ b/src/ServiceManagement/Profile/Commands.Profile/Account/AddAzureAccount.cs @@ -40,6 +40,7 @@ public class AddAzureAccount : SubscriptionCmdletBase [Parameter(ParameterSetName = "User", Mandatory = false, HelpMessage = "Optional tenant name or ID")] [Parameter(ParameterSetName = "ServicePrincipal", Mandatory = true, HelpMessage = "Tenant name or ID")] + [Alias("TenantId")] public string Tenant { get; set; } public AddAzureAccount() : base(true) diff --git a/src/ServiceManagement/Profile/Commands.Profile/Profile/NewAzureProfile.cs b/src/ServiceManagement/Profile/Commands.Profile/Profile/NewAzureProfile.cs index 890c9137d1bd..de1dbb193d82 100644 --- a/src/ServiceManagement/Profile/Commands.Profile/Profile/NewAzureProfile.cs +++ b/src/ServiceManagement/Profile/Commands.Profile/Profile/NewAzureProfile.cs @@ -82,6 +82,7 @@ public class NewAzureProfileCommand : AzureSMCmdlet [Parameter(Mandatory = false, Position = 2, ParameterSetName = CredentialsParameterSet)] [Parameter(Mandatory = true, Position = 2, ParameterSetName = ServicePrincipalParameterSet)] + [Alias("TenantId")] public string Tenant { get; set; } [Parameter(Mandatory = true, ParameterSetName = ServicePrincipalParameterSet)] From bc64d6be20cac2d0cc3b442e0c43a97f55b0dae1 Mon Sep 17 00:00:00 2001 From: Hovsep Mkrtchyan Date: Thu, 22 Oct 2015 14:30:00 -0700 Subject: [PATCH 5/5] Fixed build breaks --- .../Profile/Commands.Profile.Test/LoginCmdletTests.cs | 10 +++++----- .../Profile/Commands.Profile.Test/TenantCmdletTests.cs | 6 +++--- .../Commands.Profile/Account/AddAzureRmAccount.cs | 6 +++--- .../Commands.Profile/Tenant/GetAzureRMTenant.cs | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/ResourceManager/Profile/Commands.Profile.Test/LoginCmdletTests.cs b/src/ResourceManager/Profile/Commands.Profile.Test/LoginCmdletTests.cs index f5bd29dd5060..22b9ba0d7a23 100644 --- a/src/ResourceManager/Profile/Commands.Profile.Test/LoginCmdletTests.cs +++ b/src/ResourceManager/Profile/Commands.Profile.Test/LoginCmdletTests.cs @@ -50,7 +50,7 @@ public void LoginWithSubscriptionAndTenant() // Setup cmdlt.CommandRuntime = commandRuntimeMock; cmdlt.SubscriptionId = "2c224e7e-3ef5-431d-a57b-e71f4662e3a6"; - cmdlt.Tenant = "72f988bf-86f1-41af-91ab-2d7cd011db47"; + cmdlt.TenantId = "72f988bf-86f1-41af-91ab-2d7cd011db47"; // Act cmdlt.InvokeBeginProcessing(); @@ -69,7 +69,7 @@ public void LoginWithInvalidSubscriptionAndTenantThrowsCloudException() // Setup cmdlt.CommandRuntime = commandRuntimeMock; cmdlt.SubscriptionId = "2c224e7e-3ef5-431d-a57b-e71f4662e3a5"; - cmdlt.Tenant = "72f988bf-86f1-41af-91ab-2d7cd011db47"; + cmdlt.TenantId = "72f988bf-86f1-41af-91ab-2d7cd011db47"; // Act cmdlt.InvokeBeginProcessing(); @@ -119,7 +119,7 @@ public void LoginWithNoSubscriptionAndTenant() var cmdlt = new AddAzureRMAccountCommand(); // Setup cmdlt.CommandRuntime = commandRuntimeMock; - cmdlt.Tenant = "72f988bf-86f1-41af-91ab-2d7cd011db47"; + cmdlt.TenantId = "72f988bf-86f1-41af-91ab-2d7cd011db47"; // Act cmdlt.InvokeBeginProcessing(); @@ -137,7 +137,7 @@ public void LoginWithSubscriptionname() var cmdlt = new AddAzureRMAccountCommand(); // Setup cmdlt.CommandRuntime = commandRuntimeMock; - cmdlt.Tenant = "72f988bf-86f1-41af-91ab-2d7cd011db47"; + cmdlt.TenantId = "72f988bf-86f1-41af-91ab-2d7cd011db47"; cmdlt.SubscriptionName = "Node CLI Test"; // Act @@ -156,7 +156,7 @@ public void LoginWithBothSubscriptionIdAndNameThrowsCloudException() var cmdlt = new AddAzureRMAccountCommand(); // Setup cmdlt.CommandRuntime = commandRuntimeMock; - cmdlt.Tenant = "72f988bf-86f1-41af-91ab-2d7cd011db47"; + cmdlt.TenantId = "72f988bf-86f1-41af-91ab-2d7cd011db47"; cmdlt.SubscriptionName = "Node CLI Test"; cmdlt.SubscriptionId = "2c224e7e-3ef5-431d-a57b-e71f4662e3a6"; diff --git a/src/ResourceManager/Profile/Commands.Profile.Test/TenantCmdletTests.cs b/src/ResourceManager/Profile/Commands.Profile.Test/TenantCmdletTests.cs index 11da48548d2e..6f12018f4a98 100644 --- a/src/ResourceManager/Profile/Commands.Profile.Test/TenantCmdletTests.cs +++ b/src/ResourceManager/Profile/Commands.Profile.Test/TenantCmdletTests.cs @@ -49,7 +49,7 @@ public void GetTenantWithTenantParameter() var cmdlt = new GetAzureRMTenantCommand(); // Setup cmdlt.CommandRuntime = commandRuntimeMock; - cmdlt.Tenant = "72f988bf-86f1-41af-91ab-2d7cd011db47"; + cmdlt.TenantId = "72f988bf-86f1-41af-91ab-2d7cd011db47"; // Act Login("2c224e7e-3ef5-431d-a57b-e71f4662e3a6", null); @@ -69,7 +69,7 @@ public void GetTenantWithDomainParameter() var cmdlt = new GetAzureRMTenantCommand(); // Setup cmdlt.CommandRuntime = commandRuntimeMock; - cmdlt.Tenant = "microsoft.com"; + cmdlt.TenantId = "microsoft.com"; // Act Login("2c224e7e-3ef5-431d-a57b-e71f4662e3a6", null); @@ -107,7 +107,7 @@ private void Login(string subscriptionId, string tenantId) // Setup cmdlt.CommandRuntime = commandRuntimeMock; cmdlt.SubscriptionId = subscriptionId; - cmdlt.Tenant = tenantId; + cmdlt.TenantId = tenantId; // Act cmdlt.InvokeBeginProcessing(); diff --git a/src/ResourceManager/Profile/Commands.Profile/Account/AddAzureRmAccount.cs b/src/ResourceManager/Profile/Commands.Profile/Account/AddAzureRmAccount.cs index af177f59fcbe..2a63234c107f 100644 --- a/src/ResourceManager/Profile/Commands.Profile/Account/AddAzureRmAccount.cs +++ b/src/ResourceManager/Profile/Commands.Profile/Account/AddAzureRmAccount.cs @@ -127,9 +127,9 @@ protected override void ProcessRecord() password = Credential.Password; } - if (!string.IsNullOrEmpty(Tenant)) + if (!string.IsNullOrEmpty(TenantId)) { - azureAccount.SetProperty(AzureAccount.Property.Tenants, new[] { Tenant }); + azureAccount.SetProperty(AzureAccount.Property.Tenants, new[] { TenantId }); } if( AzureRmProfileProvider.Instance.Profile == null) @@ -139,7 +139,7 @@ protected override void ProcessRecord() var profileClient = new RMProfileClient(AzureRmProfileProvider.Instance.Profile); - WriteObject((PSAzureProfile)profileClient.Login(azureAccount, Environment, Tenant, SubscriptionId, + WriteObject((PSAzureProfile)profileClient.Login(azureAccount, Environment, TenantId, SubscriptionId, SubscriptionName, password)); } diff --git a/src/ResourceManager/Profile/Commands.Profile/Tenant/GetAzureRMTenant.cs b/src/ResourceManager/Profile/Commands.Profile/Tenant/GetAzureRMTenant.cs index 48b89ea3ab86..09efdb7d716f 100644 --- a/src/ResourceManager/Profile/Commands.Profile/Tenant/GetAzureRMTenant.cs +++ b/src/ResourceManager/Profile/Commands.Profile/Tenant/GetAzureRMTenant.cs @@ -37,7 +37,7 @@ protected override void ProcessRecord() { var profileClient = new RMProfileClient(AzureRmProfileProvider.Instance.Profile); - WriteObject(profileClient.ListTenants(Tenant).Select((t) => (PSAzureTenant)t), enumerateCollection: true); + WriteObject(profileClient.ListTenants(TenantId).Select((t) => (PSAzureTenant)t), enumerateCollection: true); } } }