Skip to content

. #89

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 40 commits into from
Sep 16, 2015
Merged

. #89

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
eb0a088
Authorization:Changes to Get-AzureroleAssignment commandlet to expand…
namratab Sep 2, 2015
43cec70
Update with official Authorization 'nuget package
namratab Sep 3, 2015
2f0d532
Fix packages.config changes that were missed
namratab Sep 3, 2015
cf14a21
Revert other RPs to use the older version of the Authorization packag…
namratab Sep 3, 2015
24b042e
Use latest Authorization package for Network and Keyvalut projects du…
namratab Sep 10, 2015
6679d88
Bug fixes in Get and Remove Role Assignments
shuagarw Sep 11, 2015
933523e
Merge branch 'dev' of github.com:Azure/azure-powershell into BugFixFi…
shuagarw Sep 11, 2015
b400edc
Merge branch 'dev' of github.com:Azure/azure-powershell into BugFixFi…
shuagarw Sep 12, 2015
dae6fda
[Test:do not merge]Attempt to fix SQl tests by using Record matcher t…
namratab Sep 14, 2015
5f2f930
Merge changes with upstream dev
namratab Sep 14, 2015
aa1e830
Fix build error
namratab Sep 14, 2015
d743fab
Merge branch 'dev' of github.com:Azure/azure-powershell into BugFixFi…
shuagarw Sep 14, 2015
ffa2ac1
Merge branch 'dev' of github.com:Azure/azure-powershell into roleassi…
namratab Sep 14, 2015
7766973
Fix break
namratab Sep 14, 2015
5b76c35
Referenced latest Authentication Package
Sep 14, 2015
55ccac3
Work in progress
Sep 15, 2015
3aba220
Re-record certain Resources tests
namratab Sep 15, 2015
f24dff3
Merge branch 'dev' of github.com:Azure/azure-powershell into roleassi…
namratab Sep 15, 2015
7619735
Some formatting changes in Remove-AzureRMRoleAssignment
shuagarw Sep 15, 2015
b986278
Merge branch 'dev' of github.com:Azure/azure-powershell into BugFixFi…
shuagarw Sep 15, 2015
27791a5
Merge branch 'dev' of github.com:Azure/azure-powershell into roleassi…
namratab Sep 15, 2015
fa930dd
Bumped up Authentication package reference.
Sep 15, 2015
eca4e40
Fix Compute and Dns tests to exclude api version for permissions
namratab Sep 15, 2015
2ece092
Update api version for remaining test projects and add exclusion for …
namratab Sep 15, 2015
8090605
Merge branch 'dev' of github.com:Azure/azure-powershell into roleassi…
namratab Sep 15, 2015
cd74631
Re-record operation insight tests
namratab Sep 15, 2015
eca9f59
Fix api management test
namratab Sep 15, 2015
af617d6
Refactor recordmatcher code
namratab Sep 15, 2015
c21ddc5
Merge branch 'dev' of github.com:Azure/azure-powershell into BugFixFi…
shuagarw Sep 15, 2015
14fa4c1
Addressed review comments for Get and Remove Azure Ro Assignments fixes
shuagarw Sep 15, 2015
c032130
Fixed build breaks.
Sep 15, 2015
6c61e03
Merge pull request #909 from shuagarw/BugFixFilterDeletedRA
ogail Sep 15, 2015
54ebc10
Merge branch 'dev' of github.com:Azure/azure-powershell into dev
Sep 15, 2015
a9f27e1
Fixed Test Failures in SM.
Sep 15, 2015
c75b99c
Fixed failing tests.
Sep 15, 2015
460341c
Updated to latest Authentication package.
Sep 15, 2015
c4e0d6a
Address review feedback for authorization commands
namratab Sep 15, 2015
b39bd6d
Merge branch 'dev' of github.com:Azure/azure-powershell into roleassi…
namratab Sep 15, 2015
2a510c9
Merge pull request #910 from hovsepm/dev
Sep 15, 2015
98d8eb3
Merge pull request #846 from namratab/roleassignmentmerge
Sep 16, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 4 additions & 1 deletion src/Common/AzurePSCmdlet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,10 @@ protected void ConfirmAction(bool force, string actionMessage, string processMes

protected virtual void Dispose(bool disposing)
{
_adalListener.Dispose();
if (_adalListener != null)
{
_adalListener.Dispose();
}
}

public void Dispose()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
</Reference>
<Reference Include="Microsoft.Azure.Common.Authentication, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Microsoft.Azure.Common.Authentication.1.1.4-preview\lib\net45\Microsoft.Azure.Common.Authentication.dll</HintPath>
<HintPath>..\..\packages\Microsoft.Azure.Common.Authentication.1.2.2-preview\lib\net45\Microsoft.Azure.Common.Authentication.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Common.NetFramework, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down
2 changes: 1 addition & 1 deletion src/Common/Commands.Common.Storage/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<packages>
<package id="Hyak.Common" version="1.0.2" targetFramework="net45" />
<package id="Microsoft.Azure.Common" version="2.1.0" targetFramework="net45" />
<package id="Microsoft.Azure.Common.Authentication" version="1.1.4-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Common.Authentication" version="1.2.2-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Resources" version="2.18.7-preview" targetFramework="net45" />
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net45" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
</Reference>
<Reference Include="Microsoft.Azure.Common.Authentication, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Microsoft.Azure.Common.Authentication.1.1.4-preview\lib\net45\Microsoft.Azure.Common.Authentication.dll</HintPath>
<HintPath>..\..\packages\Microsoft.Azure.Common.Authentication.1.2.2-preview\lib\net45\Microsoft.Azure.Common.Authentication.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Common.NetFramework">
<HintPath>..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.NetFramework.dll</HintPath>
Expand Down
36 changes: 18 additions & 18 deletions src/Common/Commands.Common.Test/Common/ProfileClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ public void NewProfileWithAccessTokenReturnsProfile()
Assert.Equal("AzureCloud", newProfile.DefaultSubscription.Environment);
Assert.Equal(new Guid(csmSubscription1.SubscriptionId), newProfile.DefaultSubscription.Id);
Assert.Equal("accountId", newProfile.DefaultSubscription.Account);
Assert.Equal(AzureAccount.AccountType.AccessToken, newProfile.DefaultContext.Account.Type);
Assert.Equal("accessToken", newProfile.DefaultContext.Account.Properties[AzureAccount.Property.AccessToken]);
Assert.Equal(AzureAccount.AccountType.AccessToken, newProfile.Context.Account.Type);
Assert.Equal("accessToken", newProfile.Context.Account.Properties[AzureAccount.Property.AccessToken]);
Assert.False(newProfile.DefaultSubscription.Properties.ContainsKey(AzureSubscription.Property.StorageAccount));
}

Expand Down Expand Up @@ -703,15 +703,15 @@ public void RemoveAzureAccountRemovesInMemoryAccount()

client.RemoveAccount(azureAccount.Id);

Assert.Equal("test2", currentProfile.DefaultContext.Account.Id);
Assert.Equal("test2", currentProfile.DefaultContext.Subscription.Account);
Assert.Equal(azureSubscription1.Id, currentProfile.DefaultContext.Subscription.Id);
Assert.Equal("test2", currentProfile.Context.Account.Id);
Assert.Equal("test2", currentProfile.Context.Subscription.Account);
Assert.Equal(azureSubscription1.Id, currentProfile.Context.Subscription.Id);

client.RemoveAccount("test2");

Assert.Null(currentProfile.DefaultContext.Account);
Assert.Null(currentProfile.DefaultContext.Subscription);
Assert.Null(currentProfile.DefaultContext.Environment);
Assert.Null(currentProfile.Context.Account);
Assert.Null(currentProfile.Context.Subscription);
Assert.Null(currentProfile.Context.Environment);
}

[Fact]
Expand Down Expand Up @@ -906,9 +906,9 @@ public void AddOrSetAzureSubscriptionUpdatesInMemory()
client.AddOrSetSubscription(azureSubscription1);
currentProfile.DefaultSubscription = azureSubscription1;
azureSubscription1.Properties[AzureSubscription.Property.StorageAccount] = "testAccount";
Assert.Equal(azureSubscription1.Id, currentProfile.DefaultContext.Subscription.Id);
Assert.Equal(azureSubscription1.Id, currentProfile.Context.Subscription.Id);
Assert.Equal(azureSubscription1.Properties[AzureSubscription.Property.StorageAccount],
currentProfile.DefaultContext.Subscription.Properties[AzureSubscription.Property.StorageAccount]);
currentProfile.Context.Subscription.Properties[AzureSubscription.Property.StorageAccount]);

var newSubscription = new AzureSubscription
{
Expand All @@ -922,10 +922,10 @@ public void AddOrSetAzureSubscriptionUpdatesInMemory()
client.AddOrSetSubscription(newSubscription);
var newSubscriptionFromProfile = client.Profile.Subscriptions[newSubscription.Id];

Assert.Equal(newSubscription.Id, currentProfile.DefaultContext.Subscription.Id);
Assert.Equal(newSubscription.Id, currentProfile.Context.Subscription.Id);
Assert.Equal(newSubscription.Id, newSubscriptionFromProfile.Id);
Assert.Equal(newSubscription.Properties[AzureSubscription.Property.StorageAccount],
currentProfile.DefaultContext.Subscription.Properties[AzureSubscription.Property.StorageAccount]);
currentProfile.Context.Subscription.Properties[AzureSubscription.Property.StorageAccount]);
Assert.Equal(newSubscription.Properties[AzureSubscription.Property.StorageAccount],
newSubscriptionFromProfile.Properties[AzureSubscription.Property.StorageAccount]);
}
Expand Down Expand Up @@ -1096,9 +1096,9 @@ public void SetAzureSubscriptionAsDefaultSetsDefaultAndCurrent()
client.SetSubscriptionAsDefault(azureSubscription2.Name, azureSubscription2.Account);

Assert.Equal(azureSubscription2.Id, client.Profile.DefaultSubscription.Id);
Assert.Equal(azureSubscription2.Id, currentProfile.DefaultContext.Subscription.Id);
Assert.Equal(azureSubscription2.Account, currentProfile.DefaultContext.Account.Id);
Assert.Equal(azureSubscription2.Environment, currentProfile.DefaultContext.Environment.Name);
Assert.Equal(azureSubscription2.Id, currentProfile.Context.Subscription.Id);
Assert.Equal(azureSubscription2.Account, currentProfile.Context.Account.Id);
Assert.Equal(azureSubscription2.Environment, currentProfile.Context.Environment.Name);
var notFoundEx = Assert.Throws<ArgumentException>(() => client.SetSubscriptionAsDefault("bad", null));
var invalidEx = Assert.Throws<ArgumentException>(() => client.SetSubscriptionAsDefault(null, null));
Assert.Contains("doesn't exist", notFoundEx.Message);
Expand All @@ -1123,9 +1123,9 @@ public void ClearDefaultAzureSubscriptionClearsDefault()
client.ClearDefaultSubscription();

Assert.Null(client.Profile.DefaultSubscription);
Assert.Null(client.Profile.DefaultContext.Account);
Assert.Null(client.Profile.DefaultContext.Environment);
Assert.Null(client.Profile.DefaultContext.Subscription);
Assert.Null(client.Profile.Context.Account);
Assert.Null(client.Profile.Context.Environment);
Assert.Null(client.Profile.Context.Subscription);
}

[Fact]
Expand Down
2 changes: 1 addition & 1 deletion src/Common/Commands.Common.Test/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<packages>
<package id="Hyak.Common" version="1.0.2" targetFramework="net45" />
<package id="Microsoft.Azure.Common" version="2.1.0" targetFramework="net45" />
<package id="Microsoft.Azure.Common.Authentication" version="1.1.4-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Common.Authentication" version="1.2.2-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.Azure.KeyVault.Core" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Resources" version="2.18.7-preview" targetFramework="net45" />
Expand Down
2 changes: 1 addition & 1 deletion src/Common/Commands.Common/AzureSMCmdlet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ private get

protected static TokenCache DefaultMemoryTokenCache { get; set; }

protected override AzureContext DefaultContext { get { return CurrentProfile.DefaultContext; } }
protected override AzureContext DefaultContext { get { return CurrentProfile.Context; } }

static AzureSMCmdlet()
{
Expand Down
12 changes: 6 additions & 6 deletions src/Common/Commands.Common/CloudBaseCmdlet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ protected virtual void InitChannelCurrentSubscription(bool force)

protected void DoInitChannelCurrentSubscription(bool force)
{
if (Profile.DefaultContext.Subscription == null)
if (Profile.Context.Subscription == null)
{
throw new ArgumentException(Resources.InvalidDefaultSubscription);
}

if (Profile.DefaultContext.Account == null)
if (Profile.Context.Account == null)
{
throw new ArgumentException(Resources.AccountNeedsToBeSpecified);
}
Expand Down Expand Up @@ -127,19 +127,19 @@ protected virtual T CreateChannel()
return Channel;
}

string certificateThumbprint = Profile.DefaultContext.Account.Id;
string certificateThumbprint = Profile.Context.Account.Id;
Debug.Assert(Profile.Accounts[certificateThumbprint].Type == AzureAccount.AccountType.Certificate);

return ChannelHelper.CreateServiceManagementChannel<T>(
ServiceBinding,
Profile.DefaultContext.Environment.GetEndpointAsUri(AzureEnvironment.Endpoint.ServiceManagement),
Profile.Context.Environment.GetEndpointAsUri(AzureEnvironment.Endpoint.ServiceManagement),
AzureSession.DataStore.GetCertificate(certificateThumbprint),
new HttpRestMessageInspector(WriteDebug));
}

protected void RetryCall(Action<string> call)
{
RetryCall(Profile.DefaultContext.Subscription.Id, call);
RetryCall(Profile.Context.Subscription.Id, call);
}

protected void RetryCall(Guid subsId, Action<string> call)
Expand Down Expand Up @@ -172,7 +172,7 @@ protected void RetryCall(Guid subsId, Action<string> call)

protected TResult RetryCall<TResult>(Func<string, TResult> call)
{
return RetryCall(Profile.DefaultContext.Subscription.Id, call);
return RetryCall(Profile.Context.Subscription.Id, call);
}

protected TResult RetryCall<TResult>(Guid subsId, Func<string, TResult> call)
Expand Down
2 changes: 1 addition & 1 deletion src/Common/Commands.Common/Commands.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
</Reference>
<Reference Include="Microsoft.Azure.Common.Authentication, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Microsoft.Azure.Common.Authentication.1.1.4-preview\lib\net45\Microsoft.Azure.Common.Authentication.dll</HintPath>
<HintPath>..\..\packages\Microsoft.Azure.Common.Authentication.1.2.2-preview\lib\net45\Microsoft.Azure.Common.Authentication.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Common.NetFramework">
<SpecificVersion>False</SpecificVersion>
Expand Down
4 changes: 2 additions & 2 deletions src/Common/Commands.Common/ProfileClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ public AzureAccount GetAccountOrDefault(string accountName)
{
if (string.IsNullOrEmpty(accountName))
{
return Profile.DefaultContext.Account;
return Profile.Context.Account;
}
else if (Profile.Accounts.ContainsKey(accountName))
{
Expand Down Expand Up @@ -1040,7 +1040,7 @@ public AzureEnvironment GetEnvironmentOrDefault(string name)
else if (string.IsNullOrEmpty(name) &&
Profile.DefaultSubscription != null)
{
return Profile.DefaultContext.Environment;
return Profile.Context.Environment;
}
else if (Profile.Environments.ContainsKey(name))
{
Expand Down
14 changes: 7 additions & 7 deletions src/Common/Commands.Common/RPRegistrationAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ public class RPRegistrationAction : IClientAction
private void RegisterResourceManagerProviders<T>(IAzureProfile profile)
{
var providersToRegister = RequiredResourceLookup.RequiredProvidersForResourceManager<T>();
var registeredProviders = profile.DefaultContext.Subscription.GetPropertyAsArray(AzureSubscription.Property.RegisteredResourceProviders);
var registeredProviders = profile.Context.Subscription.GetPropertyAsArray(AzureSubscription.Property.RegisteredResourceProviders);
var unregisteredProviders = providersToRegister.Where(p => !registeredProviders.Contains(p)).ToList();
var successfullyRegisteredProvider = new List<string>();
SubscriptionCloudCredentials creds = AzureSession.AuthenticationFactory.GetSubscriptionCloudCredentials(profile.DefaultContext);
SubscriptionCloudCredentials creds = AzureSession.AuthenticationFactory.GetSubscriptionCloudCredentials(profile.Context);

if (unregisteredProviders.Count > 0)
{
using (var client = ClientFactory.CreateCustomClient<ResourceManagementClient>(
creds,
profile.DefaultContext.Environment.GetEndpointAsUri(AzureEnvironment.Endpoint.ResourceManager)))
profile.Context.Environment.GetEndpointAsUri(AzureEnvironment.Endpoint.ResourceManager)))
{
foreach (string provider in unregisteredProviders)
{
Expand All @@ -64,17 +64,17 @@ private void RegisterResourceManagerProviders<T>(IAzureProfile profile)
/// <typeparam name="T">The client type</typeparam>
private void RegisterServiceManagementProviders<T>(AzureSMProfile profile)
{
var credentials = AzureSession.AuthenticationFactory.GetSubscriptionCloudCredentials(profile.DefaultContext);
var credentials = AzureSession.AuthenticationFactory.GetSubscriptionCloudCredentials(profile.Context);
var providersToRegister = RequiredResourceLookup.RequiredProvidersForServiceManagement<T>();
var registeredProviders = profile.DefaultContext.Subscription.GetPropertyAsArray(AzureSubscription.Property.RegisteredResourceProviders);
var registeredProviders = profile.Context.Subscription.GetPropertyAsArray(AzureSubscription.Property.RegisteredResourceProviders);
var unregisteredProviders = providersToRegister.Where(p => !registeredProviders.Contains(p)).ToList();
var successfullyRegisteredProvider = new List<string>();

if (unregisteredProviders.Count > 0)
{
using (var client = new ManagementClient(
credentials,
profile.DefaultContext.Environment.GetEndpointAsUri(AzureEnvironment.Endpoint.ServiceManagement)))
profile.Context.Environment.GetEndpointAsUri(AzureEnvironment.Endpoint.ServiceManagement)))
{
foreach (var provider in unregisteredProviders)
{
Expand All @@ -97,7 +97,7 @@ private void RegisterServiceManagementProviders<T>(AzureSMProfile profile)
}

Debug.Assert(profile is AzureSMProfile);
UpdateSubscriptionRegisteredProviders((AzureSMProfile)profile, profile.DefaultContext.Subscription, successfullyRegisteredProvider);
UpdateSubscriptionRegisteredProviders((AzureSMProfile)profile, profile.Context.Subscription, successfullyRegisteredProvider);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Common/Commands.Common/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<package id="Microsoft.ApplicationInsights" version="1.1.1-beta" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.2" targetFramework="net45" />
<package id="Microsoft.Azure.Common" version="2.1.0" targetFramework="net45" />
<package id="Microsoft.Azure.Common.Authentication" version="1.1.4-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Common.Authentication" version="1.2.2-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Resources" version="2.18.7-preview" targetFramework="net45" />
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net45" />
Expand Down
2 changes: 1 addition & 1 deletion src/Common/Commands.Profile/Commands.Profile.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<HintPath>..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Common.Authentication, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Azure.Common.Authentication.1.1.4-preview\lib\net45\Microsoft.Azure.Common.Authentication.dll</HintPath>
<HintPath>..\..\packages\Microsoft.Azure.Common.Authentication.1.2.2-preview\lib\net45\Microsoft.Azure.Common.Authentication.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.Common.NetFramework">
Expand Down
2 changes: 1 addition & 1 deletion src/Common/Commands.Profile/Models/PsAzureSubscription.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public PSAzureSubscription(AzureSubscription subscription, AzureSMProfile profil
DefaultAccount = subscription.Account;
Accounts = profile.Accounts.Values.Where(a => a.HasSubscription(subscription.Id)).ToArray();
IsDefault = subscription.IsPropertySet(AzureSubscription.Property.Default);
IsCurrent = profile.DefaultContext != null && profile.DefaultContext.Subscription.Id == subscription.Id;
IsCurrent = profile.Context != null && profile.Context.Subscription.Id == subscription.Id;
CurrentStorageAccountName = subscription.GetProperty(AzureSubscription.Property.StorageAccount);
TenantId = subscription.GetPropertyAsArray(AzureSubscription.Property.Tenants).FirstOrDefault();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ public override void ExecuteCmdlet()
{
case "ByName":
IEnumerable<AzureSubscription> subscriptions = new AzureSubscription[0];
if (Profile.DefaultContext != null && Profile.DefaultContext.Environment != null)
if (Profile.Context != null && Profile.Context.Environment != null)
{
subscriptions = ProfileClient.RefreshSubscriptions(Profile.DefaultContext.Environment)
subscriptions = ProfileClient.RefreshSubscriptions(Profile.Context.Environment)
.Where(
s =>
SubscriptionName == null ||
Expand Down Expand Up @@ -113,7 +113,7 @@ public void GetCurrent()
// since current is strictly in-memory and we want the real
// current subscription.
//
if (Profile.DefaultContext.Subscription == null)
if (Profile.Context.Subscription == null)
{
WriteError(new ErrorRecord(
new InvalidOperationException(Resources.InvalidSelectedSubscription),
Expand All @@ -122,7 +122,7 @@ public void GetCurrent()
}
else
{
WriteSubscriptions(Profile.DefaultContext.Subscription);
WriteSubscriptions(Profile.Context.Subscription);
}
}

Expand Down
Loading