Skip to content

Commit a19b781

Browse files
author
Maddie Clayton
committed
Merge branch 'preview' of https://github.com/Azure/azure-powershell into AddAsJobCompute
2 parents 23efe2b + 978b243 commit a19b781

File tree

283 files changed

+190983
-104332
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

283 files changed

+190983
-104332
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Below is a table containing the various Azure PowerShell rollup modules found in
1717
| Rollup Module for ARM Cmdlets | `AzureRM` | [![AzureRM](https://img.shields.io/powershellgallery/v/AzureRM.svg?style=flat-square&label=AzureRM)](https://www.powershellgallery.com/packages/AzureRM/) |
1818
| Rollup Module for .NET Core Cmdlets | `AzureRM.Netcore` | [![AzureRM.Netcore](https://img.shields.io/powershellgallery/v/AzureRM.Netcore.svg?style=flat-square&label=AzureRM.Netcore)](https://www.powershellgallery.com/packages/AzureRM.Netcore/) |
1919
| Rollup Module for Administrative Modules in Azure Stack | `AzureStack` | [![AzureStack](https://img.shields.io/powershellgallery/v/AzureStack.svg?style=flat-square&label=AzureStack)](https://www.powershellgallery.com/packages/AzureStack/) |
20-
| Rolledup Module for Service Management Cmdlets | `Azure` | [![Azure](https://img.shields.io/powershellgallery/v/Azure.svg?style=flat-square&label=Azure)](https://www.powershellgallery.com/packages/Azure/) |
20+
| Rollup Module for Service Management Cmdlets | `Azure` | [![Azure](https://img.shields.io/powershellgallery/v/Azure.svg?style=flat-square&label=Azure)](https://www.powershellgallery.com/packages/Azure/) |
2121

2222
## Features
2323

TestMappings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@
4444
"src/ResourceManager/DataLakeStore/": [
4545
".\\src\\ResourceManager\\DataLakeStore\\Commands.DataLakeStore.Test\\bin\\Debug\\Microsoft.Azure.Commands.DataLake.Test.dll"
4646
],
47+
"src/ResourceManager/DataMigration/": [
48+
".\\src\\ResourceManager\\DataMigration\\Commands.DataMigration.Test\\bin\\Debug\\Microsoft.Azure.Commands.DataMigration.Test.dll"
49+
],
4750
"src/ResourceManager/DevTestLabs/": [],
4851
"src/ResourceManager/Dns/": [
4952
".\\src\\ResourceManager\\Dns\\Commands.Dns.Test\\bin\\Debug\\Microsoft.Azure.Commands.Dns.Test.dll"

build.proj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,9 @@
531531
<!-- Run checkin tests for each pull request -->
532532
<Target Name="Test" DependsOnTargets="BeforeRunTests">
533533
<Message Importance="high" Text="Running check in tests..." />
534+
<!-- Run Pester tests -->
535+
<Exec Command="&quot;$(PowerShellCommand)&quot; -NonInteractive -NoLogo -NoProfile -Command &quot;$(MSBuildProjectDirectory)\tools\Modules\Run-UnitTests.ps1&quot;"
536+
ContinueOnError="ErrorAndContinue"/>
534537
<CallTarget Targets="InvokeXUnit"/>
535538
</Target>
536539

setup/azurecmdfiles.wxi

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,23 @@
516516
<File Id="fil509D1E7494560B2BB3462B8FAD7954CF" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.DataLakeStore\Microsoft.Azure.Management.DataLake.Store.dll" />
517517
</Component>
518518
</Directory>
519+
<Directory Id="dir737D4AB8FD306B33AFF72CE69894AEC6" Name="AzureRM.DataMigration">
520+
<Component Id="cmpF537AF8D3332C6ECBEC0516187F2220F" Guid="*">
521+
<File Id="fil38B67D67DD39331782A801AB1268A382" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.DataMigration\AzureRM.DataMigration.psd1" />
522+
</Component>
523+
<Component Id="cmp62BC16A48F4AAB22EAFDB6EA8C458B36" Guid="*">
524+
<File Id="filB3373AF76FB37D674E8110F7B07D406B" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.DataMigration\AzureRM.DataMigration.psm1" />
525+
</Component>
526+
<Component Id="cmpB20E0977CD0B2DFD15CEFF2F07F39AB9" Guid="*">
527+
<File Id="filBFF0F6B3EE0CADBC6E8D145D70B031BB" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.DataMigration\Microsoft.Azure.Commands.DataMigration.dll" />
528+
</Component>
529+
<Component Id="cmp8D46A82F0869AFC4C01CACAC464F81E9" Guid="*">
530+
<File Id="fil6EA1FAE6CF33BFDC7C44362C0A050A09" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.DataMigration\Microsoft.Azure.Commands.DataMigration.dll-Help.xml" />
531+
</Component>
532+
<Component Id="cmp636578DE56B109ECA4CF967ED6BE2823" Guid="*">
533+
<File Id="fil9172B5B303F5B98071CEC5BDA731C87B" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.DataMigration\Microsoft.Azure.Management.DataMigration.dll" />
534+
</Component>
535+
</Directory>
519536
<Directory Id="dir58E771D29F659E11F33C1EBA94EBEC2D" Name="AzureRM.DevTestLabs">
520537
<Component Id="cmpB88BB2B8DA875D258057401A820E82D6" Guid="*">
521538
<File Id="filE1512C82B1E6F38CDFD909FFD8C61C64" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.DevTestLabs\AzureRM.DevTestLabs.psd1" />
@@ -3282,6 +3299,11 @@
32823299
<ComponentRef Id="cmp3E5522CBA7172D5BE69D628639359496" />
32833300
<ComponentRef Id="cmp001FEDC74DD7D918EFE88F2EB8E4285C" />
32843301
<ComponentRef Id="cmp3C96010EFA751762A76B66B811613835" />
3302+
<ComponentRef Id="cmpF537AF8D3332C6ECBEC0516187F2220F" />
3303+
<ComponentRef Id="cmp62BC16A48F4AAB22EAFDB6EA8C458B36" />
3304+
<ComponentRef Id="cmpB20E0977CD0B2DFD15CEFF2F07F39AB9" />
3305+
<ComponentRef Id="cmp8D46A82F0869AFC4C01CACAC464F81E9" />
3306+
<ComponentRef Id="cmp636578DE56B109ECA4CF967ED6BE2823" />
32853307
<ComponentRef Id="cmpB88BB2B8DA875D258057401A820E82D6" />
32863308
<ComponentRef Id="cmp727F3C3BF9F149CC43CD2F72DB01F9AF" />
32873309
<ComponentRef Id="cmpCF89ADAF131C4033F0441CD44BD5AFF9" />

src/Common/Commands.Common.Authentication.Test/AuthenticationFactoryTests.cs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
using Microsoft.WindowsAzure.Commands.ScenarioTest;
2222
using Xunit;
2323
using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
24+
using System.Linq;
2425

2526
namespace Common.Authentication.Test
2627
{
@@ -98,5 +99,55 @@ public void VerifyValidateAuthorityFalseForOnPremise()
9899

99100
Assert.False(((MockAccessTokenProvider)authFactory.TokenProvider).AdalConfiguration.ValidateAuthority);
100101
}
102+
103+
[Fact]
104+
[Trait(Category.AcceptanceType, Category.CheckIn)]
105+
public void CanAuthenticateWithAccessToken()
106+
{
107+
AzureSessionInitializer.InitializeAzureSession();
108+
string tenant = Guid.NewGuid().ToString();
109+
string userId = "[email protected]";
110+
var armToken = Guid.NewGuid().ToString();
111+
var graphToken = Guid.NewGuid().ToString();
112+
var kvToken = Guid.NewGuid().ToString();
113+
var account = new AzureAccount
114+
{
115+
Id = userId,
116+
Type = AzureAccount.AccountType.AccessToken
117+
};
118+
account.SetTenants(tenant);
119+
account.SetAccessToken(armToken);
120+
account.SetProperty(AzureAccount.Property.GraphAccessToken, graphToken);
121+
account.SetProperty(AzureAccount.Property.KeyVaultAccessToken, kvToken);
122+
var authFactory = new AuthenticationFactory();
123+
var environment = AzureEnvironment.PublicEnvironments.Values.First();
124+
var checkArmToken = authFactory.Authenticate(account, environment, tenant, new System.Security.SecureString(), "Never", null);
125+
VerifyToken(checkArmToken, armToken, userId, tenant);
126+
checkArmToken = authFactory.Authenticate(account, environment, tenant, new System.Security.SecureString(), "Never", null, environment.ActiveDirectoryServiceEndpointResourceId);
127+
VerifyToken(checkArmToken, armToken, userId, tenant);
128+
var checkGraphToken = authFactory.Authenticate(account, environment, tenant, new System.Security.SecureString(), "Never", null, AzureEnvironment.Endpoint.GraphEndpointResourceId);
129+
VerifyToken(checkGraphToken, graphToken, userId, tenant);
130+
checkGraphToken = authFactory.Authenticate(account, environment, tenant, new System.Security.SecureString(), "Never", null, environment.GraphEndpointResourceId);
131+
VerifyToken(checkGraphToken, graphToken, userId, tenant);
132+
var checkKVToken = authFactory.Authenticate(account, environment, tenant, new System.Security.SecureString(), "Never", null, environment.AzureKeyVaultServiceEndpointResourceId);
133+
VerifyToken(checkKVToken, kvToken, userId, tenant);
134+
checkKVToken = authFactory.Authenticate(account, environment, tenant, new System.Security.SecureString(), "Never", null, AzureEnvironment.Endpoint.AzureKeyVaultServiceEndpointResourceId);
135+
VerifyToken(checkKVToken, kvToken, userId, tenant);
136+
}
137+
138+
void VerifyToken(IAccessToken checkToken, string expectedAccessToken, string expectedUserId, string expectedTenant)
139+
{
140+
141+
Assert.True(checkToken is RawAccessToken);
142+
Assert.Equal(expectedAccessToken, checkToken.AccessToken);
143+
Assert.Equal(expectedUserId, checkToken.UserId);
144+
Assert.Equal(expectedTenant, checkToken.TenantId);
145+
checkToken.AuthorizeRequest((type, token) =>
146+
{
147+
Assert.Equal(expectedAccessToken, token);
148+
Assert.Equal("Bearer", type);
149+
});
150+
}
151+
101152
}
102153
}

src/Common/Commands.Common.Authentication.Test/Commands.Common.Authentication.Test.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<Import Project="..\..\..\packages\xunit.runner.visualstudio.2.1.0\build\net20\xunit.runner.visualstudio.props" Condition="Exists('..\..\..\packages\xunit.runner.visualstudio.2.1.0\build\net20\xunit.runner.visualstudio.props')" />
4-
<Import Project="..\..\..\packages\xunit.core.2.1.0\build\portable-net45+win8+wp8+wpa81\xunit.core.props" Condition="Exists('..\..\..\packages\xunit.core.2.1.0\build\portable-net45+win8+wp8+wpa81\xunit.core.props')" />
3+
<Import Project="..\..\packages\xunit.runner.visualstudio.2.1.0\build\net20\xunit.runner.visualstudio.props" Condition="Exists('..\..\packages\xunit.runner.visualstudio.2.1.0\build\net20\xunit.runner.visualstudio.props')" />
4+
<Import Project="..\..\packages\xunit.core.2.1.0\build\portable-net45+win8+wp8+wpa81\xunit.core.props" Condition="Exists('..\..\packages\xunit.core.2.1.0\build\portable-net45+win8+wp8+wpa81\xunit.core.props')" />
55
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
66
<PropertyGroup>
77
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>

src/Common/Commands.Common.Authentication.Test/packages.config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@
2020
<package id="xunit.core" version="2.1.0" targetFramework="net45" />
2121
<package id="xunit.extensibility.core" version="2.1.0" targetFramework="net45" />
2222
<package id="xunit.extensibility.execution" version="2.1.0" targetFramework="net45" />
23-
<package id="xunit.runner.visualstudio" version="2.1.0" targetFramework="net45" />
24-
</packages>
23+
<package id="xunit.runner.visualstudio" version="2.1.0" targetFramework="net45" developmentDependency="true" />
24+
</packages>

src/ResourceManager/Common/Commands.Common.Strategies/IReportProgress.cs renamed to src/Common/Commands.Common.Authentication/Authentication/RawAccessToken.cs

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,35 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
namespace Microsoft.Azure.Commands.Common.Strategies
15+
using System;
16+
17+
namespace Microsoft.Azure.Commands.Common.Authentication
1618
{
17-
public interface IProgressReport
19+
public class RawAccessToken : IAccessToken
1820
{
19-
void Start<TModel>(ResourceConfig<TModel> config)
20-
where TModel : class;
21+
public string AccessToken
22+
{
23+
get; set;
24+
}
25+
26+
public string LoginType
27+
{
28+
get; set;
29+
}
30+
31+
public string TenantId
32+
{
33+
get; set;
34+
}
35+
36+
public string UserId
37+
{
38+
get; set;
39+
}
2140

22-
void Done<TModel>(ResourceConfig<TModel> config, double progress)
23-
where TModel : class;
41+
public void AuthorizeRequest(Action<string, string> authTokenSetter)
42+
{
43+
authTokenSetter("Bearer", AccessToken);
44+
}
2445
}
2546
}

src/Common/Commands.Common.Authentication/Commands.Common.Authentication.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@
133133
<Compile Include="Authentication\ITokenProvider.cs" />
134134
<Compile Include="Authentication\KeyStoreApplicationCredentialProvider.cs" />
135135
<Compile Include="Authentication\ProtectedFileTokenCache.cs" />
136+
<Compile Include="Authentication\RawAccessToken.cs" />
136137
<Compile Include="Authentication\ServicePrincipalKeyStore.cs" />
137138
<Compile Include="Authentication\ServicePrincipalTokenProvider.cs" />
138139
<Compile Include="Authentication\UserTokenProvider.cs" />

src/Common/Commands.Common.Authentication/Factories/AuthenticationFactory.cs

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,42 @@ public IAccessToken Authenticate(
6262
configuration.ClientRedirectUri,
6363
configuration.ResourceClientUri,
6464
configuration.ValidateAuthority);
65-
if (account.IsPropertySet(AzureAccount.Property.CertificateThumbprint))
65+
if (account != null && environment != null
66+
&& account.Type == AzureAccount.AccountType.AccessToken)
67+
{
68+
var rawToken = new RawAccessToken
69+
{
70+
TenantId = tenant,
71+
UserId = account.Id,
72+
LoginType = AzureAccount.AccountType.AccessToken
73+
};
74+
75+
if ((string.Equals(resourceId, environment.AzureKeyVaultServiceEndpointResourceId, StringComparison.OrdinalIgnoreCase)
76+
|| string.Equals(AzureEnvironment.Endpoint.AzureKeyVaultServiceEndpointResourceId, resourceId, StringComparison.OrdinalIgnoreCase))
77+
&& account.IsPropertySet(AzureAccount.Property.KeyVaultAccessToken))
78+
{
79+
rawToken.AccessToken = account.GetProperty(AzureAccount.Property.KeyVaultAccessToken);
80+
}
81+
else if ((string.Equals(resourceId, environment.GraphEndpointResourceId, StringComparison.OrdinalIgnoreCase)
82+
|| string.Equals(AzureEnvironment.Endpoint.GraphEndpointResourceId, resourceId, StringComparison.OrdinalIgnoreCase))
83+
&& account.IsPropertySet(AzureAccount.Property.GraphAccessToken))
84+
{
85+
rawToken.AccessToken = account.GetProperty(AzureAccount.Property.GraphAccessToken);
86+
}
87+
else if ((string.Equals(resourceId, environment.ActiveDirectoryServiceEndpointResourceId, StringComparison.OrdinalIgnoreCase)
88+
|| string.Equals(AzureEnvironment.Endpoint.ActiveDirectoryServiceEndpointResourceId, resourceId, StringComparison.OrdinalIgnoreCase))
89+
&& account.IsPropertySet(AzureAccount.Property.AccessToken))
90+
{
91+
rawToken.AccessToken = account.GetAccessToken();
92+
}
93+
else
94+
{
95+
throw new InvalidOperationException(string.Format(Resources.AccessTokenResourceNotFound, resourceId));
96+
}
97+
98+
token = rawToken;
99+
}
100+
else if (account.IsPropertySet(AzureAccount.Property.CertificateThumbprint))
66101
{
67102
var thumbprint = account.GetProperty(AzureAccount.Property.CertificateThumbprint);
68103
#if !NETSTANDARD
@@ -325,7 +360,7 @@ private AdalConfiguration GetAdalConfiguration(IAzureEnvironment environment, st
325360
string.Format("No Active Directory endpoint specified for environment '{0}'", environment.Name));
326361
}
327362

328-
var audience = environment.GetEndpoint(resourceId);
363+
var audience = environment.GetEndpoint(resourceId)?? resourceId;
329364
if (string.IsNullOrWhiteSpace(audience))
330365
{
331366
string message = Resources.InvalidManagementTokenAudience;

src/Common/Commands.Common.Authentication/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.Common.Authentication/Properties/Resources.resx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,4 +310,8 @@
310310
<value>[Common.Authentication]: Parsed token '{0}' with json value '{1}' and decoded issuer '{2}'.</value>
311311
<comment>0 = raw token; 1 = decoded token; 2 = issuer</comment>
312312
</data>
313+
<data name="AccessTokenResourceNotFound" xml:space="preserve">
314+
<value>Cannot retrieve access token for resource '{0}'. Please ensure that you have provided the appropriate access tokens when using access token login.</value>
315+
<comment>{0} = authentication resource id</comment>
316+
</data>
313317
</root>

src/Common/Commands.ScenarioTests.Common/packages.config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@
2121
<package id="xunit.core" version="2.1.0" targetFramework="net45" />
2222
<package id="xunit.extensibility.core" version="2.1.0" targetFramework="net45" />
2323
<package id="xunit.extensibility.execution" version="2.1.0" targetFramework="net45" />
24-
<package id="xunit.runner.visualstudio" version="2.1.0" targetFramework="net45" />
25-
</packages>
24+
<package id="xunit.runner.visualstudio" version="2.1.0" targetFramework="net45" developmentDependency="true" />
25+
</packages>

src/ResourceManager/AnalysisServices/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Additional information about change #1
1919
-->
2020
## Current Release
21+
* Added ResourceGroup Completer to -ResourceGroup parameters allowing tab completion through resource groups in current subscription
2122

2223
## Version 0.6.1
2324
* Remove validate set of location into dynamic lookup so that all clouds are supported.

src/ResourceManager/ApiManagement/ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
- Additional information about change #1
1919
-->
2020
## Current Release
21+
* Added Location Completer to -Location parameters allowing tab completion through valid Locations
22+
* Added ResourceGroup Completer to -ResourceGroup parameters allowing tab completion through resource groups in current subscription
2123

2224
## Version 5.0.1
2325
* Fixed assembly loading issue that caused some cmdlets to fail when executing

src/ResourceManager/ApplicationInsights/ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
- Additional information about change #1
1919
-->
2020
## Current Release
21+
* Added Location Completer to -Location parameters allowing tab completion through valid Locations
22+
* Added ResourceGroup Completer to -ResourceGroup parameters allowing tab completion through resource groups in current subscription
2123

2224
## Version 0.1.0
2325
* Add commands to get/create/remove applicaiton insights resource

src/ResourceManager/ApplicationInsights/Commands.ApplicationInsights/ApplicationInsights/ApplicationInsightsBaseCmdlet.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,11 @@ public IApplicationInsightsManagementClient AppInsightsManagementClient
9999
{
100100
if (appInsightsManagementClientWrapper == null)
101101
{
102-
appInsightsManagementClientWrapper = new ApplicationInsightsManagementClientWrapper(DefaultProfile.DefaultContext)
103-
{
104-
VerboseLogger = WriteVerboseWithTimestamp,
105-
ErrorLogger = WriteErrorWithTimestamp
106-
};
102+
appInsightsManagementClientWrapper = new ApplicationInsightsManagementClientWrapper(DefaultProfile.DefaultContext);
107103
}
108104

105+
this.appInsightsManagementClientWrapper.VerboseLogger = WriteVerboseWithTimestamp;
106+
this.appInsightsManagementClientWrapper.ErrorLogger = WriteErrorWithTimestamp;
109107
return appInsightsManagementClientWrapper.appInsightsManagementClient;
110108
}
111109

src/ResourceManager/Automation/ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
- Additional information about change #1
1919
-->
2020
## Current Release
21+
* Added Location Completer to -Location parameters allowing tab completion through valid Locations
22+
* Added ResourceGroup Completer to -ResourceGroup parameters allowing tab completion through resource groups in current subscription
2123

2224
## Version 4.1.1
2325
* Update to Import-AzureRMAutomationRunbook

0 commit comments

Comments
 (0)