Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions setup/azurecmd.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<?define sourceDir="$(var.SolutionDir)..\src\Package\$(var.Configuration)" ?>
<?define caSourceDir="$(var.SolutionDir)setup\bin\$(var.Configuration)" ?>

<?define version="0.9.8" ?>
<?define version="0.9.9" ?>
<?define versionedStartMenuFolder="Microsoft Azure" ?>
<?define staleStartMenuFolder="Windows Azure" ?>

Expand Down Expand Up @@ -69,7 +69,7 @@
<Component Id="PSModulePath.System" Guid="273525B9-7AAB-421A-90C8-8E50A1840B8D">
<CreateFolder />
<!-- Work around bug that PowerShell does not always consider default module paths. -->
<Environment Id="PSModulePath.SystemAppRoot" Action="set" Name="PSMODULEPATH" Part="last" Value="[PowerShellFolder]ServiceManagement" System="yes" />
<Environment Id="PSModulePath.SystemAppRoot" Action="set" Name="PSMODULEPATH" Part="last" Value="[PowerShellFolder]ResourceManager;[PowerShellFolder]ServiceManagement" System="yes" />
</Component>
</DirectoryRef>

Expand Down
4 changes: 2 additions & 2 deletions src/Common/Commands.Common.Storage/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@
[assembly: ComVisible(false)]
[assembly: CLSCompliant(false)]
[assembly: Guid("c565107e-98a9-4703-85cd-a7efc3d8da7b")]
[assembly: AssemblyVersion("0.9.8")]
[assembly: AssemblyFileVersion("0.9.8")]
[assembly: AssemblyVersion("0.9.9")]
[assembly: AssemblyFileVersion("0.9.9")]
4 changes: 2 additions & 2 deletions src/Common/Commands.Common/AzurePowerShell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ public class AzurePowerShell

public const string AssemblyCopyright = "Copyright © Microsoft";

public const string AssemblyVersion = "0.9.8";
public const string AssemblyVersion = "0.9.9";

public const string AssemblyFileVersion = "0.9.8";
public const string AssemblyFileVersion = "0.9.9";

public const string ProfileFile = "AzureProfile.json";

Expand Down
1 change: 0 additions & 1 deletion src/Common/Commands.Profile/Commands.Profile.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@
<Compile Include="Profile\SelectAzureProfile.cs" />
<Compile Include="Profile\NewAzureProfile.cs" />
<Compile Include="Profile\ClearAzureProfile.cs" />
<Compile Include="SwitchAzureMode.cs" />
<Compile Include="Account\AddAzureAccount.cs" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOVE IT!!

<Compile Include="Subscription\RemoveAzureSubscription.cs" />
<Compile Include="Account\GetAzureAccount.cs" />
Expand Down
89 changes: 0 additions & 89 deletions src/Common/Commands.Profile/SwitchAzureMode.cs

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ Select Y to enable data collection [Y/N]:</value>
<data name="InvalidDefaultSubscription" xml:space="preserve">
<value>No default subscription has been designated. Use Select-AzureSubscription -Default &lt;subscriptionName&gt; to set the default subscription.</value>
</data>
<data name="NoSubscriptionFound" xml:space="preserve">
<value>The provided account {0} does not have access to any subscriptions. Please try logging in with different credentials.</value>
</data>
<data name="TenantNotFound" xml:space="preserve">
<value>Tenant '{0}' was not found. Please verify that your account has access to this tenant.</value>
</data>
Expand Down
74 changes: 39 additions & 35 deletions src/Common/Commands.ResourceManager.Common/RMProfileClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ public AzureRMProfile Login(AzureAccount account, AzureEnvironment environment,
// (tenant is present and subscription is not provided)
if (!string.IsNullOrEmpty(tenantId))
{
TryGetTenantSubscription(account, environment, tenantId, subscriptionId, password, promptBehavior, out newSubscription, out newTenant);
var token = AcquireAccessToken(account, environment, tenantId, password, promptBehavior);
TryGetTenantSubscription(token, account, environment, tenantId, subscriptionId, out newSubscription, out newTenant);
}
// (tenant is not provided and subscription is present) OR
// (tenant is not provided and subscription is not provided)
Expand All @@ -63,16 +64,21 @@ public AzureRMProfile Login(AzureAccount account, AzureEnvironment environment,
foreach(var tenant in ListAccountTenants(account, environment, password, promptBehavior))
{
AzureTenant tempTenant;
if (TryGetTenantSubscription(account, environment, tenant.Id.ToString(), subscriptionId, password, ShowDialog.Auto, out newSubscription, out tempTenant))
{
AzureSubscription tempSubscription;
var token = AcquireAccessToken(account, environment, tenant.Id.ToString(), password,
ShowDialog.Auto);
if (newTenant == null && TryGetTenantSubscription(token, account, environment, tenant.Id.ToString(), subscriptionId, out tempSubscription, out tempTenant) &&
newTenant == null)
{
newTenant = tempTenant;
newSubscription = tempSubscription;
}
}
}

if (newSubscription == null)
{
throw new PSInvalidOperationException("Subscription was not found.");
throw new PSInvalidOperationException(String.Format(Properties.Resources.NoSubscriptionFound, account.Id));
}

_profile.Context = new AzureContext(newSubscription, account, environment, newTenant);
Expand Down Expand Up @@ -135,12 +141,14 @@ public bool TryGetSubscription(string tenantId, string subscriptionId, out Azure
{
if (string.IsNullOrWhiteSpace(tenantId))
{
throw new ArgumentNullException("Please provide a valid tenant Id");
throw new ArgumentNullException("Please provide a valid tenant Id.");
}

AzureTenant tenant;
return TryGetTenantSubscription(_profile.Context.Account, _profile.Context.Environment,
tenantId, subscriptionId, null, ShowDialog.Never, out subscription, out tenant);
var token = AcquireAccessToken(_profile.Context.Account, _profile.Context.Environment,
tenantId, null, ShowDialog.Never);
return TryGetTenantSubscription(token, _profile.Context.Account, _profile.Context.Environment,
tenantId, subscriptionId, out subscription, out tenant);
}

public AzureEnvironment AddOrSetEnvironment(AzureEnvironment environment)
Expand Down Expand Up @@ -235,23 +243,30 @@ private AzureEnvironment MergeEnvironmentProperties(AzureEnvironment environment
return mergedEnvironment;
}

private bool TryGetTenantSubscription(
AzureAccount account,
AzureEnvironment environment,
string tenantId,
string subscriptionId,
SecureString password,
ShowDialog promptBehavior,
private IAccessToken AcquireAccessToken(AzureAccount account,
AzureEnvironment environment,
string tenantId,
SecureString password,
ShowDialog promptBehavior)
{
return AzureSession.AuthenticationFactory.Authenticate(
account,
environment,
tenantId,
password,
promptBehavior,
TokenCache.DefaultShared);
}

private bool TryGetTenantSubscription(IAccessToken accessToken,
AzureAccount account,
AzureEnvironment environment,
string tenantId,
string subscriptionId,
out AzureSubscription subscription,
out AzureTenant tenant)
{
var accessToken = AzureSession.AuthenticationFactory.Authenticate(
account,
environment,
tenantId,
password,
promptBehavior,
TokenCache.DefaultShared);

using (var subscriptionClient = AzureSession.ClientFactory.CreateCustomClient<SubscriptionClient>(
new TokenCloudCredentials(accessToken.AccessToken),
environment.GetEndpointAsUri(AzureEnvironment.Endpoint.ResourceManager)))
Expand Down Expand Up @@ -311,13 +326,8 @@ private bool TryGetTenantSubscription(

private List<AzureTenant> ListAccountTenants(AzureAccount account, AzureEnvironment environment, SecureString password, ShowDialog promptBehavior)
{
var commonTenantToken = AzureSession.AuthenticationFactory.Authenticate(
account,
environment,
AuthenticationFactory.CommonAdTenant,
password,
promptBehavior,
TokenCache.DefaultShared);
var commonTenantToken = AcquireAccessToken( account, environment, AuthenticationFactory.CommonAdTenant,
password, promptBehavior);

using (var subscriptionClient = AzureSession.ClientFactory.CreateCustomClient<SubscriptionClient>(
new TokenCloudCredentials(commonTenantToken.AccessToken),
Expand All @@ -341,13 +351,7 @@ public IEnumerable<AzureTenant> ListTenants()
private IEnumerable<AzureSubscription> ListSubscriptionsForTenant(AzureAccount account, AzureEnvironment environment,
SecureString password, ShowDialog promptBehavior, string tenantId)
{
var accessToken = AzureSession.AuthenticationFactory.Authenticate(
account,
environment,
tenantId,
password,
promptBehavior,
TokenCache.DefaultShared);
var accessToken = AcquireAccessToken(account, environment, tenantId, password, promptBehavior);
using (var subscriptionClient = AzureSession.ClientFactory.CreateCustomClient<SubscriptionClient>(
new TokenCloudCredentials(accessToken.AccessToken),
environment.GetEndpointAsUri(AzureEnvironment.Endpoint.ResourceManager)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@{

# Version number of this module.
ModuleVersion = '0.9.8'
ModuleVersion = '0.9.9'

# ID used to uniquely identify this module
GUID = 'F237EAAA-BD3A-4965-AD4A-BF38598BFEF7'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@{

# Version number of this module.
ModuleVersion = '0.9.8'
ModuleVersion = '0.9.9'

# ID used to uniquely identify this module
GUID = '81d522a4-6e5d-4105-8f58-376204c47458'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@{

# Version number of this module.
ModuleVersion = '0.9.8'
ModuleVersion = '0.9.9'

# ID used to uniquely identify this module
GUID = 'F237EAAA-BD3A-4965-AD4A-BF38598BFEF7'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
[assembly: ComVisible(false)]
[assembly: CLSCompliant(false)]
[assembly: Guid("e386b843-f3f0-4db3-8664-37d16b860dde")]
[assembly: AssemblyVersion("0.9.8")]
[assembly: AssemblyFileVersion("0.9.8")]
[assembly: AssemblyVersion("0.9.9")]
[assembly: AssemblyFileVersion("0.9.9")]
#if SIGN
[assembly: InternalsVisibleTo("Microsoft.Azure.Commands.Resources.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]
#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
ModuleToProcess = '.\Microsoft.WindowsAzure.Commands.ServiceManagement.PlatformImageRepository.dll'

# Version number of this module.
ModuleVersion = '0.9.8'
ModuleVersion = '0.9.9'

# ID used to uniquely identify this module
GUID = 'a9343cbd-175c-4f72-90c7-2abe9b300644'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
ModuleToProcess = '.\Microsoft.WindowsAzure.Commands.ServiceManagement.Preview.dll'

# Version number of this module.
ModuleVersion = '0.9.8'
ModuleVersion = '0.9.9'

# ID used to uniquely identify this module
GUID = '1C72E555-E83F-45E4-AED2-AF3278828DCD'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
ModuleToProcess = '.\Microsoft.WindowsAzure.Commands.ExpressRoute.dll'

# Version number of this module.
ModuleVersion = '0.9.8'
ModuleVersion = '0.9.9'

# ID used to uniquely identify this module
GUID = 'e5b10573-30da-456a-9319-4c0a5f8bed4a'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@{

# Version number of this module.
ModuleVersion = '0.9.8'
ModuleVersion = '0.9.9'

# ID used to uniquely identify this module
GUID = 'D48CF693-4125-4D2D-8790-1514F44CE325'
Expand Down
Loading