none
ASP.NET Core site deployment from GitHub to App Service failing RRS feed

  • Question

  • Hi, I'm usually developing with Win10 and VS2015, but this time I'm trying out deploying a site with ASP.NET Core on my Mac.

    So I fired up Safari, went to http://dot.net (love that domain!) got myself the bits for macOS 10.11.

    I've followed the basic Getting Started from the docs, and created the most basic ASP.NET Core (1.0.1) website. The source code you can find on GitHub here: https://github.com/msdevsHK/website

    I've also created a brand new Azure subscription and started out with a brand new D1 (Shared) App Service Plan to host the site. From the Azure Portal, I've created the site and setup deployment from GitHub, by watching the master branch.

    So when I look with Kudu into the deployment logs, I can see that deployments are triggered from GitHub, but the website seems not to be hosted by App Service. I've added a .deployment file into the root of the repo, to tell Kudu to look in the 'source' folder.

    When I look in the logs, this is what I find:

    2016-09-18T16:20:06.1943627Z,Updating submodules.,4b92155d-a057-4ad8-aff4-e075d4b43c0f,0
    2016-09-18T16:20:06.2412374Z,Preparing deployment for commit id 'a3a47aa665'.,1e7eb0df-5137-4f27-8949-8a1a1aad89b3,0
    2016-09-18T16:20:06.4131191Z,Generating deployment script.,fe8de8de-45d9-4ecc-930b-61be6546bcde,0
    	2016-09-18T16:20:06.4443746Z,Using the following command to generate deployment script: 'azure site deploymentscript -y --no-dot-deployment -r "D:\home\site\repository" -o "D:\home\site\deployments\tools" --basic --sitePath "D:\home\site\repository\source"'.,,0
    	2016-09-18T16:20:06.8506375Z,The site directory path: .\source,,0
    	2016-09-18T16:20:06.8506375Z,Generating deployment script for Web Site,,0
    	2016-09-18T16:20:06.8668294Z,Generated deployment script files,,0
    2016-09-18T16:20:06.9131459Z,Running deployment command...,1278b312-fe62-43c5-b3e4-752e127fb4a6,0
    	2016-09-18T16:20:06.9287637Z,Command: "D:\home\site\deployments\tools\deploy.cmd",,0
    	2016-09-18T16:20:07.4131674Z,Handling Basic Web Site deployment.,,0
    	2016-09-18T16:20:07.6787896Z,KuduSync.NET from: 'D:\home\site\repository\source' to: 'D:\home\site\wwwroot',,0
    	2016-09-18T16:20:07.6787896Z,Deleting file: '.gitignore',,0
    	2016-09-18T16:20:07.6787896Z,Deleting file: 'LICENSE',,0
    	2016-09-18T16:20:07.6787896Z,Deleting file: 'README.md',,0
    	2016-09-18T16:20:07.6944150Z,Copying file: 'Program.cs',,0
    	2016-09-18T16:20:07.6944150Z,Copying file: 'project.json',,0
    	2016-09-18T16:20:07.6944150Z,Copying file: 'Startup.cs',,0
    	2016-09-18T16:20:07.6944150Z,Deleting file: '.vscode\settings.json',,0
    	2016-09-18T16:20:07.6944150Z,Deleting directory: '.vscode',,0
    	2016-09-18T16:20:07.7100374Z,Deleting file: 'source\Program.cs',,0
    	2016-09-18T16:20:07.7100374Z,Deleting file: 'source\project.json',,0
    	2016-09-18T16:20:07.7100374Z,Deleting file: 'source\Startup.cs',,0
    	2016-09-18T16:20:07.7100374Z,Deleting directory: 'source',,0
    	2016-09-18T16:20:07.7256606Z,Finished successfully.,,0
    2016-09-18T16:20:07.7569192Z,Running post deployment command(s)...,926f37b0-02fa-46c4-8780-8e79c9f22e94,0
    2016-09-18T16:20:07.8194122Z,Deployment successful.,61e93d37-c1c8-40a3-8afa-a243b281d2cb,0

    In D:\home\site\deployments\tools there is a deploy.cmd file with this version info:

    :: ----------------------
    :: KUDU Deployment Script
    :: Version: 1.0.8
    :: ----------------------

    The problem seems to be that the ASP.NET Core app isn't built.

    In the wwwroot I simply find:

    D:\home\site\wwwroot>ls
    Program.cs
    Startup.cs
    project.json

    In other deployment guides I found references to .sln, but for the Mac approach there is only the project.json.

    Am I doing something wrong?

    Thanks

    Monday, September 19, 2016 1:19 PM

Answers

  • I finally can report success! Thanks for the suggestions and links, David.

    There are two crucial elements in the docs:

    1. Add the IISIntegration dependency.
    2. Add the publish-iis postpublish step.

    Without #1, the page would load and eventually timeout, with the following error in the EventLog:

    <Events>
        <Event>
            <System>
                <Provider Name="IIS AspNetCore Module"/>
                <EventID>1000</EventID>
                <Level>0</Level>
                <Task>0</Task>
                <Keywords>Keywords</Keywords>
                <TimeCreated SystemTime="2016-09-20T15:35:05Z"/>
                <EventRecordID>50071875</EventRecordID>
                <Channel>Application</Channel>
                <Computer>RD00155D826D57</Computer>
                <Security/>
            </System>
            <EventData>
                <Data>Process was created with commandline '"dotnet" .\source.dll' but either crashed or did not reponse within given time or did not listen on the given port '23454', ErrorCode = '0x800705b4'</Data>
            </EventData>
        </Event>

    Tuesday, September 20, 2016 4:01 PM

All replies

  • Hi,

    Please check this article:
    https://docs.asp.net/en/latest/tutorials/your-first-mac-aspnet.html

    Regards,
    Azam Khan

    Monday, September 19, 2016 6:47 PM
  • I think the problem is that Kudu is not able to detect that this is a Core app, so it treats it as a 'plain' site, and just deploys all the files as is (which of course won't work).

    For now, you can override the script generator by setting an App Setting in the Portal:

    SCM_SCRIPT_GENERATOR_ARGS=--aspNetCore source\project.json

    Bu we need to improve this scenario.

    Monday, September 19, 2016 9:38 PM
    Moderator
  • With David's suggested change, the project is now built upon deployment. All I had to do was going to the Azure Portal, set the App Setting, and go to Deployment Options, click the active deployment and click Redeploy.

    However, when I go to the URL, I still get the following error:

    You do not have permission to view this directory or page.

    It seems App Service is not binding the ASP.NET Core app? Since I have no auth setup for this project.

    Here's the deployment log, (clipped with [...] for repetitive actions):

    2016-09-19T23:32:17.5165552Z,Updating branch 'a3a47aa6657da0dfd10d89a0f875c11d3119e1c0'.,ae85c17c-47d6-4d11-9fa3-7726efad1f1b,0
    2016-09-19T23:32:17.8446857Z,Updating submodules.,16f6378d-aceb-45e2-b6e7-3abe87c18fa7,0
    2016-09-19T23:32:17.8915615Z,Preparing deployment for commit id 'a3a47aa665'.,35214fd0-2a7f-4107-b18c-4883ad7410cd,0
    2016-09-19T23:32:18.0634548Z,Generating deployment script.,c14922c5-998b-4afd-b311-3768dc2b11d3,0
    	2016-09-19T23:32:18.1259467Z,Using the following command to generate deployment script: 'azure site deploymentscript -y --no-dot-deployment -r "D:\home\site\repository" -o "D:\home\site\deployments\tools" --aspNetCore source\project.json'.,,0
    	2016-09-19T23:32:18.8134727Z,Project file path: .\source\project.json,,0
    	2016-09-19T23:32:18.8290999Z,Generating deployment script for ASP.NET Core Application,,0
    	2016-09-19T23:32:18.8603731Z,Generated deployment script files,,0
    2016-09-19T23:32:18.9384738Z,Running deployment command...,25d9a431-0c95-4958-8f7c-282af404ae87,0
    	2016-09-19T23:32:18.9384738Z,Command: "D:\home\site\deployments\tools\deploy.cmd",,0
    	2016-09-19T23:32:19.4385007Z,Handling ASP.NET Core Web Application deployment.,,0
    	2016-09-19T23:32:20.7823021Z,Restoring packages for D:\home\site\repository\source\project.json...,,0
    	2016-09-19T23:32:21.4542010Z,  GET https://api.nuget.org/v3-flatcontainer/microsoft.netcore.app/index.json,,0
    	2016-09-19T23:32:21.4698213Z,  GET https://api.nuget.org/v3-flatcontainer/microsoft.aspnetcore.server.kestrel/index.json,,0
    [...]
    	2016-09-19T23:32:36.3454169Z,  OK https://api.nuget.org/v3-flatcontainer/system.net.websockets/4.0.0/system.net.websockets.4.0.0.nupkg 972ms,,0
    	2016-09-19T23:32:36.5016543Z,Installing System.Diagnostics.Contracts 4.0.1.,,0
    	2016-09-19T23:32:36.5329018Z,Installing System.Text.Encodings.Web 4.0.0.,,0
    [...]
    	2016-09-19T23:32:55.4572680Z,Installing Microsoft.AspNetCore.Http.Extensions 1.0.0.,,0
    	2016-09-19T23:32:55.4880170Z,Installing Microsoft.NETCore.DotNetHost 1.0.1.,,0
    	2016-09-19T23:33:08.1135325Z,Committing restore...,,0
    	2016-09-19T23:33:08.1135325Z,Writing lock file to disk. Path: D:\home\site\repository\source\project.lock.json,,0
    	2016-09-19T23:33:08.2385080Z,D:\home\site\repository\source\project.json,,0
    	2016-09-19T23:33:08.2385080Z,Restore completed in 47474ms.,,0
    	2016-09-19T23:33:08.2541430Z,,,0
    	2016-09-19T23:33:08.2541430Z,NuGet Config files used:,,0
    	2016-09-19T23:33:08.2541430Z,    C:\DWASFiles\Sites\#1MSDevsHK\AppData\NuGet\NuGet.Config,,0
    	2016-09-19T23:33:08.2698002Z,,,0
    	2016-09-19T23:33:08.2698002Z,Feeds used:,,0
    	2016-09-19T23:33:08.2698002Z,    https://api.nuget.org/v3/index.json,,0
    	2016-09-19T23:33:08.2853824Z,,,0
    	2016-09-19T23:33:08.2853824Z,Installed:,,0
    	2016-09-19T23:33:08.3010080Z,    137 package(s) to D:\home\site\repository\source\project.json,,0
    	2016-09-19T23:33:09.5666875Z,Publishing source for .NETCoreApp&comma;Version=v1.0,,0
    	2016-09-19T23:33:09.8479478Z,Project source (.NETCoreApp&comma;Version=v1.0) will be compiled because expected outputs are missing,,0
    	2016-09-19T23:33:09.9260759Z,Compiling source for .NETCoreApp&comma;Version=v1.0,,0
    	2016-09-19T23:33:12.9574439Z,,,0
    	2016-09-19T23:33:12.9574439Z,Compilation succeeded.,,0
    	2016-09-19T23:33:12.9730634Z,    0 Warning(s),,0
    	2016-09-19T23:33:12.9730634Z,    0 Error(s),,0
    	2016-09-19T23:33:12.9730634Z,,,0
    	2016-09-19T23:33:12.9730634Z,Time elapsed 00:00:03.0238615,,0
    	2016-09-19T23:33:13.6636923Z, ,,0
    	2016-09-19T23:33:13.6762221Z,,,0
    	2016-09-19T23:33:14.0668603Z,publish: Published to D:\local\Temp\8d3e0e531f5ccd7,,0
    	2016-09-19T23:33:14.0824855Z,Published 1/1 projects successfully,,0
    	2016-09-19T23:33:14.5043978Z,KuduSync.NET from: 'D:\local\Temp\8d3e0e531f5ccd7' to: 'D:\home\site\wwwroot',,0
    	2016-09-19T23:33:14.5043978Z,Deleting file: 'Program.cs',,0
    	2016-09-19T23:33:14.5200025Z,Deleting file: 'project.json',,0
    	2016-09-19T23:33:14.5200025Z,Deleting file: 'Startup.cs',,0
    	2016-09-19T23:33:14.5356363Z,Copying file: 'Microsoft.AspNetCore.Hosting.Abstractions.dll',,0
    	2016-09-19T23:33:14.5356363Z,Copying file: 'Microsoft.AspNetCore.Hosting.dll',,0
    	2016-09-19T23:33:14.5356363Z,Copying file: 'Microsoft.AspNetCore.Hosting.Server.Abstractions.dll',,0
    	2016-09-19T23:33:14.5512624Z,Copying file: 'Microsoft.AspNetCore.Http.Abstractions.dll',,0
    	2016-09-19T23:33:14.5512624Z,Copying file: 'Microsoft.AspNetCore.Http.dll',,0
    	2016-09-19T23:33:14.5668897Z,Copying file: 'Microsoft.AspNetCore.Http.Extensions.dll',,0
    	2016-09-19T23:33:14.5668897Z,Copying file: 'Microsoft.AspNetCore.Http.Features.dll',,0
    	2016-09-19T23:33:14.5668897Z,Copying file: 'Microsoft.AspNetCore.Server.Kestrel.dll',,0
    	2016-09-19T23:33:14.5825000Z,Copying file: 'Microsoft.AspNetCore.WebUtilities.dll',,0
    	2016-09-19T23:33:14.5825000Z,Copying file: 'Microsoft.Extensions.Configuration.Abstractions.dll',,0
    	2016-09-19T23:33:14.5825000Z,Copying file: 'Microsoft.Extensions.Configuration.dll',,0
    	2016-09-19T23:33:14.5981256Z,Copying file: 'Microsoft.Extensions.Configuration.EnvironmentVariables.dll',,0
    	2016-09-19T23:33:14.5981256Z,Copying file: 'Microsoft.Extensions.DependencyInjection.Abstractions.dll',,0
    	2016-09-19T23:33:14.6137656Z,Copying file: 'Microsoft.Extensions.DependencyInjection.dll',,0
    	2016-09-19T23:33:14.6918914Z,Copying file: 'Microsoft.Extensions.FileProviders.Abstractions.dll',,0
    	2016-09-19T23:33:14.7075072Z,Copying file: 'Microsoft.Extensions.FileProviders.Physical.dll',,0
    	2016-09-19T23:33:14.7075072Z,Copying file: 'Microsoft.Extensions.FileSystemGlobbing.dll',,0
    	2016-09-19T23:33:14.7075072Z,Copying file: 'Microsoft.Extensions.Logging.Abstractions.dll',,0
    	2016-09-19T23:33:14.7231289Z,Copying file: 'Microsoft.Extensions.Logging.dll',,0
    	2016-09-19T23:33:14.7231289Z,Copying file: 'Microsoft.Extensions.ObjectPool.dll',,0
    	2016-09-19T23:33:14.7231289Z,Copying file: 'Microsoft.Extensions.Options.dll',,0
    	2016-09-19T23:33:14.7387559Z,Copying file: 'Microsoft.Extensions.PlatformAbstractions.dll',,0
    	2016-09-19T23:33:14.7387559Z,Copying file: 'Microsoft.Extensions.Primitives.dll',,0
    	2016-09-19T23:33:14.7387559Z,Copying file: 'Microsoft.Net.Http.Headers.dll',,0
    	2016-09-19T23:33:14.7543815Z,Copying file: 'source.deps.json',,0
    	2016-09-19T23:33:14.7543815Z,Copying file: 'source.dll',,0
    	2016-09-19T23:33:14.7543815Z,Copying file: 'source.pdb',,0
    	2016-09-19T23:33:14.7700062Z,Copying file: 'source.runtimeconfig.json',,0
    	2016-09-19T23:33:14.7700062Z,Copying file: 'System.Diagnostics.Contracts.dll',,0
    	2016-09-19T23:33:14.7700062Z,Copying file: 'System.Net.WebSockets.dll',,0
    	2016-09-19T23:33:14.7856323Z,Copying file: 'System.Text.Encodings.Web.dll',,0
    	2016-09-19T23:33:14.7856323Z,Finished successfully.,,0
    2016-09-19T23:33:14.8481401Z,Running post deployment command(s)...,78caf315-3f65-47e2-8d8a-93cab4f8e9a4,0
    2016-09-19T23:33:14.9262765Z,Deployment successful.,16d8034e-ee35-4dff-9c1a-b0cad0f311cf,0
    

    Monday, September 19, 2016 11:49 PM
  • I see, so the problem is that no web.config gets generated. Kudu generates a deployment script that looks like this:

    call :ExecuteCmd nuget.exe restore -packagesavemode nuspec
    IF !ERRORLEVEL! NEQ 0 goto error
    
    :: 2. Build and publish
    call :ExecuteCmd dotnet publish "source\project.json" --output "%DEPLOYMENT_TEMP%" --configuration Release
    IF !ERRORLEVEL! NEQ 0 goto error
    

    But it appears that the dotnet publish command is not treating the project as a web app. We'll need to ask the dotnet core experts to help understand this.

    Tuesday, September 20, 2016 1:10 AM
    Moderator
  • Ok, that makes sense actually. Since from the ASP.NET Core perspective I've only specified that it should be hosted with Kestrel.

    I don't feel it's the responsibility of the dotnet publish command to automatically understand that the project will be hosted in an App Service environment that requires a Web.config to bind Kestrel to IIS. This is implementation specific and should be handled by App Service, or Kudu in this case, in my opinion. Maybe the dotnet publish command can have a flag to indicate this?

    So either the Azure documentation explains what Web.config is needed in the project folder of a ASP.NET Core site to get it going on App Service, or Kudu has a final automatic step to setup the binding.

    Would you have an example Web.config file that has the minimum config needed to setup this binding?

    Tuesday, September 20, 2016 2:18 AM
  • Actually, 'dotnet publish' has support for auto-generating a web.config. It's a matter of having the right magic in project.json. I'm asking the core guys about it.
    Tuesday, September 20, 2016 3:00 AM
    Moderator
  • Thanks a lot, David - will be good to document this magic. :-)
    Tuesday, September 20, 2016 3:29 AM
  • Ok, I think I found it in the Core docs. See https://docs.asp.net/en/latest/publishing/iis.html#publish-iis-tool. It tells you exactly what you need to add:

    "tools": {
      "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
    },
    "scripts": {
      "postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%"
    }

    And indeed in a VS generated project (link this one), I have those things. Can you give it a shot?

    Tuesday, September 20, 2016 3:35 AM
    Moderator
  • Thanks! - I'll try tonight when I can test it on my Mac. From the link you mentioned, it looks like I might also need to configure the project at startup:

    var host = new WebHostBuilder()
      .UseKestrel()
      .UseContentRoot(Directory.GetCurrentDirectory())
      .UseIISIntegration()
      .UseStartup<Startup>()
      .Build();
    Note the .UseIISIntegration(). I'll try the project.json changes first and see if it's needed to add this config line as well at startup.


    Tuesday, September 20, 2016 3:46 AM
  • I finally can report success! Thanks for the suggestions and links, David.

    There are two crucial elements in the docs:

    1. Add the IISIntegration dependency.
    2. Add the publish-iis postpublish step.

    Without #1, the page would load and eventually timeout, with the following error in the EventLog:

    <Events>
        <Event>
            <System>
                <Provider Name="IIS AspNetCore Module"/>
                <EventID>1000</EventID>
                <Level>0</Level>
                <Task>0</Task>
                <Keywords>Keywords</Keywords>
                <TimeCreated SystemTime="2016-09-20T15:35:05Z"/>
                <EventRecordID>50071875</EventRecordID>
                <Channel>Application</Channel>
                <Computer>RD00155D826D57</Computer>
                <Security/>
            </System>
            <EventData>
                <Data>Process was created with commandline '"dotnet" .\source.dll' but either crashed or did not reponse within given time or did not listen on the given port '23454', ErrorCode = '0x800705b4'</Data>
            </EventData>
        </Event>

    Tuesday, September 20, 2016 4:01 PM
  • Note that if you use Yeoman from your Mac, it can generate a starter project that has all the right things in it, which makes life easier. See https://docs.asp.net/en/latest/client-side/yeoman.html
    Wednesday, September 21, 2016 12:29 AM
    Moderator