diff --git a/AzureIntegration.sln b/AzureIntegration.sln index e45defbc4c..b2fc8fd520 100644 --- a/AzureIntegration.sln +++ b/AzureIntegration.sln @@ -1,8 +1,8 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26208.0 +VisualStudioVersion = 15.0.26323.1 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNetCore.AzureAppServicesIntegration", "src\Microsoft.AspNetCore.AzureAppServicesIntegration\Microsoft.AspNetCore.AzureAppServicesIntegration.csproj", "{5916BEB5-0969-469B-976C-A392E015DFAC}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.AzureAppServicesIntegration", "src\Microsoft.AspNetCore.AzureAppServicesIntegration\Microsoft.AspNetCore.AzureAppServicesIntegration.csproj", "{5916BEB5-0969-469B-976C-A392E015DFAC}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{FF9B744E-6C59-40CC-9E41-9D2EBD292435}" EndProject @@ -11,13 +11,17 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution NuGet.config = NuGet.config EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AzureAppServicesSample", "sample\AzureAppServicesSample\AzureAppServicesSample.csproj", "{05A4D308-B162-4194-BC5E-88CCB4DBD318}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AzureAppServicesSample", "sample\AzureAppServicesSample\AzureAppServicesSample.csproj", "{05A4D308-B162-4194-BC5E-88CCB4DBD318}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{37237C93-6855-40D9-9E60-418B093EF49A}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{CD650B4B-81C2-4A44-AEF2-A251A877C1F0}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNetCore.AzureAppServicesIntegration.Tests", "test\Microsoft.AspNetCore.AzureAppServicesIntegration.Tests\Microsoft.AspNetCore.AzureAppServicesIntegration.Tests.csproj", "{9BA1B692-B313-4E22-A864-F0ADBBE3C3FA}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.AzureAppServicesIntegration.Tests", "test\Microsoft.AspNetCore.AzureAppServicesIntegration.Tests\Microsoft.AspNetCore.AzureAppServicesIntegration.Tests.csproj", "{9BA1B692-B313-4E22-A864-F0ADBBE3C3FA}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.AzureLightup", "src\Microsoft.AspNetCore.AzureLightup\Microsoft.AspNetCore.AzureLightup.csproj", "{AC023B45-7995-4D4A-8108-E512AE8E5734}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AzureAppServicesLightupSample", "sample\AzureAppServicesLightupSample\AzureAppServicesLightupSample.csproj", "{939EA897-CA31-4F2E-BA51-22B570B64671}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -37,6 +41,14 @@ Global {9BA1B692-B313-4E22-A864-F0ADBBE3C3FA}.Debug|Any CPU.Build.0 = Debug|Any CPU {9BA1B692-B313-4E22-A864-F0ADBBE3C3FA}.Release|Any CPU.ActiveCfg = Release|Any CPU {9BA1B692-B313-4E22-A864-F0ADBBE3C3FA}.Release|Any CPU.Build.0 = Release|Any CPU + {AC023B45-7995-4D4A-8108-E512AE8E5734}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AC023B45-7995-4D4A-8108-E512AE8E5734}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AC023B45-7995-4D4A-8108-E512AE8E5734}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AC023B45-7995-4D4A-8108-E512AE8E5734}.Release|Any CPU.Build.0 = Release|Any CPU + {939EA897-CA31-4F2E-BA51-22B570B64671}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {939EA897-CA31-4F2E-BA51-22B570B64671}.Debug|Any CPU.Build.0 = Debug|Any CPU + {939EA897-CA31-4F2E-BA51-22B570B64671}.Release|Any CPU.ActiveCfg = Release|Any CPU + {939EA897-CA31-4F2E-BA51-22B570B64671}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -45,5 +57,7 @@ Global {5916BEB5-0969-469B-976C-A392E015DFAC} = {FF9B744E-6C59-40CC-9E41-9D2EBD292435} {05A4D308-B162-4194-BC5E-88CCB4DBD318} = {37237C93-6855-40D9-9E60-418B093EF49A} {9BA1B692-B313-4E22-A864-F0ADBBE3C3FA} = {CD650B4B-81C2-4A44-AEF2-A251A877C1F0} + {AC023B45-7995-4D4A-8108-E512AE8E5734} = {FF9B744E-6C59-40CC-9E41-9D2EBD292435} + {939EA897-CA31-4F2E-BA51-22B570B64671} = {37237C93-6855-40D9-9E60-418B093EF49A} EndGlobalSection EndGlobal diff --git a/sample/AzureAppServicesLightupSample/AzureAppServicesLightupSample.csproj b/sample/AzureAppServicesLightupSample/AzureAppServicesLightupSample.csproj new file mode 100644 index 0000000000..1584e90ca4 --- /dev/null +++ b/sample/AzureAppServicesLightupSample/AzureAppServicesLightupSample.csproj @@ -0,0 +1,19 @@ + + + + + + net46;netcoreapp2.0 + $(PackageTargetFallback);portable-net40+sl5+win8+wp8+wpa81;portable-net45+win8+wp8+wpa81 + + + + + + + + + + + + diff --git a/sample/AzureAppServicesLightupSample/Properties/launchSettings.json b/sample/AzureAppServicesLightupSample/Properties/launchSettings.json new file mode 100644 index 0000000000..ea16a500b7 --- /dev/null +++ b/sample/AzureAppServicesLightupSample/Properties/launchSettings.json @@ -0,0 +1,24 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:22071/", + "sslPort": 0 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development", + "ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.AzureLightup;Microsoft.AspNetCore.Server.IISIntegration" + } + }, + "AzureAppServicesSample": { + "commandName": "IISExpress", + "launchBrowser": true + } + } +} \ No newline at end of file diff --git a/sample/AzureAppServicesLightupSample/Startup.cs b/sample/AzureAppServicesLightupSample/Startup.cs new file mode 100644 index 0000000000..cbb697e1e9 --- /dev/null +++ b/sample/AzureAppServicesLightupSample/Startup.cs @@ -0,0 +1,79 @@ +using System; +using System.Linq; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; + +namespace IISSample +{ + public class Startup + { + public void ConfigureServices(IServiceCollection services) + { + } + + public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) + { + loggerfactory.AddConsole(LogLevel.Debug); + + var logger = loggerfactory.CreateLogger("Requests"); + + app.Run(async (context) => + { + logger.LogDebug("Received request: " + context.Request.Method + " " + context.Request.Path); + + context.Response.ContentType = "text/plain"; + await context.Response.WriteAsync("Hello World - " + DateTimeOffset.Now + Environment.NewLine); + await context.Response.WriteAsync(Environment.NewLine); + + await context.Response.WriteAsync("Address:" + Environment.NewLine); + await context.Response.WriteAsync("Scheme: " + context.Request.Scheme + Environment.NewLine); + await context.Response.WriteAsync("Host: " + context.Request.Headers["Host"] + Environment.NewLine); + await context.Response.WriteAsync("PathBase: " + context.Request.PathBase.Value + Environment.NewLine); + await context.Response.WriteAsync("Path: " + context.Request.Path.Value + Environment.NewLine); + await context.Response.WriteAsync("Query: " + context.Request.QueryString.Value + Environment.NewLine); + await context.Response.WriteAsync(Environment.NewLine); + + await context.Response.WriteAsync("Connection:" + Environment.NewLine); + await context.Response.WriteAsync("RemoteIp: " + context.Connection.RemoteIpAddress + Environment.NewLine); + await context.Response.WriteAsync("RemotePort: " + context.Connection.RemotePort + Environment.NewLine); + await context.Response.WriteAsync("LocalIp: " + context.Connection.LocalIpAddress + Environment.NewLine); + await context.Response.WriteAsync("LocalPort: " + context.Connection.LocalPort + Environment.NewLine); + await context.Response.WriteAsync("ClientCert: " + context.Connection.ClientCertificate + Environment.NewLine); + await context.Response.WriteAsync(Environment.NewLine); + + await context.Response.WriteAsync("User: " + context.User.Identity.Name + Environment.NewLine); + await context.Response.WriteAsync(Environment.NewLine); + + await context.Response.WriteAsync("Headers:" + Environment.NewLine); + foreach (var header in context.Request.Headers) + { + await context.Response.WriteAsync(header.Key + ": " + header.Value + Environment.NewLine); + } + await context.Response.WriteAsync(Environment.NewLine); + + await context.Response.WriteAsync("Environment Variables:" + Environment.NewLine); + var vars = Environment.GetEnvironmentVariables(); + foreach (var key in vars.Keys.Cast().OrderBy(key => key, StringComparer.OrdinalIgnoreCase)) + { + var value = vars[key]; + await context.Response.WriteAsync(key + ": " + value + Environment.NewLine); + } + await context.Response.WriteAsync(Environment.NewLine); + }); + } + + public static void Main(string[] args) + { + var host = new WebHostBuilder() + .UseKestrel() + .UseStartup() + .Build(); + + host.Run(); + } + } +} + diff --git a/sample/AzureAppServicesSample/AzureAppServicesSample.csproj b/sample/AzureAppServicesSample/AzureAppServicesSample.csproj index 9ec0cf3b78..bbf8635e65 100644 --- a/sample/AzureAppServicesSample/AzureAppServicesSample.csproj +++ b/sample/AzureAppServicesSample/AzureAppServicesSample.csproj @@ -1,4 +1,4 @@ - + @@ -12,8 +12,7 @@ - - + diff --git a/sample/AzureAppServicesSample/Properties/launchSettings.json b/sample/AzureAppServicesSample/Properties/launchSettings.json new file mode 100644 index 0000000000..5ff7428dc8 --- /dev/null +++ b/sample/AzureAppServicesSample/Properties/launchSettings.json @@ -0,0 +1,24 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:22071/", + "sslPort": 0 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development", + "ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.Server.IISIntegration" + } + }, + "AzureAppServicesSample": { + "commandName": "IISExpress", + "launchBrowser": true + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.AzureAppServicesIntegration/AppServicesWebHostBuilderExtensions.cs b/src/Microsoft.AspNetCore.AzureAppServicesIntegration/AppServicesWebHostBuilderExtensions.cs index 33c4f2269d..a8687866ae 100644 --- a/src/Microsoft.AspNetCore.AzureAppServicesIntegration/AppServicesWebHostBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.AzureAppServicesIntegration/AppServicesWebHostBuilderExtensions.cs @@ -20,7 +20,6 @@ namespace Microsoft.AspNetCore.Hosting throw new ArgumentNullException(nameof(hostBuilder)); } - hostBuilder.UseIISIntegration(); hostBuilder.ConfigureLogging(loggerFactory => loggerFactory.AddAzureWebAppDiagnostics()); return hostBuilder; diff --git a/src/Microsoft.AspNetCore.AzureAppServicesIntegration/Microsoft.AspNetCore.AzureAppServicesIntegration.csproj b/src/Microsoft.AspNetCore.AzureAppServicesIntegration/Microsoft.AspNetCore.AzureAppServicesIntegration.csproj index 070bfaba43..f52f79de2a 100644 --- a/src/Microsoft.AspNetCore.AzureAppServicesIntegration/Microsoft.AspNetCore.AzureAppServicesIntegration.csproj +++ b/src/Microsoft.AspNetCore.AzureAppServicesIntegration/Microsoft.AspNetCore.AzureAppServicesIntegration.csproj @@ -14,7 +14,6 @@ - diff --git a/src/Microsoft.AspNetCore.AzureLightup/AzureStartupLoader.cs b/src/Microsoft.AspNetCore.AzureLightup/AzureStartupLoader.cs new file mode 100644 index 0000000000..0e6757e0fc --- /dev/null +++ b/src/Microsoft.AspNetCore.AzureLightup/AzureStartupLoader.cs @@ -0,0 +1,24 @@ +// 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 Microsoft.AspNetCore.Hosting; + +[assembly: HostingStartup(typeof(Microsoft.AspNetCore.AzureLightup.AzureStartupLoader))] + +namespace Microsoft.AspNetCore.AzureLightup +{ + /// + /// A dynamic azure lightup experiance + /// + public class AzureStartupLoader : IHostingStartup + { + /// + /// Calls UseAzureAppServices + /// + /// + public void Configure(IWebHostBuilder builder) + { + builder.UseAzureAppServices(); + } + } +} diff --git a/src/Microsoft.AspNetCore.AzureLightup/Microsoft.AspNetCore.AzureLightup.csproj b/src/Microsoft.AspNetCore.AzureLightup/Microsoft.AspNetCore.AzureLightup.csproj new file mode 100644 index 0000000000..4ea608c723 --- /dev/null +++ b/src/Microsoft.AspNetCore.AzureLightup/Microsoft.AspNetCore.AzureLightup.csproj @@ -0,0 +1,20 @@ + + + + + + ASP.NET Core lightup integration with Azure AppServices. + netstandard1.3 + true + aspnetcore;azure;appservices + + + + + + + + + + + \ No newline at end of file