Skip to content
Open
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
22 changes: 3 additions & 19 deletions .github/workflows/pr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,10 @@ jobs:
build-windows:
name: Build 'azure-relay-aspnetserver' on windows-latest

runs-on: 'windows-2019'
runs-on: 'windows-latest'

steps:
- uses: actions/checkout@v1
- name: Setup .NET Core 2.2
uses: actions/setup-dotnet@v1
with:
dotnet-version: '2.2.x'
- name: Setup .NET Core 3.1
uses: actions/setup-dotnet@v1
with:
dotnet-version: '3.1.x'
- uses: actions/checkout@v4
Copy link
Author

Choose a reason for hiding this comment

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

The base images have net8.0 already installed.

- run: dotnet --info
- name: Restore
run: .\restore.cmd
Expand All @@ -34,15 +26,7 @@ jobs:
runs-on: ${{ matrix.platform }}

steps:
- uses: actions/checkout@v1
- name: Setup .NET Core 2.2
uses: actions/setup-dotnet@v1
with:
dotnet-version: '2.2.x'
- name: Setup .NET Core 3.1
uses: actions/setup-dotnet@v1
with:
dotnet-version: '3.1.x'
- uses: actions/checkout@v4
- run: dotnet --info
- name: Restore
run: ./restore.sh
Expand Down
14 changes: 3 additions & 11 deletions AzureRelayServer.sln
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29503.13
# Visual Studio Version 17
VisualStudioVersion = 17.9.34511.98
MinimumVisualStudioVersion = 15.0.26730.03
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{99D5E5F3-88F5-4CCF-8D8C-717C8925DF09}"
ProjectSection(SolutionItems) = preProject
Expand All @@ -16,13 +16,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{3A1E
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{5E9B546C-17AC-4BDF-BCB3-5955D4755ED8}"
ProjectSection(SolutionItems) = preProject
.appveyor.yml = .appveyor.yml
.gitignore = .gitignore
.travis.yml = .travis.yml
build.cmd = build.cmd
build.sh = build.sh
Directory.Build.props = Directory.Build.props
Directory.Build.targets = Directory.Build.targets
Directory.Packages.props = Directory.Packages.props
NuGet.config = NuGet.config
README.md = README.md
EndProjectSection
Expand All @@ -33,12 +32,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Relay.AspNe
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Relay.AspNetCore", "src\Microsoft.Azure.Relay.AspNetCore\Microsoft.Azure.Relay.AspNetCore.csproj", "{B9F45F9D-D206-47F0-8E5F-54CE2F0BDF92}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{85914BA9-4168-48C5-9C3F-E2E8B1479A6E}"
ProjectSection(SolutionItems) = preProject
build\dependencies.props = build\dependencies.props
build\Key.snk = build\Key.snk
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MVCServerApp", "samples\MVCServerApp\MVCServerApp.csproj", "{E9ED2DA2-BFAF-4ABF-B045-63B787CA6CCE}"
EndProject
Global
Expand Down Expand Up @@ -101,7 +94,6 @@ Global
{1236F93A-AC5C-4A77-9477-C88F040151CA} = {3A1E31E3-2794-4CA3-B8E2-253E96BDE514}
{4492FF4C-9032-411D-853F-46B01755E504} = {E183C826-1360-4DFF-9994-F33CED5C8525}
{B9F45F9D-D206-47F0-8E5F-54CE2F0BDF92} = {99D5E5F3-88F5-4CCF-8D8C-717C8925DF09}
{85914BA9-4168-48C5-9C3F-E2E8B1479A6E} = {5E9B546C-17AC-4BDF-BCB3-5955D4755ED8}
{E9ED2DA2-BFAF-4ABF-B045-63B787CA6CCE} = {3A1E31E3-2794-4CA3-B8E2-253E96BDE514}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<PropertyGroup Label="Package Versions">
<MicrosoftAzureRelayPackageVersion>2.0.1</MicrosoftAzureRelayPackageVersion>
<MicrosoftAzureRelayPackageVersion>3.0.1</MicrosoftAzureRelayPackageVersion>
</PropertyGroup>

<PropertyGroup Label="Version">
Expand Down
22 changes: 22 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
Copy link
Author

Choose a reason for hiding this comment

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

Central package management such that version are store in a single place.

<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>

<ItemGroup>
<PackageVersion Include="Microsoft.Azure.Relay" Version="3.0.1" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
<PackageVersion Include="System.Threading.Tasks.Dataflow" Version="8.0.0" />

<!-- For netstandard2.0 only -->
<PackageVersion Include="Microsoft.AspNetCore.Authentication.Core" Version="2.2.0" />
<PackageVersion Include="Microsoft.AspNetCore.Hosting" Version="2.2.0" />
<PackageVersion Include="Microsoft.Net.Http.Headers" Version="2.2.0" />

<PackageVersion Include="xunit" Version="2.6.6" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.6" />

</ItemGroup>
</Project>
7 changes: 1 addition & 6 deletions samples/MVCServerApp/MVCServerApp.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App"/>
<PackageReference Include="Microsoft.Azure.Relay" Version="$(MicrosoftAzureRelayPackageVersion)" />
</ItemGroup>

<ItemGroup>
<!--DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.3" /-->
</ItemGroup>
Expand Down
18 changes: 5 additions & 13 deletions samples/MVCServerApp/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

namespace MVCServerApp
{
Expand All @@ -21,11 +18,11 @@ public Startup(IConfiguration configuration)
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddMvc(options => options.EnableEndpointRouting = false);
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
Expand All @@ -39,12 +36,7 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)

app.UseStaticFiles();

app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
app.UseMvcWithDefaultRoute();
}
}
}
6 changes: 2 additions & 4 deletions samples/SelfHostServer/SelfHostServer.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;netcoreapp2.1</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net461</TargetFrameworks>
<TargetFrameworks>net6.0</TargetFrameworks>
<OutputType>Exe</OutputType>
<ServerGarbageCollection>true</ServerGarbageCollection>
</PropertyGroup>
Expand All @@ -12,8 +11,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Relay" Version="$(MicrosoftAzureRelayPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" />
</ItemGroup>

</Project>
1 change: 1 addition & 0 deletions src/Microsoft.Azure.Relay.AspNetCore/AzureRelayListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Threading.Tasks;
using System.Threading.Tasks.Dataflow;
using Microsoft.Extensions.Logging;
using Microsoft.Azure.Relay;

namespace Microsoft.Azure.Relay.AspNetCore
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<PropertyGroup>
<Description>ASP.NET Core HTTP server that uses Azure Relay.</Description>
<Authors>Microsoft</Authors>
<copyright>&#169; Microsoft Corporation. All rights reserved.</copyright>
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
<copyright>© Microsoft Corporation. All rights reserved.</copyright>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand All @@ -14,25 +14,23 @@
<PackageIconUrl>https://raw.githubusercontent.com/Azure/azure-relay-dotnet/master/relay.png</PackageIconUrl>
<PackageProjectUrl>https://github.com/Azure/azure-relay-aspnetserver</PackageProjectUrl>
<IsPackable>True</IsPackable>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.1' ">
<PackageReference Include="Microsoft.AspNetCore.Http.Features" Version="3.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Core" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.2.7" />
<PackageReference Include="Microsoft.AspNetCore.Http.Features" Version="3.0.0" />
<PackageReference Include="Microsoft.Net.Http.Headers" Version="2.2.0" />
<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
<FrameworkReference Include="Microsoft.AspNetCore.App" />
Copy link
Author

Choose a reason for hiding this comment

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

These packages are not published anymore (most). Referencing the shared framework is the way to go.

</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' != 'netstandard2.1' ">
<PackageReference Include="Microsoft.AspNetCore.Authentication.Core" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.1.1" />
<PackageReference Include="Microsoft.Net.Http.Headers" Version="2.1.1" />
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="Microsoft.AspNetCore.Authentication.Core" />
<PackageReference Include="Microsoft.AspNetCore.Hosting" />
<PackageReference Include="Microsoft.Net.Http.Headers" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.Threading.Tasks.Dataflow" Version="4.10.0" />
<PackageReference Include="Microsoft.Azure.Relay" Version="$(MicrosoftAzureRelayPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" />
<PackageReference Include="System.Threading.Tasks.Dataflow" />
<PackageReference Include="Microsoft.Azure.Relay" />
</ItemGroup>

</Project>
11 changes: 2 additions & 9 deletions test/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
<Project>
<Import Project="..\Directory.Build.props" />

<PropertyGroup>
<DeveloperBuildTestTfms>netcoreapp2.1;netcoreapp3.1</DeveloperBuildTestTfms>
<StandardTestTfms>$(DeveloperBuildTestTfms)</StandardTestTfms>
<StandardTestTfms Condition=" '$(DeveloperBuild)' != 'true' ">$(StandardTestTfms)</StandardTestTfms>
<StandardTestTfms Condition=" '$(DeveloperBuild)' != 'true' AND '$(OS)' == 'Windows_NT' ">$(StandardTestTfms);net461</StandardTestTfms>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.visualstudio" />
</ItemGroup>
</Project>
36 changes: 21 additions & 15 deletions test/Microsoft.Azure.Relay.AspNetCore.FunctionalTests/HttpsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public async Task Https_200OK_Success()
{
using (Utilities.CreateHttpsServer(httpContext =>
{
return Task.FromResult(0);
return Task.CompletedTask;
}))
{
string response = await SendRequestAsync(Address);
Expand Down Expand Up @@ -61,7 +61,7 @@ public async Task Https_EchoHelloWorld_Success()
byte[] body = Encoding.UTF8.GetBytes("Hello World");
httpContext.Response.ContentLength = body.Length;
httpContext.Response.Body.Write(body, 0, body.Length);
return Task.FromResult(0);
return Task.CompletedTask;
}))
{
string response = await SendRequestAsync(Address, "Hello World");
Expand Down Expand Up @@ -108,28 +108,34 @@ public async Task Https_ClientCertRequested_ClientCertPresent()
private async Task<string> SendRequestAsync(string uri,
X509Certificate cert = null)
{
var handler = new WinHttpHandler();
handler.ServerCertificateValidationCallback = (a, b, c, d) => true;
var handler = new HttpClientHandler
{
ClientCertificateOptions = ClientCertificateOption.Manual,
ServerCertificateCustomValidationCallback = (httpRequestMessage, cert, cetChain, policyErrors) => true
};

if (cert != null)
{
handler.ClientCertificates.Add(cert);
}
using (HttpClient client = new HttpClient(handler))
{
return await client.GetStringAsync(uri);
}

using HttpClient client = new HttpClient(handler);
return await client.GetStringAsync(uri);
}

private async Task<string> SendRequestAsync(string uri, string upload)
{
var handler = new WinHttpHandler();
handler.ServerCertificateValidationCallback = (a, b, c, d) => true;
using (HttpClient client = new HttpClient(handler))
var handler = new HttpClientHandler
{
HttpResponseMessage response = await client.PostAsync(uri, new StringContent(upload));
response.EnsureSuccessStatusCode();
return await response.Content.ReadAsStringAsync();
}
ClientCertificateOptions = ClientCertificateOption.Manual,
ServerCertificateCustomValidationCallback = (httpRequestMessage, cert, cetChain, policyErrors) => true
};

using HttpClient client = new HttpClient(handler);

HttpResponseMessage response = await client.PostAsync(uri, new StringContent(upload));
response.EnsureSuccessStatusCode();
return await response.Content.ReadAsStringAsync();
}

private X509Certificate2 FindClientCert()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.Json;
Copy link
Author

Choose a reason for hiding this comment

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

Removed NewtonSoft.Json dependency.


namespace Microsoft.Azure.Relay.AspNetCore
{
Expand All @@ -15,23 +12,21 @@ public LaunchSettingsFixture()
string filename = "Properties\\launchSettings.json";
if (File.Exists(filename))
{
using (var file = File.OpenText(filename))
using (var file = File.Open(filename, FileMode.Open))
{
var reader = new JsonTextReader(file);
var jObject = JObject.Load(reader);
var json = JsonDocument.Parse(file).RootElement;

var variables = jObject
.GetValue("profiles")
var variables = json.
GetProperty("profiles").EnumerateObject()
//select a proper profile here
.SelectMany(profiles => profiles.Children())
.SelectMany(profile => profile.Children<JProperty>())
.SelectMany(profile => profile.Value.EnumerateObject())
.Where(prop => prop.Name == "environmentVariables")
.SelectMany(prop => prop.Value.Children<JProperty>())
.SelectMany(prop => prop.Value.EnumerateObject())
.ToList();

foreach (var variable in variables)
{
Environment.SetEnvironmentVariable(variable.Name, variable.Value.ToString());
Environment.SetEnvironmentVariable(variable.Name, variable.Value.GetString());
}
}
}
Expand Down
Loading