Skip to content

Commit 35677e7

Browse files
committed
Merge pull request Azure#942 from markcowl/partnermsi
Changing partner msi to remove Switch-AzureMode, load both modules, a…
2 parents f66cc5a + 5744f7c commit 35677e7

File tree

17 files changed

+1049
-1123
lines changed

17 files changed

+1049
-1123
lines changed

setup/azurecmd.wxs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<?define sourceDir="$(var.SolutionDir)..\src\Package\$(var.Configuration)" ?>
66
<?define caSourceDir="$(var.SolutionDir)setup\bin\$(var.Configuration)" ?>
77

8-
<?define version="0.9.8" ?>
8+
<?define version="0.9.9" ?>
99
<?define versionedStartMenuFolder="Microsoft Azure" ?>
1010
<?define staleStartMenuFolder="Windows Azure" ?>
1111

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

src/Common/Commands.Common.Storage/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@
2424
[assembly: ComVisible(false)]
2525
[assembly: CLSCompliant(false)]
2626
[assembly: Guid("c565107e-98a9-4703-85cd-a7efc3d8da7b")]
27-
[assembly: AssemblyVersion("0.9.8")]
28-
[assembly: AssemblyFileVersion("0.9.8")]
27+
[assembly: AssemblyVersion("0.9.9")]
28+
[assembly: AssemblyFileVersion("0.9.9")]

src/Common/Commands.Common/AzurePowerShell.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ public class AzurePowerShell
2727

2828
public const string AssemblyCopyright = "Copyright © Microsoft";
2929

30-
public const string AssemblyVersion = "0.9.8";
30+
public const string AssemblyVersion = "0.9.9";
3131

32-
public const string AssemblyFileVersion = "0.9.8";
32+
public const string AssemblyFileVersion = "0.9.9";
3333

3434
public const string ProfileFile = "AzureProfile.json";
3535

src/Common/Commands.Profile/Commands.Profile.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@
141141
<Compile Include="Profile\SelectAzureProfile.cs" />
142142
<Compile Include="Profile\NewAzureProfile.cs" />
143143
<Compile Include="Profile\ClearAzureProfile.cs" />
144-
<Compile Include="SwitchAzureMode.cs" />
145144
<Compile Include="Account\AddAzureAccount.cs" />
146145
<Compile Include="Subscription\RemoveAzureSubscription.cs" />
147146
<Compile Include="Account\GetAzureAccount.cs" />

src/Common/Commands.Profile/SwitchAzureMode.cs

Lines changed: 0 additions & 89 deletions
This file was deleted.

src/Common/Commands.ResourceManager.Common/Properties/Resources.Designer.cs

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Common/Commands.ResourceManager.Common/Properties/Resources.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ Select Y to enable data collection [Y/N]:</value>
148148
<data name="InvalidDefaultSubscription" xml:space="preserve">
149149
<value>No default subscription has been designated. Use Select-AzureSubscription -Default &lt;subscriptionName&gt; to set the default subscription.</value>
150150
</data>
151+
<data name="NoSubscriptionFound" xml:space="preserve">
152+
<value>The provided account {0} does not have access to any subscriptions. Please try logging in with different credentials.</value>
153+
</data>
151154
<data name="TenantNotFound" xml:space="preserve">
152155
<value>Tenant '{0}' was not found. Please verify that your account has access to this tenant.</value>
153156
</data>

src/Common/Commands.ResourceManager.Common/RMProfileClient.cs

Lines changed: 39 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ public AzureRMProfile Login(AzureAccount account, AzureEnvironment environment,
5454
// (tenant is present and subscription is not provided)
5555
if (!string.IsNullOrEmpty(tenantId))
5656
{
57-
TryGetTenantSubscription(account, environment, tenantId, subscriptionId, password, promptBehavior, out newSubscription, out newTenant);
57+
var token = AcquireAccessToken(account, environment, tenantId, password, promptBehavior);
58+
TryGetTenantSubscription(token, account, environment, tenantId, subscriptionId, out newSubscription, out newTenant);
5859
}
5960
// (tenant is not provided and subscription is present) OR
6061
// (tenant is not provided and subscription is not provided)
@@ -63,16 +64,21 @@ public AzureRMProfile Login(AzureAccount account, AzureEnvironment environment,
6364
foreach(var tenant in ListAccountTenants(account, environment, password, promptBehavior))
6465
{
6566
AzureTenant tempTenant;
66-
if (TryGetTenantSubscription(account, environment, tenant.Id.ToString(), subscriptionId, password, ShowDialog.Auto, out newSubscription, out tempTenant))
67-
{
67+
AzureSubscription tempSubscription;
68+
var token = AcquireAccessToken(account, environment, tenant.Id.ToString(), password,
69+
ShowDialog.Auto);
70+
if (newTenant == null && TryGetTenantSubscription(token, account, environment, tenant.Id.ToString(), subscriptionId, out tempSubscription, out tempTenant) &&
71+
newTenant == null)
72+
{
6873
newTenant = tempTenant;
74+
newSubscription = tempSubscription;
6975
}
7076
}
7177
}
7278

7379
if (newSubscription == null)
7480
{
75-
throw new PSInvalidOperationException("Subscription was not found.");
81+
throw new PSInvalidOperationException(String.Format(Properties.Resources.NoSubscriptionFound, account.Id));
7682
}
7783

7884
_profile.Context = new AzureContext(newSubscription, account, environment, newTenant);
@@ -135,12 +141,14 @@ public bool TryGetSubscription(string tenantId, string subscriptionId, out Azure
135141
{
136142
if (string.IsNullOrWhiteSpace(tenantId))
137143
{
138-
throw new ArgumentNullException("Please provide a valid tenant Id");
144+
throw new ArgumentNullException("Please provide a valid tenant Id.");
139145
}
140146

141147
AzureTenant tenant;
142-
return TryGetTenantSubscription(_profile.Context.Account, _profile.Context.Environment,
143-
tenantId, subscriptionId, null, ShowDialog.Never, out subscription, out tenant);
148+
var token = AcquireAccessToken(_profile.Context.Account, _profile.Context.Environment,
149+
tenantId, null, ShowDialog.Never);
150+
return TryGetTenantSubscription(token, _profile.Context.Account, _profile.Context.Environment,
151+
tenantId, subscriptionId, out subscription, out tenant);
144152
}
145153

146154
public AzureEnvironment AddOrSetEnvironment(AzureEnvironment environment)
@@ -235,23 +243,30 @@ private AzureEnvironment MergeEnvironmentProperties(AzureEnvironment environment
235243
return mergedEnvironment;
236244
}
237245

238-
private bool TryGetTenantSubscription(
239-
AzureAccount account,
240-
AzureEnvironment environment,
241-
string tenantId,
242-
string subscriptionId,
243-
SecureString password,
244-
ShowDialog promptBehavior,
246+
private IAccessToken AcquireAccessToken(AzureAccount account,
247+
AzureEnvironment environment,
248+
string tenantId,
249+
SecureString password,
250+
ShowDialog promptBehavior)
251+
{
252+
return AzureSession.AuthenticationFactory.Authenticate(
253+
account,
254+
environment,
255+
tenantId,
256+
password,
257+
promptBehavior,
258+
TokenCache.DefaultShared);
259+
}
260+
261+
private bool TryGetTenantSubscription(IAccessToken accessToken,
262+
AzureAccount account,
263+
AzureEnvironment environment,
264+
string tenantId,
265+
string subscriptionId,
245266
out AzureSubscription subscription,
246267
out AzureTenant tenant)
247268
{
248-
var accessToken = AzureSession.AuthenticationFactory.Authenticate(
249-
account,
250-
environment,
251-
tenantId,
252-
password,
253-
promptBehavior,
254-
TokenCache.DefaultShared);
269+
255270
using (var subscriptionClient = AzureSession.ClientFactory.CreateCustomClient<SubscriptionClient>(
256271
new TokenCloudCredentials(accessToken.AccessToken),
257272
environment.GetEndpointAsUri(AzureEnvironment.Endpoint.ResourceManager)))
@@ -311,13 +326,8 @@ private bool TryGetTenantSubscription(
311326

312327
private List<AzureTenant> ListAccountTenants(AzureAccount account, AzureEnvironment environment, SecureString password, ShowDialog promptBehavior)
313328
{
314-
var commonTenantToken = AzureSession.AuthenticationFactory.Authenticate(
315-
account,
316-
environment,
317-
AuthenticationFactory.CommonAdTenant,
318-
password,
319-
promptBehavior,
320-
TokenCache.DefaultShared);
329+
var commonTenantToken = AcquireAccessToken( account, environment, AuthenticationFactory.CommonAdTenant,
330+
password, promptBehavior);
321331

322332
using (var subscriptionClient = AzureSession.ClientFactory.CreateCustomClient<SubscriptionClient>(
323333
new TokenCloudCredentials(commonTenantToken.AccessToken),
@@ -341,13 +351,7 @@ public IEnumerable<AzureTenant> ListTenants()
341351
private IEnumerable<AzureSubscription> ListSubscriptionsForTenant(AzureAccount account, AzureEnvironment environment,
342352
SecureString password, ShowDialog promptBehavior, string tenantId)
343353
{
344-
var accessToken = AzureSession.AuthenticationFactory.Authenticate(
345-
account,
346-
environment,
347-
tenantId,
348-
password,
349-
promptBehavior,
350-
TokenCache.DefaultShared);
354+
var accessToken = AcquireAccessToken(account, environment, tenantId, password, promptBehavior);
351355
using (var subscriptionClient = AzureSession.ClientFactory.CreateCustomClient<SubscriptionClient>(
352356
new TokenCloudCredentials(accessToken.AccessToken),
353357
environment.GetEndpointAsUri(AzureEnvironment.Endpoint.ResourceManager)))

src/ResourceManager/HDInsight/Commands.HDInsight/Microsoft.Azure.Commands.HDInsight.dll-help.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
@{
1010

1111
# Version number of this module.
12-
ModuleVersion = '0.9.8'
12+
ModuleVersion = '0.9.9'
1313

1414
# ID used to uniquely identify this module
1515
GUID = 'F237EAAA-BD3A-4965-AD4A-BF38598BFEF7'

src/ResourceManager/Resources/Commands.Resources/AzureResourceManager.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
@{
1010

1111
# Version number of this module.
12-
ModuleVersion = '0.9.8'
12+
ModuleVersion = '0.9.9'
1313

1414
# ID used to uniquely identify this module
1515
GUID = '81d522a4-6e5d-4105-8f58-376204c47458'

src/ResourceManager/Storage/Commands.Management.Storage/Microsoft.Azure.Commands.Management.Storage.dll-Help.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
@{
1010

1111
# Version number of this module.
12-
ModuleVersion = '0.9.8'
12+
ModuleVersion = '0.9.9'
1313

1414
# ID used to uniquely identify this module
1515
GUID = 'F237EAAA-BD3A-4965-AD4A-BF38598BFEF7'

src/ResourceManager/Tags/Commands.Tags/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
[assembly: ComVisible(false)]
2626
[assembly: CLSCompliant(false)]
2727
[assembly: Guid("e386b843-f3f0-4db3-8664-37d16b860dde")]
28-
[assembly: AssemblyVersion("0.9.8")]
29-
[assembly: AssemblyFileVersion("0.9.8")]
28+
[assembly: AssemblyVersion("0.9.9")]
29+
[assembly: AssemblyFileVersion("0.9.9")]
3030
#if SIGN
3131
[assembly: InternalsVisibleTo("Microsoft.Azure.Commands.Resources.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]
3232
#else

src/ServiceManagement/Compute/Commands.ServiceManagement.PlatformImageRepository/PIR.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
ModuleToProcess = '.\Microsoft.WindowsAzure.Commands.ServiceManagement.PlatformImageRepository.dll'
1313

1414
# Version number of this module.
15-
ModuleVersion = '0.9.8'
15+
ModuleVersion = '0.9.9'
1616

1717
# ID used to uniquely identify this module
1818
GUID = 'a9343cbd-175c-4f72-90c7-2abe9b300644'

src/ServiceManagement/Compute/Commands.ServiceManagement.Preview/AzurePreview.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
ModuleToProcess = '.\Microsoft.WindowsAzure.Commands.ServiceManagement.Preview.dll'
1313

1414
# Version number of this module.
15-
ModuleVersion = '0.9.8'
15+
ModuleVersion = '0.9.9'
1616

1717
# ID used to uniquely identify this module
1818
GUID = '1C72E555-E83F-45E4-AED2-AF3278828DCD'

src/ServiceManagement/ExpressRoute/Commands.ExpressRoute/ExpressRoute.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
ModuleToProcess = '.\Microsoft.WindowsAzure.Commands.ExpressRoute.dll'
1313

1414
# Version number of this module.
15-
ModuleVersion = '0.9.8'
15+
ModuleVersion = '0.9.9'
1616

1717
# ID used to uniquely identify this module
1818
GUID = 'e5b10573-30da-456a-9319-4c0a5f8bed4a'

src/ServiceManagement/Services/Commands.Utilities/Azure.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
@{
1010

1111
# Version number of this module.
12-
ModuleVersion = '0.9.8'
12+
ModuleVersion = '0.9.9'
1313

1414
# ID used to uniquely identify this module
1515
GUID = 'D48CF693-4125-4D2D-8790-1514F44CE325'

0 commit comments

Comments
 (0)