Skip to content

Commit ee7dcb7

Browse files
committed
Merge branch 'dev' of github.com:Azure/azure-powershell into psget
2 parents 9a15249 + 35677e7 commit ee7dcb7

File tree

27 files changed

+1077
-1151
lines changed

27 files changed

+1077
-1151
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/Insights/Commands.Insights/Microsoft.Azure.Commands.Insights.dll-Help.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3575,7 +3575,7 @@ The value must be earlier than StartTime, but not more than 15 days.</maml:para>
35753575
<command:details>
35763576
<command:name>Get-AzureRMResourceProviderLog</command:name>
35773577
<maml:description>
3578-
<maml:para>Gets the operations associated with a Resource Provider (RP) for Azure Resource Manager (ARM). You can use the Get-AzureRMProvider command to list out the ARM Resource Providers that are available. By default, this command retrieves Resource Provider log entries for the last hour, however you can specify custom start and end times to get log entries from a specific time period.</maml:para>
3578+
<maml:para>Gets the operations associated with a Resource Provider (RP) for Azure Resource Manager (ARM). You can use the Get-AzureRMResourceProvider command to list out the ARM Resource Providers that are available. By default, this command retrieves Resource Provider log entries for the last hour, however you can specify custom start and end times to get log entries from a specific time period.</maml:para>
35793579
</maml:description>
35803580
<maml:copyright>
35813581
<maml:para />
@@ -3593,7 +3593,7 @@ The value must be earlier than StartTime, but not more than 15 days.</maml:para>
35933593
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="0">
35943594
<maml:name>ResourceProvider</maml:name>
35953595
<maml:description>
3596-
<maml:para>Specifies a filter by ResourceProvider. This parameter is mandatory. To discover a list of Resource Providers, use the Get-AzureRMProvider command.</maml:para>
3596+
<maml:para>Specifies a filter by ResourceProvider. This parameter is mandatory. To discover a list of Resource Providers, use the Get-AzureRMResourceProvider command.</maml:para>
35973597
</maml:description>
35983598
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
35993599
</command:parameter>

src/ResourceManager/OperationalInsights/Commands.OperationalInsights/Microsoft.Azure.Commands.OperationalInsights.dll-Help.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2053,7 +2053,7 @@
20532053
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp">
20542054
<!--Generated by PS Cmdlet Help Editor-->
20552055
<command:details>
2056-
<command:name>Get-AzureRMProvider</command:name>
2056+
<command:name>Get-AzureRMResourceProvider</command:name>
20572057
<maml:description>
20582058
<maml:para />
20592059
</maml:description>

src/ResourceManager/Resources/Commands.Resources.Test/ScenarioTests/MoveResourceTest.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function Test-MoveAzureResource
2727
$providerNamespace = "Providers.Test"
2828
$resourceType = $providerNamespace + "/statefulResources"
2929

30-
Register-AzureRMProvider -ProviderNamespace $providerNamespace -Force
30+
Register-AzureRMResourceProvider -ProviderNamespace $providerNamespace -Force
3131
New-AzureRMResourceGroup -Name $sourceResourceGroupName -Location $location -Force
3232
New-AzureRMResourceGroup -Name $destinationResourceGroupName -Location $location -Force
3333
$resource1 = New-AzureRMResource -Name $testResourceName1 -Location $location -Tags @{Name = "testtag"; Value = "testval"} -ResourceGroupName $sourceResourceGroupName -ResourceType $resourceType -PropertyObject @{"administratorLogin" = "adminuser"; "administratorLoginPassword" = "P@ssword1"} -ApiVersion $apiversion -Force

src/ResourceManager/Resources/Commands.Resources.Test/ScenarioTests/ProviderTests.ps1

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,33 +18,33 @@
1818
#>
1919
function Test-AzureProvider
2020
{
21-
$defaultProviders = Get-AzureRMProvider
21+
$defaultProviders = Get-AzureRMResourceProvider
2222

2323
Assert-True { $defaultProviders.Length -gt 0 }
2424

25-
$allProviders = Get-AzureRMProvider -ListAvailable
25+
$allProviders = Get-AzureRMResourceProvider -ListAvailable
2626

2727
Assert-True { $allProviders.Length -gt $defaultProviders.Length }
2828

29-
Register-AzureRMProvider -ProviderName "Microsoft.ApiManagement" -Force
29+
Register-AzureRMResourceProvider -ProviderName "Microsoft.ApiManagement" -Force
3030

3131
$endTime = [DateTime]::UtcNow.AddMinutes(5)
3232

33-
while ([DateTime]::UtcNow -lt $endTime -and @(Get-AzureRMProvider -ProviderName "Microsoft.ApiManagement").RegistrationState -ne "Registered")
33+
while ([DateTime]::UtcNow -lt $endTime -and @(Get-AzureRMResourceProvider -ProviderName "Microsoft.ApiManagement").RegistrationState -ne "Registered")
3434
{
3535
[Microsoft.WindowsAzure.Commands.Utilities.Common.TestMockSupport]::Delay(1000)
3636
}
3737

38-
Assert-True { @(Get-AzureRMProvider -ProviderName "Microsoft.ApiManagement").RegistrationState -eq "Registered" }
38+
Assert-True { @(Get-AzureRMResourceProvider -ProviderName "Microsoft.ApiManagement").RegistrationState -eq "Registered" }
3939

40-
Unregister-AzureRMProvider -ProviderName "Microsoft.ApiManagement" -Force
40+
Unregister-AzureRMResourceProvider -ProviderName "Microsoft.ApiManagement" -Force
4141

42-
while ([DateTime]::UtcNow -lt $endTime -and @(Get-AzureRMProvider -ProviderName "Microsoft.ApiManagement").RegistrationState -ne "Unregistered")
42+
while ([DateTime]::UtcNow -lt $endTime -and @(Get-AzureRMResourceProvider -ProviderName "Microsoft.ApiManagement").RegistrationState -ne "Unregistered")
4343
{
4444
[Microsoft.WindowsAzure.Commands.Utilities.Common.TestMockSupport]::Delay(1000)
4545
}
4646

47-
Assert-True { @(Get-AzureRMProvider -ProviderName "Microsoft.ApiManagement").RegistrationState -eq "Unregistered" }
47+
Assert-True { @(Get-AzureRMResourceProvider -ProviderName "Microsoft.ApiManagement").RegistrationState -eq "Unregistered" }
4848
}
4949

5050
<#

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'

0 commit comments

Comments
 (0)