Skip to content

Commit

Permalink
Merge pull request #32 from Azure/dev
Browse files Browse the repository at this point in the history
Merge dev into master
  • Loading branch information
dlstucki authored Feb 25, 2021
2 parents 73451d1 + b3d6ff7 commit 14ebb4e
Show file tree
Hide file tree
Showing 26 changed files with 415 additions and 175 deletions.
17 changes: 0 additions & 17 deletions .appveyor.yml

This file was deleted.

52 changes: 52 additions & 0 deletions .github/workflows/pr-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: azure-relay-aspnetserver

on: [push, pull_request]

jobs:
build-windows:
name: Build 'azure-relay-aspnetserver' on windows-latest

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'
- run: dotnet --info
- name: Restore
run: .\restore.cmd
- name: Build
run: .\build.cmd
- name: Package
run: .\package.cmd
build-nix:
strategy:
matrix:
platform: [ 'ubuntu-latest', 'macos-latest' ]
name: Build 'azure-relay-aspnetserver' on ${{ matrix.platform }}

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'
- run: dotnet --info
- name: Restore
run: ./restore.sh
- name: Build
run: ./build.sh
- name: Package
run: ./package.sh
2 changes: 1 addition & 1 deletion .pipelines/pipeline.user.windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ environment:
version:
name: 'DefaultVersion'
major: 1
minor: 2
minor: 3
system: 'RevisionCounter'
exclude_commit: true

Expand Down
30 changes: 0 additions & 30 deletions .travis.yml

This file was deleted.

6 changes: 3 additions & 3 deletions .version/PipelineAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

// This is a CDP xPlat pipeline generated file. Do not modify. This will be replaced with the actual versions in the actual Pipeline.
using System.Reflection;
[assembly: AssemblyVersion("1.2.0.0")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyInformationalVersion("1.2.0.0-dev-00000000")]
[assembly: AssemblyVersion("1.3.0.0")]
[assembly: AssemblyFileVersion("1.3.0.0")]
[assembly: AssemblyInformationalVersion("1.3.0.0-dev-00000000")]
1 change: 0 additions & 1 deletion NuGet.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<configuration>
<packageSources>
<clear />
<add key="dotnet-core" value="https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
ASP.NET Core Hosting for Azure Relay
=================

[![Build Status](https://travis-ci.org/Azure/azure-relay-aspnetserver.svg?branch=dev)](https://travis-ci.org/Azure/azure-relay-aspnetserver)
![](https://github.com/Azure/azure-relay-aspnetserver/workflows/azure-relay-aspnetserver/badge.svg?branch=dev)

This repo contains a web server for ASP.NET Core based on Azure Relay Hybrid Connections HTTP. A NuGet package produced from this repo is available on NuGet as ["Microsoft.Azure.Relay.AspNetCore"](https://www.nuget.org/packages/Microsoft.Azure.Relay.AspNetCore).
This repo contains a web server for ASP.NET Core based on Azure Relay Hybrid Connections HTTP. A NuGet package produced from this repo is available on NuGet as [Microsoft.Azure.Relay.AspNetCore](https://www.nuget.org/packages/Microsoft.Azure.Relay.AspNetCore).

The integration supports most ASP.NET scenarios, with a few exceptions. WebSocket support will
be added in the near future, for instance.

To use the extension, take the following steps:

1. Add the Microsoft.Azure.Relay.AspNetCore assembly to your project. The assembly must be built from
this sampe repo at the moment. An "official" Nuget package will be available in a little while.
1. Add the [Microsoft.Azure.Relay.AspNetCore](https://www.nuget.org/packages/Microsoft.Azure.Relay.AspNetCore) assembly to your project.
2. [Create a Hybrid Connection](https://docs.microsoft.com/en-us/azure/service-bus-relay/relay-hybrid-connections-http-requests-dotnet-get-started)
3. After you have created the Hybrid Connection, find its "Shared Access Policies" portal tab and
add a new rule "listen" with the Listen-permission checked.
Expand Down
19 changes: 17 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,21 @@ while [[ -h $source ]]; do
# symlink file was located
[[ $source != /* ]] && source="$scriptroot/$source"
done

scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
"$scriptroot/eng/common/build.sh" --build --restore $@

if [ ${TF_BUILD}="True" ]; then
BuildConfiguration="Release"
else
BuildConfiguration="Debug"
fi

echo "dotnet build '${scriptroot}/AzureRelayServer.sln' --configuration ${BuildConfiguration}"
dotnet build "${scriptroot}/AzureRelayServer.sln" --configuration ${BuildConfiguration}

if [ $? -eq 0 ]
then
exit 0
else
echo "Error during running dotnet build" >&2
exit 1
fi
5 changes: 1 addition & 4 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
{
"sdk": {
"version": "3.0"
}
}
}
2 changes: 1 addition & 1 deletion package.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
PUSHD "%~dp0"

rem CDP_PACKAGE_VERSION_SEMANTIC set by internal
if not defined CDP_PACKAGE_VERSION_SEMANTIC set CDP_PACKAGE_VERSION_SEMANTIC=1.0.0.0-dev
if not defined CDP_PACKAGE_VERSION_SEMANTIC set CDP_PACKAGE_VERSION_SEMANTIC=1.3.0.0-dev

if defined TF_BUILD (
set BuildConfiguration=Release
Expand Down
31 changes: 31 additions & 0 deletions package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash

source="${BASH_SOURCE[0]}"

# resolve $SOURCE until the file is no longer a symlink
while [[ -h $source ]]; do
scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
source="$(readlink "$source")"

# if $source was a relative symlink, we need to resolve it relative to the path where the
# symlink file was located
[[ $source != /* ]] && source="$scriptroot/$source"
done
scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"

if [ ${TF_BUILD}="True" ]; then
BuildConfiguration="Release"
else
BuildConfiguration="Debug"
fi

echo "dotnet pack '${scriptroot}/AzureRelayServer.sln' --no-build --no-dependencies --no-restore /p:Version=${CDP_PACKAGE_VERSION_SEMANTIC:-1.0.0.0-dev} --configuration ${BuildConfiguration}"
dotnet pack "${scriptroot}/AzureRelayServer.sln" --no-build --no-dependencies --no-restore /p:Version=${CDP_PACKAGE_VERSION_SEMANTIC:-1.0.0.0-dev} --configuration ${BuildConfiguration}

if [ $? -eq 0 ]
then
exit 0
else
echo "Error during running dotnet build" >&2
exit 1
fi
25 changes: 25 additions & 0 deletions restore.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

source="${BASH_SOURCE[0]}"

# resolve $SOURCE until the file is no longer a symlink
while [[ -h $source ]]; do
scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
source="$(readlink "$source")"

# if $source was a relative symlink, we need to resolve it relative to the path where the
# symlink file was located
[[ $source != /* ]] && source="$scriptroot/$source"
done
scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"

echo "dotnet restore '${scriptroot}/AzureRelayServer.sln'"
dotnet restore "${scriptroot}/AzureRelayServer.sln"

if [ $? -eq 0 ]
then
exit 0
else
echo "Error during running dotnet restore" >&2
exit 1
fi
6 changes: 1 addition & 5 deletions samples/SelfHostServer/SelfHostServer.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.0;netcoreapp2.1</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;netcoreapp2.1</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net461</TargetFrameworks>
<OutputType>Exe</OutputType>
<ServerGarbageCollection>true</ServerGarbageCollection>
</PropertyGroup>

<ItemGroup>
<None Remove="Properties\launchSettings.json" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Microsoft.Azure.Relay.AspNetCore\Microsoft.Azure.Relay.AspNetCore.csproj" />
Expand Down
13 changes: 9 additions & 4 deletions src/Microsoft.Azure.Relay.AspNetCore/AzureRelayListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public AzureRelayListener(AzureRelayOptions options, ILoggerFactory loggerFactor

Logger = LogHelper.CreateLogger(loggerFactory, typeof(AzureRelayListener));
}

Task<bool> WebSocketAcceptHandler(RelayedHttpListenerContext arg)
{
return Task<bool>.FromResult(true);
Expand Down Expand Up @@ -78,7 +78,7 @@ internal enum State
public bool IsListening
{
get { return _state == State.Started; }
}
}

/// <summary>
/// Start accepting incoming requests.
Expand Down Expand Up @@ -109,12 +109,17 @@ public void Start()
var rcb = new RelayConnectionStringBuilder();

var tokenProvider = urlPrefix.TokenProvider != null ? urlPrefix.TokenProvider : Options.TokenProvider;
if ( tokenProvider == null )
if (tokenProvider == null)
{
throw new InvalidOperationException("No relay token provider defined.");
}
var relayListener = new HybridConnectionListener(
new UriBuilder(urlPrefix.FullPrefix) { Scheme = "sb", Port = -1 }.Uri, tokenProvider );
new UriBuilder(urlPrefix.FullPrefix) { Scheme = "sb", Port = -1 }.Uri, tokenProvider);

if (Options.UseCustomProxy)
{
relayListener.Proxy = Options.Proxy;
}

relayListener.RequestHandler = (ctx) => requestHandler(new RequestContext(ctx, new Uri(urlPrefix.FullPrefix)));
// TODO: CR: An accept handler which simply returns true is the same as no handler at all.
Expand Down
19 changes: 17 additions & 2 deletions src/Microsoft.Azure.Relay.AspNetCore/AzureRelayOptions.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Net;

namespace Microsoft.Azure.Relay.AspNetCore
{
public class AzureRelayOptions
{
private IWebProxy proxy;

public AzureRelayOptions()
{
}
Expand All @@ -15,12 +18,24 @@ public AzureRelayOptions()

public UrlPrefixCollection UrlPrefixes { get; } = new UrlPrefixCollection();

public IWebProxy Proxy
{
get { return proxy; }
set
{
UseCustomProxy = true;
proxy = value;
}
}

public bool UseCustomProxy { get; set; }

internal bool ThrowWriteExceptions { get; set; }

internal long MaxRequestBodySize { get; set; }

internal int RequestQueueLimit { get; set; }

internal int? MaxConnections { get; set; }
internal int? MaxConnections { get; set; }
}
}
31 changes: 31 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash

source="${BASH_SOURCE[0]}"

# resolve $SOURCE until the file is no longer a symlink
while [[ -h $source ]]; do
scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
source="$(readlink "$source")"

# if $source was a relative symlink, we need to resolve it relative to the path where the
# symlink file was located
[[ $source != /* ]] && source="$scriptroot/$source"
done
scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"

if [ ${TF_BUILD}="True" ]; then
BuildConfiguration="Release"
else
BuildConfiguration="Debug"
fi

echo "dotnet test '${scriptroot}/AzureRelayServer.sln' --no-build --no-restore --blame --logger:trx --configuration ${BuildConfiguration}"
dotnet test "${scriptroot}/AzureRelayServer.sln" --no-build --no-restore --blame --logger:trx --configuration ${BuildConfiguration}

if [ $? -eq 0 ]
then
exit 0
else
echo "Error during running dotnet test" >&2
exit 1
fi
2 changes: 1 addition & 1 deletion test/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Import Project="..\Directory.Build.props" />

<PropertyGroup>
<DeveloperBuildTestTfms>netcoreapp2.1;netcoreapp3.0</DeveloperBuildTestTfms>
<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>
Expand Down
Loading

0 comments on commit 14ebb4e

Please sign in to comment.