ASP.NET Core is a new open-source and cross-platform framework for building modern cloud-based and internet-connected applications using the C# programming language.
Google Cloud Shell is a browser-based command line tool to access Google Cloud Platform resources. Cloud Shell makes it really easy to manage your Cloud Platform Console projects and resources without having to install the Google Cloud SDK and other tools on your system. With Cloud Shell, the Cloud SDK gcloud command and other utilities such as .NET Core command line interface tools are always available when you need them.
In this lab, you will learn about how to build and launch an ASP.NET Core app from Google Cloud Shell — without ever leaving the browser.
If you don't already have a Google account (Gmail or GSuite), you must create one. Then, sign-in to Google Cloud Platform console (console.cloud.google.com) and create a new project:
Remember the project ID, a unique name across all Google Cloud Platform projects. It will be referred to later in this codelab as
Next, you'll need to enable billing in Google Cloud Console in order to use Google Cloud Platform resources.
Google Cloud Shell is the browser-based command line tool to access Google Cloud Platform resources. Cloud Shell makes it really easy to manage your Cloud Platform Console projects and resources without having to install the Google Cloud SDK and other tools on your system. With Cloud Shell, the Cloud SDK gcloud command and other utilities such as .NET Core command line interface tools are always available when you need them.
To get started:
A Cloud Shell session opens inside a new frame at the bottom of the console and displays a command-line prompt. This might take a few seconds as Cloud Shell is spinning a VM.
Wait until the $ prompt appears.
ASP.NET Core is a significant redesign of the traditional Windows-only ASP.NET framework. You can develop and run your ASP.NET Core apps cross-platform on Windows, Mac and Linux.
ASP.NET Core comes with the .NET Core command-line interface (CLI), a new foundational cross-platform toolchain for developing .NET Core applications. This toolchain is already installed in Google Cloud Shell.
In the next section, we use the .NET Core command-line interface to create our first ASP.NET Core app.
In Cloud Shell prompt, dotnet command line tool is already installed and you can verify its version as follows.
Next, create a new skeleton ASP.NET Core web app.
dotnet new razor -o HelloWorldAspNetCore
This should create a project and restore its dependencies. You should see a message similar to below.
Restore completed in 11.44 sec for HelloWorldAspNetCore.csproj. Restore succeeded.
We're almost ready to run our app. Navigate to the app folder.
Finally, run the app.
dotnet run --urls=http://localhost:8080
Application starts listening on port 8080.
Hosting environment: Production Content root path: /home/atameldev/HelloWorldAspNetCore Now listening on: http://[::]:8080 Application started. Press Ctrl+C to shut down.
To verify that the app is running, click on the web preview button on the top right and select ‘Preview on port 8080'.
You'll see the default ASP.NET Core webpage which simply prints Hello World in a new tab.
Once you verified that the app is running, press Ctrl+C to shut down the app.
There! You've just created and launched an ASP.NET Core app from inside Cloud Shell, without once leaving your browser. But that's not all you can do. You can take your newly created ASP.NET Core app, containerize it using Docker and deploy it to Google App Engine. Or you can let Kubernetes manage it all for you in Google Container Engine.