Skip to content

Instantly share code, notes, and snippets.

@spboyer
Last active December 2, 2016 16:51
Show Gist options
  • Save spboyer/3984b735bc4a59cfa642b5bfd01e8264 to your computer and use it in GitHub Desktop.
Save spboyer/3984b735bc4a59cfa642b5bfd01e8264 to your computer and use it in GitHub Desktop.
Create a ASP.NET Core web application using the dotnet-cli and push to Azure using the azure-cli
Counting objects: 84, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (78/78), done.
Writing objects: 100% (84/84), 551.03 KiB | 0 bytes/s, done.
Total 84 (delta 5), reused 0 (delta 0)
remote: Updating branch 'master'.
remote: Updating submodules.
remote: Preparing deployment for commit id '59c9c966b5'.
remote: Generating deployment script.
remote: Project file path: .\preview3web.csproj
remote: Generating deployment script for .NET console application
remote: Generated deployment script files
remote: Running deployment command...
remote: Handling .NET Console Application deployment.
remote: .
remote: Controllers\HomeController.cs(5,17): error CS0234: The type or namespace name 'AspNetCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [D:\home\site\repository\preview3web.csproj]
remote: Program.cs(6,17): error CS0234: The type or namespace name 'AspNetCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [D:\home\site\repository\preview3web.csproj]
remote: Startup.cs(5,17): error CS0234: The type or namespace name 'AspNetCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [D:\home\site\repository\preview3web.csproj]
remote: Startup.cs(6,17): error CS0234: The type or namespace name 'AspNetCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [D:\home\site\repository\preview3web.csproj]
remote: Startup.cs(7,17): error CS0234: The type or namespace name 'Extensions' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [D:\home\site\repository\preview3web.csproj]
remote: Startup.cs(8,17): error CS0234: The type or namespace name 'Extensions' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [D:\home\site\repository\preview3web.csproj]
remote: Startup.cs(9,17): error CS0234: The type or namespace name 'Extensions' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [D:\home\site\repository\preview3web.csproj]
remote: Controllers\HomeController.cs(9,35): error CS0246: The type or namespace name 'Controller' could not be found (are you missing a using directive or an assembly reference?) [D:\home\site\repository\preview3web.csproj]
remote: Controllers\HomeController.cs(11,16): error CS0246: The type or namespace name 'IActionResult' could not be found (are you missing a using directive or an assembly reference?) [D:\home\site\repository\preview3web.csproj]
remote: Controllers\HomeController.cs(16,16): error CS0246: The type or namespace name 'IActionResult' could not be found (are you missing a using directive or an assembly reference?) [D:\home\site\repository\preview3web.csproj]
remote: Controllers\HomeController.cs(23,16): error CS0246: The type or namespace name 'IActionResult' could not be found (are you missing a using directive or an assembly reference?) [D:\home\site\repository\preview3web.csproj]
remote: Controllers\HomeController.cs(30,16): error CS0246: The type or namespace name 'IActionResult' could not be found (are you missing a using directive or an assembly reference?) [D:\home\site\repository\preview3web.csproj]
remote: Startup.cs(25,16): error CS0246: The type or namespace name 'IConfigurationRoot' could not be found (are you missing a using directive or an assembly reference?) [D:\home\site\repository\preview3web.csproj]
remote: Startup.cs(28,39): error CS0246: The type or namespace name 'IServiceCollection' could not be found (are you missing a using directive or an assembly reference?) [D:\home\site\repository\preview3web.csproj]
remote: Startup.cs(35,31): error CS0246: The type or namespace name 'IApplicationBuilder' could not be found (are you missing a using directive or an assembly reference?) [D:\home\site\repository\preview3web.csproj]
remote: Startup.cs(35,56): error CS0246: The type or namespace name 'IHostingEnvironment' could not be found (are you missing a using directive or an assembly reference?) [D:\home\site\repository\preview3web.csproj]
remote: Startup.cs(35,81): error CS0246: The type or namespace name 'ILoggerFactory' could not be found (are you missing a using directive or an assembly reference?) [D:\home\site\repository\preview3web.csproj]
remote: Startup.cs(15,24): error CS0246: The type or namespace name 'IHostingEnvironment' could not be found (are you missing a using directive or an assembly reference?) [D:\home\site\repository\preview3web.csproj]
remote: Failed exitCode=1, command="D:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" "D:\home\site\repository\preview3web.csproj" /nologo /verbosity:m /t:Build /p:Configuration=Release;OutputPath="D:\local\Temp\8d41ad308f0fcfb\app_data\jobs\continuous\deployedJob";UseSharedCompilation=false
remote: An error has occurred during web site deployment.
remote:
remote: Error - Changes committed to remote repository but deployment to website failed.
To https://[email protected]/preview3web.git
* [new branch] master -> master

Prerequisites

  • azure-cli
  • dotnet-cli Preview 3

Install the latest azure-cli using npm

$ npm install azure-cli -g

Configure azure-cli

Login to Azure

$ azure login

The cli prompts you to go to a url and enter a specific code to login to the portal.

Enable Azure CLI Service Management mode commands

$ azure config mode asm

dotnet-cli Preview 3

Create the Web app using the dotnet-cli

# create the destinatation directory
$ mkdir preview3web

# change directory
$ cd preview3web

# create new application with template option of web
$ dotnet new -t web

# restore nuget packages
$ dotnet restore

Console Output

  Restoring packages for .../preview3web/preview3web.csproj...
  Writing lock file to disk. Path: .../preview3web/obj/project.assets.json
  Generating MSBuild file .../preview3web/obj/preview3web.csproj.nuget.g.targets.
  Generating MSBuild file .../preview3web/obj/preview3web.csproj.nuget.g.props.
  Restore completed in 1657.5765ms for .../preview3web/preview3web.csproj.

  NuGet Config files used:
      /Users/shayneboyer/.nuget/NuGet/NuGet.Config

  Feeds used:
      https://api.nuget.org/v3/index.json

Creating the Web site using the azure-cli

--location sets the Azure region for the site to be created, and the --git option set that we will be using git deploy to deploy the application.

$ azure site create 'preview3web' --location 'East US' --git

Console Output

info:    Executing command site create
+ Getting sites
+ Getting locations
info:    Creating a new web site at preview3web.azurewebsites.net
\info:    Created website at preview3web.azurewebsites.net
+
+ Getting locations
info:    Executing `git init`
info:    Initializing remote Azure repository
+ Updating site information
info:    Remote azure repository initialized
+ Getting site information
+ Getting user information
info:    Executing `git remote add azure https://[email protected]/preview3web.git`
info:    A new remote, 'azure', has been added to your local git repository
info:    Use git locally to make changes to your site, commit, and then use 'git push azure master' to deploy to Azure
info:    site create command OK

Add the site contents and push to azure.

$ git add .

$ git commit -m 'init'

Push to Azure

$ git push azure master
2016-12-02T16:48:11 Welcome, you are now connected to log-streaming service.
2016-12-02T16:48:24 Updating branch 'master'.
2016-12-02T16:48:25 Updating submodules.
2016-12-02T16:48:25 Preparing deployment for commit id '59c9c966b5'.
2016-12-02T16:48:25 Generating deployment script.
2016-12-02T16:48:25 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" --dotNetConsole "D:\home\site\repository\preview3web.csproj" --no-solution'.
2016-12-02T16:48:27 Project file path: .\preview3web.csproj
2016-12-02T16:48:27 Generating deployment script for .NET console application
2016-12-02T16:48:27 Generated deployment script files
2016-12-02T16:48:27 Running deployment command...
2016-12-02T16:48:27 Command: "D:\home\site\deployments\tools\deploy.cmd"
2016-12-02T16:48:28 Handling .NET Console Application deployment.
2016-12-02T16:48:33 Controllers\HomeController.cs(5,17): error CS0234: The type or namespace name 'AspNetCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [D:\home\site\repository\preview3web.csproj]
2016-12-02T16:48:33 Program.cs(6,17): error CS0234: The type or namespace name 'AspNetCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [D:\home\site\repository\preview3web.csproj]
2016-12-02T16:48:33 Startup.cs(5,17): error CS0234: The type or namespace name 'AspNetCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [D:\home\site\repository\preview3web.csproj]
2016-12-02T16:48:33 Startup.cs(6,17): error CS0234: The type or namespace name 'AspNetCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [D:\home\site\repository\preview3web.csproj]
2016-12-02T16:48:33 Startup.cs(7,17): error CS0234: The type or namespace name 'Extensions' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [D:\home\site\repository\preview3web.csproj]
2016-12-02T16:48:33 Startup.cs(8,17): error CS0234: The type or namespace name 'Extensions' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [D:\home\site\repository\preview3web.csproj]
2016-12-02T16:48:33 Startup.cs(9,17): error CS0234: The type or namespace name 'Extensions' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [D:\home\site\repository\preview3web.csproj]
2016-12-02T16:48:33 Controllers\HomeController.cs(9,35): error CS0246: The type or namespace name 'Controller' could not be found (are you missing a using directive or an assembly reference?) [D:\home\site\repository\preview3web.csproj]
2016-12-02T16:48:33 Controllers\HomeController.cs(11,16): error CS0246: The type or namespace name 'IActionResult' could not be found (are you missing a using directive or an assembly reference?) [D:\home\site\repository\preview3web.csproj]
2016-12-02T16:48:33 Controllers\HomeController.cs(16,16): error CS0246: The type or namespace name 'IActionResult' could not be found (are you missing a using directive or an assembly reference?) [D:\home\site\repository\preview3web.csproj]
2016-12-02T16:48:33 Controllers\HomeController.cs(23,16): error CS0246: The type or namespace name 'IActionResult' could not be found (are you missing a using directive or an assembly reference?) [D:\home\site\repository\preview3web.csproj]
2016-12-02T16:48:33 Controllers\HomeController.cs(30,16): error CS0246: The type or namespace name 'IActionResult' could not be found (are you missing a using directive or an assembly reference?) [D:\home\site\repository\preview3web.csproj]
2016-12-02T16:48:33 Startup.cs(25,16): error CS0246: The type or namespace name 'IConfigurationRoot' could not be found (are you missing a using directive or an assembly reference?) [D:\home\site\repository\preview3web.csproj]
2016-12-02T16:48:33 Startup.cs(28,39): error CS0246: The type or namespace name 'IServiceCollection' could not be found (are you missing a using directive or an assembly reference?) [D:\home\site\repository\preview3web.csproj]
2016-12-02T16:48:33 Startup.cs(35,31): error CS0246: The type or namespace name 'IApplicationBuilder' could not be found (are you missing a using directive or an assembly reference?) [D:\home\site\repository\preview3web.csproj]
2016-12-02T16:48:33 Startup.cs(35,56): error CS0246: The type or namespace name 'IHostingEnvironment' could not be found (are you missing a using directive or an assembly reference?) [D:\home\site\repository\preview3web.csproj]
2016-12-02T16:48:33 Startup.cs(35,81): error CS0246: The type or namespace name 'ILoggerFactory' could not be found (are you missing a using directive or an assembly reference?) [D:\home\site\repository\preview3web.csproj]
2016-12-02T16:48:33 Startup.cs(15,24): error CS0246: The type or namespace name 'IHostingEnvironment' could not be found (are you missing a using directive or an assembly reference?) [D:\home\site\repository\preview3web.csproj]
2016-12-02T16:48:33 Failed exitCode=1, command="D:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" "D:\home\site\repository\preview3web.csproj" /nologo /verbosity:m /t:Build /p:Configuration=Release;OutputPath="D:\local\Temp\8d41ad308f0fcfb\app_data\jobs\continuous\deployedJob";UseSharedCompilation=false
2016-12-02T16:48:33 An error has occurred during web site deployment.
2016-12-02T16:48:33
D:\Program Files (x86)\SiteExtensions\Kudu\59.51122.2559\bin\Scripts\starter.cmd "D:\home\site\deployments\tools\deploy.cmd"
2016-12-02T16:48:33 Error occurred, type: error, text:
D:\Program Files (x86)\SiteExtensions\Kudu\59.51122.2559\bin\Scripts\starter.cmd "D:\home\site\deployments\tools\deploy.cmd", stackTrace: at Kudu.Core.Infrastructure.Executable.ExecuteInternal(ITracer tracer, Func`2 onWriteOutput, Func`2 onWriteError, Encoding encoding, String arguments, Object[] args)
at Kudu.Core.Infrastructure.Executable.ExecuteWithProgressWriter(ILogger logger, ITracer tracer, String arguments, Object[] args)
at Kudu.Core.Deployment.Generator.ExternalCommandBuilder.RunCommand(DeploymentContext context, String command, String message)
2016-12-02T16:48:33
2016-12-02T16:48:33 Error occurred, type: error, text:
D:\Program Files (x86)\SiteExtensions\Kudu\59.51122.2559\bin\Scripts\starter.cmd "D:\home\site\deployments\tools\deploy.cmd", stackTrace: at Kudu.Core.Infrastructure.Executable.ExecuteInternal(ITracer tracer, Func`2 onWriteOutput, Func`2 onWriteError, Encoding encoding, String arguments, Object[] args)
at Kudu.Core.Infrastructure.Executable.ExecuteWithProgressWriter(ILogger logger, ITracer tracer, String arguments, Object[] args)
at Kudu.Core.Deployment.Generator.ExternalCommandBuilder.RunCommand(DeploymentContext context, String command, String message)
at Kudu.Core.Deployment.Generator.GeneratorSiteBuilder.Build(DeploymentContext context)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Kudu.Core.Deployment.DeploymentManager.<Build>d__36.MoveNext()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment