Skip to content
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

Auto rest #62

Merged
merged 53 commits into from
Jul 31, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
4e992b5
Added checks for playback mode for LRO timeouts
stankovski Jul 14, 2015
cb95d21
Updated test recordings
stankovski Jul 15, 2015
b906e7f
remove net40 solution configurations from auto rest based libraries
yugangw-msft Jul 17, 2015
f10e48f
Merge pull request #1261 from yugangw-msft/removeuseless
Jul 18, 2015
7285a28
Added x-ms-client-request-id
stankovski Jul 20, 2015
b5491d8
migrate to using profile 111 and regenerate library code
Jul 21, 2015
2e45ac9
Merge branch 'AutoRest' of https://github.com/WindowsAzure/azure-sdk-…
stankovski Jul 21, 2015
9c8ba4d
Merge pull request #1269 from yugangw-msft/111
stankovski Jul 21, 2015
2b35210
Merge branch 'AutoRest' of https://github.com/WindowsAzure/azure-sdk-…
stankovski Jul 21, 2015
3e89b6c
Merge pull request #1271 from stankovski/AutoRest
Jul 21, 2015
e4889ff
Added Azure ClientRuntime Test framework.
Jul 21, 2015
fcabd3c
Moving TestFramework to repo - work in progress
Jul 22, 2015
d9f347f
Fixed compute tests.
Jul 22, 2015
46b050e
Referenced latest ClientRuntime.Azure and fixed tests.
Jul 22, 2015
cbf957a
Regenerated clients with new AutoRest and removed stale files.
Jul 22, 2015
26af8df
Fixed TestFramework solution configuration
Jul 22, 2015
6b1a0fb
Fixed build breaks for portable versions.
Jul 22, 2015
0eafaa8
Fixed Microsoft.Rest.ClientRuntime.Azure.TestFramework package build.
Jul 22, 2015
33f9937
Fixed white space in nuget package project
Jul 22, 2015
bfedff7
Fixed TestFramework
Jul 22, 2015
e4a7c44
Fixed TestFramework Tenant and Domain fields
Jul 23, 2015
6e0ffaf
Merge pull request #1274 from hovsepm/AutoRest
Jul 23, 2015
12099dc
Fixed Resource tests.
Jul 23, 2015
61a6439
Merge pull request #1279 from hovsepm/AutoRest
Jul 23, 2015
2aaa5d7
Changed Authentication reference to Adal.
Jul 23, 2015
41869a1
Merge pull request #1285 from hovsepm/AutoRest
Jul 23, 2015
a5f01ba
Updated clients to the latest specs and code gen
stankovski Jul 24, 2015
2d7c5f5
Updated test framework and tests
stankovski Jul 24, 2015
634fb16
Updated test framework
stankovski Jul 24, 2015
a49101d
Updated ClientRuntime to latest version and fixed TestFramework.Tests
stankovski Jul 25, 2015
5ae82f1
Merge pull request #1290 from stankovski/AutoRest
stankovski Jul 25, 2015
43b06bf
Added creation of AutoRest ARM client in the ClientFactory
Jul 25, 2015
9f9f3e7
Merge branch 'AutoRest' of github.com:Azure/azure-sdk-for-net into Au…
Jul 25, 2015
a167e16
Merge pull request #1291 from hovsepm/AutoRest
Jul 25, 2015
d7d6d26
Fixed dependency for Authentication package.
Jul 27, 2015
7536c1d
Merge pull request #1297 from hovsepm/AutoRest
Jul 27, 2015
14985d4
Fixed NuGet.Config files and updated ResourceManagement swagger files
stankovski Jul 27, 2015
a0780a6
Fixed Compute test
stankovski Jul 27, 2015
11a8e76
add generate command file for storage library
yugangw-msft Jul 27, 2015
26bb070
Merge pull request #1299 from stankovski/AutoRest
stankovski Jul 27, 2015
dc33c76
add more clients to generate for resource
yugangw-msft Jul 27, 2015
871343b
merge with the latest AutoRest
yugangw-msft Jul 27, 2015
e1f22f1
regenerate lib
yugangw-msft Jul 27, 2015
8c843d3
Merge pull request #1301 from yugangw-msft/script
Jul 28, 2015
dc0bdbe
Updated to latest client runtime
stankovski Jul 29, 2015
f4451b6
Merge pull request #1308 from stankovski/AutoRest
stankovski Jul 29, 2015
dc4f9e0
Add .NET SDK for Logic App
tonytang-microsoft-com Jul 29, 2015
5caff49
Upgraded to latest Authentication package
stankovski Jul 29, 2015
6d57c16
Merge pull request #1311 from stankovski/AutoRest
stankovski Jul 29, 2015
033430d
Added generate.cmd
tonytang-microsoft-com Jul 29, 2015
f3f2c73
Merge pull request #1309 from tonytang-microsoft-com/AutoRest
stankovski Jul 29, 2015
89f39ae
update code-gen script and produce mit license header
yugangw-msft Jul 30, 2015
9cbc15a
Merge pull request #1318 from yugangw-msft/mit
amarzavery Jul 30, 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
  •  
  •  
  •  
35 changes: 25 additions & 10 deletions build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,16 @@
Exclude="$(LibrarySourceFolder)\HDInsight\**\*.sln;$(LibrarySourceFolder)\KeyVault\**\*.sln"
Condition=" '$(Scope)' == 'all' " />
<LibraryFxTargetList Include="$(FxTargetList)" />
<AutoRestLibraryFxTargetList Include="portable;net45" />
</ItemGroup>

<PropertyGroup>
<NuGetCommand>&quot;$(LibraryToolsFolder)\nuget.exe&quot;</NuGetCommand>
</PropertyGroup>

<UsingTask AssemblyFile="$(LibraryToolsFolder)\Microsoft.WindowsAzure.Build.Tasks.dll" TaskName="RegexReplacementTask" />
<UsingTask AssemblyFile="$(LibraryToolsFolder)\Microsoft.WindowsAzure.Build.Tasks.dll" TaskName="ValidateStrongNameSignatureTask" />

<UsingTask TaskName="ValidateStrongNameSignatureTask" AssemblyFile="$(LibraryToolsFolder)\Microsoft.WindowsAzure.Build.Tasks.dll" />
<UsingTask TaskName="FilterOutAutoRestLibraries" AssemblyFile="$(LibraryToolsFolder)\Microsoft.WindowsAzure.Build.Tasks.dll" />
<!--
CI build related
-->
Expand All @@ -91,27 +92,41 @@
<UsingTask Condition=" $(OnPremiseBuild) " TaskName="CorporateValidation" AssemblyFile="$(CIToolsPath)\Microsoft.WindowsAzure.Tools.Build.Tasks.OnPremise.dll" />
<Import Condition=" $(OnPremiseBuild) " Project="$(CIToolsPath)\Microsoft.WindowsAzure.Build.OnPremise.msbuild" />

<Target Name="Build" DependsOnTargets="RestoreNugetPackages">
<Target Name="PrepareForAutoRestLibraries">
<FilterOutAutoRestLibraries AllLibraries="@(LibrariesToBuild)" AutoRestMark="AutoRestProjects">
<Output TaskParameter="AutoRestLibraries" ItemName="AutoRestLibraries" />
<Output TaskParameter="NonAutoRestLibraries" ItemName="NonAutoRestLibraries" />
</FilterOutAutoRestLibraries>
</Target>

<Target Name="Build" DependsOnTargets="RestoreNugetPackages;BuildMsBuildTask;PrepareForAutoRestLibraries">
<PropertyGroup>
<_ExtraPropertyList>CodeSign=$(CodeSign)</_ExtraPropertyList>
</PropertyGroup>
<CallTarget Targets="BuildMsBuildTask" />
<CallTarget Targets="BuildServerPreparation" Condition=" '$(CodeSign)' == 'true' " />

<!--The solution contains configurations for each platform such as Net40-Debug, Net45-Release, etc
So when invoke msbuild, feed the right configuration name-->
<MSBuild Projects="@(LibrariesToBuild)"
<MSBuild Projects="@(NonAutoRestLibraries)"
Properties="Configuration=%(LibraryFxTargetList.Identity)-$(Configuration);Platform=Any CPU;$(_ExtraPropertyList)"
Targets="Build" />

<MSBuild Projects="@(AutoRestLibraries)"
Properties="Configuration=%(AutoRestLibraryFxTargetList.Identity)-$(Configuration);Platform=Any CPU;$(_ExtraPropertyList)"
Targets="Build" />

<CallTarget Targets="CodeSignBinaries" Condition=" '$(CodeSign)' == 'true' " />

</Target>

<Target Name="Clean" DependsOnTargets="RestoreNugetPackages">
<MSBuild Projects="@(LibrariesToBuild)"
<Target Name="Clean" DependsOnTargets="RestoreNugetPackages;BuildMsBuildTask;PrepareForAutoRestLibraries">
<MSBuild Projects="@(NonAutoRestLibraries)"
Properties="Configuration=%(LibraryFxTargetList.Identity)-$(Configuration);Platform=Any CPU"
Targets="Clean"/>
Targets="Clean" />

<MSBuild Projects="@(AutoRestLibraries)"
Properties="Configuration=%(AutoRestLibraryFxTargetList.Identity)-$(Configuration);Platform=Any CPU;$(_ExtraPropertyList)"
Targets="Clean" />
<RemoveDir Directories="$(BinariesFolder)" />
</Target>

Expand All @@ -122,7 +137,7 @@
<TestPartialName>$([System.IO.Path]::GetFileName($(Scope)))</TestPartialName>
</PropertyGroup>
<ItemGroup>
<!--TODO: improve inclue the logic to be more explicit -->
<!--TODO: improve the logic to be more explicit -->
<TestDlls Include=".\src\**\*.Tests\bin\net45-$(Configuration)\*.Tests.dll" Condition=" '$(Scope)' == 'All' " />
<TestDlls Include=".\src\$(Scope)\*.Tests\bin\net45-$(Configuration)\*$(TestPartialName)*.Tests.dll"
Condition=" '$(Scope)' != 'All' " />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,21 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>$(LibraryNugetPackageFolder)\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.NetFramework.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory, Version=2.14.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(LibraryNugetPackageFolder)\Microsoft.IdentityModel.Clients.ActiveDirectory.2.14.201151115\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.dll</HintPath>
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.3.5.207081303-alpha\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms, Version=2.14.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(LibraryNugetPackageFolder)\Microsoft.IdentityModel.Clients.ActiveDirectory.2.14.201151115\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll</HintPath>
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory.Platform, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.3.5.207081303-alpha\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.Platform.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Rest.ClientRuntime, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.1.1.1\lib\net45\Microsoft.Rest.ClientRuntime.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Rest.ClientRuntime.Azure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.1.0.18-preview\lib\net45\Microsoft.Rest.ClientRuntime.Azure.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Management.Storage">
<HintPath>$(LibraryNugetPackageFolder)\Microsoft.WindowsAzure.Management.Storage.5.0.0\lib\net40\Microsoft.WindowsAzure.Management.Storage.dll</HintPath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,11 @@ public SubscriptionCloudCredentials GetSubscriptionCloudCredentials(AzureContext
{
return new CertificateCloudCredentials(context.Subscription.Id.ToString(), Certificate);
}


public Rest.ServiceClientCredentials GetServiceClientCredentials(AzureContext context)
{
throw new System.NotImplementedException();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,16 @@ public List<System.Net.Http.Headers.ProductInfoHeaderValue> UserAgents
throw new NotImplementedException();
}
}

public TClient CreateArmClient<TClient>(AzureContext context, AzureEnvironment.Endpoint endpoint) where TClient : Rest.ServiceClient<TClient>
{
var creds = AzureSession.AuthenticationFactory.GetServiceClientCredentials(context);
return CreateCustomArmClient<TClient>(creds, context.Environment.GetEndpointAsUri(endpoint));
}

public TClient CreateCustomArmClient<TClient>(params object[] parameters) where TClient : Rest.ServiceClient<TClient>
{
return ManagementClients.FirstOrDefault(o => o is TClient) as TClient;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using Microsoft.Azure;
using Microsoft.Azure.Common.Authentication;
using Microsoft.Azure.Common.Authentication.Models;
using Microsoft.Rest;
using System;
using System.Security;

Expand Down Expand Up @@ -68,5 +69,11 @@ public SubscriptionCloudCredentials GetSubscriptionCloudCredentials(AzureContext
{
return new AccessTokenCredential(context.Subscription.Id, Token);
}


public ServiceClientCredentials GetServiceClientCredentials(AzureContext context)
{
return new TokenCredentials(Token.AccessToken);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net45" />
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net45" />
<package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net45" />
<package id="Microsoft.IdentityModel.Clients.ActiveDirectory" version="2.14.201151115" targetFramework="net45" />
<package id="Microsoft.IdentityModel.Clients.ActiveDirectory" version="3.5.207081303-alpha" targetFramework="net45" />
<package id="Microsoft.Net.Http" version="2.2.22" targetFramework="net45" />
<package id="Microsoft.Rest.ClientRuntime" version="1.1.1" targetFramework="net45" />
<package id="Microsoft.Rest.ClientRuntime.Azure" version="1.0.18-preview" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Storage" version="5.0.0" targetFramework="net45" />
<package id="Moq" version="4.2.1409.1722" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net45" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class AdalConfiguration
// These constants define the default values to use for AD authentication
// against RDFE
//
private const string PowerShellClientId = "1950a258-227b-4e31-a9cf-717495945fc2";
public const string PowerShellClientId = "1950a258-227b-4e31-a9cf-717495945fc2";

public static readonly Uri PowerShellRedirectUri = new Uri("urn:ietf:wg:oauth:2.0:oob");

Expand All @@ -55,6 +55,7 @@ public AdalConfiguration()
ClientRedirectUri = PowerShellRedirectUri;
ValidateAuthority = true;
AdEndpoint = string.Empty;
ResourceClientUri = "https://management.core.windows.net/";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,19 @@ public static SecureString GetKey(string appId, string tenantId)
}
return null;
}
catch
{
// we could be running in an environment that does not have credentials store
}
finally
{
if (pCredential != IntPtr.Zero)
{
CredStore.NativeMethods.CredFree(pCredential);
}
}

return null;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using System;
using System.Collections.Generic;
using System.Security;
using System.Threading.Tasks;

namespace Microsoft.Azure.Common.Authentication
{
Expand All @@ -33,36 +34,41 @@ public IAccessToken GetAccessToken(AdalConfiguration config, ShowDialog promptBe
{
throw new ArgumentException(string.Format(Resources.InvalidCredentialType, "User"), "credentialType");
}
return new ServicePrincipalAccessToken(config, AcquireToken(config, userId, password), this, userId);
return new ServicePrincipalAccessToken(
config,
AcquireToken(config, userId, password).ConfigureAwait(false).GetAwaiter().GetResult(),
this,
userId);
}

private AuthenticationResult AcquireToken(AdalConfiguration config, string appId, SecureString appKey)
private async Task<AuthenticationResult> AcquireToken(AdalConfiguration config, string appId, SecureString appKey)
{
if (appKey == null)
{
return Renew(config, appId);
return await Renew(config, appId);
}

StoreAppKey(appId, config.AdDomain, appKey);

string authority = config.AdEndpoint + config.AdDomain;
var context = new AuthenticationContext(authority, config.ValidateAuthority,
AzureSession.TokenCache);
var credential = new ClientCredential(appId, appKey);
return context.AcquireToken("https://management.core.windows.net/", credential);
var credential = new ClientCredential(appId, UserTokenProvider.ConvertToString(appKey));
return await context.AcquireTokenAsync(config.ResourceClientUri, credential);
}

private AuthenticationResult Renew(AdalConfiguration config, string appId)
private async Task<AuthenticationResult> Renew(AdalConfiguration config, string appId)
{
TracingAdapter.Information(Resources.SPNRenewTokenTrace, appId, config.AdDomain, config.AdEndpoint,
config.ClientId, config.ClientRedirectUri);
using (SecureString appKey = LoadAppKey(appId, config.AdDomain))

using (SecureString appKey = LoadAppKey(appId, config.AdDomain))
{
if (appKey == null)
{
throw new KeyNotFoundException(string.Format(Resources.ServiceKeyNotFound, appId));
}
return AcquireToken(config, appId, appKey);
return await AcquireToken(config, appId, appKey);
}
}

Expand Down Expand Up @@ -96,7 +102,7 @@ public void AuthorizeRequest(Action<string, string> authTokenSetter)
{
if (IsExpired)
{
AuthResult = tokenProvider.Renew(Configuration, appId);
AuthResult = tokenProvider.Renew(Configuration, appId).ConfigureAwait(false).GetAwaiter().GetResult();
}

authTokenSetter(AuthResult.AccessTokenType, AuthResult.AccessToken);
Expand Down
Loading