Sample code demonstrating running trivial .NET web applications on Google Cloud Platform services.
The example here uses Microsofts's .NET Core 1.0.0 RC/preview (dotnet-dev-1.0.0-preview2-003121).
You can use Visutal Studio 2015 to create and extend the sample from scratch. VS2015
- WebApplication1 Default webapplication generated by Visual Studio 2015: "New Project
- ASP.NET Core Web Application (.NET Core) ; (Change Authenticaiton --> No Authentication)
(optionally, if you want to try out Google APIs, see Using Google API Libraries)
Sample application simply spins up inside a Docker container an runs Kestrel to host the application. The sample is modified from the baseline in the following way to run with healthchecks in GCP:
- port: 8080
- GET requests to endpoint /_ah/health must return a 200 OK HTTP response
- Use Kestrel Webserver
If you want to pack the deployment to a .dll using dotnet publish
in project.json, if the following artifiact from Visual Studio exists, remove
Then make the build/release .dll
To run the local pack directly:
Finally, edit the Dockerfile
Note: As of 8/16, dotnet is currently not supported on Alpine Linux.
Deploying to GCP requires your gcloud environment to get setup:
gcloud auth login
gcloud config set project <your_project>
Deploying to GAE is pretty simple:
gcloud app deploy app.yaml
To deploy on GKE, you need to setup the replication controllers and frontend loadbalancer services as well as a small cluster.