To deploy your application to Google Cloud Platform’s App Engine you will need to first add an app.yaml file, publish your .NET Core and have the Cloud SDK installed and setup with your Project ID to use gcloud commands.

Create an app.yaml file at the root of your startup project. In Visual Studio right click your project and select add new item, name it app.yaml.

Your app.yaml should look similar to below:

runtime: aspnetcore
env: flex
env_variables:
ASPNETCORE_ENVIRONMENT: Production
service: alexacsharp

The service label is used to create a new service on the App Engine other than default, if this is your first service just omit the service label.

To have the app.yaml file be automatically copied to the Output Directory with your project when you publish add the following snippet to .csproj:

 <ItemGroup>  <None Include="app.yaml" CopyToOutputDirectory="PreserveNewest" /></ItemGroup>

Next, from the startup project’s directory, run “dotnet publish” with the configuration of your choice, for example:

dotnet publish -c Release 

You should get a message with the location of the Publish folder usually it is in the format: <project location>\bin\<configuration>\netcore<version>\publish. Go to that location and run the following command to deploy to the App Engine:

gcloud app deploy app.yaml

To deploy with a specific version:

 gcloud app deploy app.yaml --version=V0

For more info read the following Google Cloud documentations:

  1. Four methods to deploy ASP.NET Core
  2. More app.yaml settings


2 Comments

discuss · November 7, 2020 at 4:03 am

I have read so many content regarding the blogger lovers however this article is genuinely a nice post,
keep it up.

wordpress installation · November 1, 2020 at 10:01 am

I’m still learning from you, while I’m making my way to the top as well.
I certainly love reading all that is posted on your blog.Keep the aarticles coming.
I liked it!

Leave a Reply

Your email address will not be published. Required fields are marked *