Quick start: develop & deploy a .NET Core app on Oracle Cloud

Abhishek Gupta
Dec 22, 2017 · 4 min read

The run time juggernaut for Oracle Application Container Cloud continues.. and the latest addition is Microsoft .NET Core ! This makes it the fourth run time which is sourced directly from DockerHub (in addition to Python, Ruby and Go)

Image for post
Image for post
Hello .NET Core !
Image for post
Image for post
currently supported versions

This blog is a getting started guide to build and deploy a .NET Core app to Oracle Application Container Cloud. This is a simple app which is bootstrapped using an existing .NET Core React template

By the way, we introduced Golang support not too long ago

Let’s get going…

Start by installing the .NET Core SDK

Bootstrap a project — since I am a UI noob, the react template is a god send ! Lets put it to use quickly scaffold a project

dotnet new react -n DotnetCoreOnAppContainerCloud

Image for post
Image for post
New ‘dotnet’ project

Move into the newly created app directory — you should see the project contents

cd DotnetCoreOnAppContainerCloud

Image for post
Image for post
the stage is set

Edit the Program.cs file to add this on line 23.UseUrls("http://0.0.0.0:"+ Environment.GetEnvironmentVariable("PORT"))

It is to ensure that the HTTP server binds to the $PORT environment variable once its deployed to Oracle Application Container Cloud

Image for post
Image for post
tweak the code

To pull respective dependencies, execute the following

  • npm install
  • dotnet restore

And then

  • Build the project — dotnet build
Image for post
Image for post
  • followed by creating a binary for the Linux platform dotnet publish -c Release -r linux-x64 — this will create thepublish directory in bin\Release\netcoreapp2.0\linux-x64
Image for post
Image for post
‘dotnet build’ process
Image for post
Image for post
(some of) the contents of the ‘publish’ directory

Zip the contents of the publish directory e.g. accs-dotnetcore-sample.zip

Create deployment metadata files

These descriptor/metadata files will be referenced during the deployment step (up next)

Start with manifest.json where you specify the version and the application bootstrap/startup command

{
"runtime":{
"majorVersion":"2.0.0-runtime"
},
"command": "dotnet DotnetCoreOnAppContainerCloud.dll"
}

and the deployment.json where you specify the topology — in this case its 1 instance with 1 GB memory

{
"memory":"1G",
"instances":1
}

Push to cloud

With Oracle Application Container Cloud, you have multiple options in terms of deploying your applications. This blog will leverage PSM CLI which is a powerful command line interface for managing Oracle Cloud services

other deployment options include REST API, Oracle Developer Cloud and of course the console/UI

  • Download and setup PSM CLI on your machine (using psm setup) — details here
  • deploy the application — psm accs push -n DotnetCoreReactApp -r dotnet -e dockerhub -s hourly -m manifest.json -d deployment.json -p bin\Release\netcoreapp2.0\linux-x64\publish\accs-dotnetcore-sample.zip

Note that

  • we reference the zip file (using -p) and the deployment descriptors (-m and -d)
  • include the runtime name (-r dotnet) and the fact that its sourced from Docker Hub (with -e dockerhub)

That’s it — the app creation should get initiated

Image for post
Image for post
.NET Core app on Oracle Application Container Cloud

.. and you can see it’s details once the deployment completes

Image for post
Image for post
application details

Check out your application

Click on the application URL (highlighted above) and it should lead you to the app home page

Image for post
Image for post
Up and running !

That wasn’t too hard ! You now have a .NET Core based application running on Oracle Application Container Cloud

Don’t forget to…

  • check out the tutorials for Oracle Application Container Cloud — there is something for every runtime!
  • other blogs on Application Container Cloud

Cheers!

The views expressed in this post are my own and do not necessarily reflect the views of Oracle.

Oracle Groundbreakers

Aggregation of articles from Oracle engineers…

Abhishek Gupta

Written by

Currently working with Kafka, Databases, Azure, Kubernetes and related open source projects | Confluent Community Catalyst (for Kafka)

Oracle Groundbreakers

Aggregation of articles from Oracle engineers, Groundbreaker Ambassadors, ACEs, and the developer community on all things Oracle Cloud. The views expressed are those of the authors and not necessarily of Oracle.

Abhishek Gupta

Written by

Currently working with Kafka, Databases, Azure, Kubernetes and related open source projects | Confluent Community Catalyst (for Kafka)

Oracle Groundbreakers

Aggregation of articles from Oracle engineers, Groundbreaker Ambassadors, ACEs, and the developer community on all things Oracle Cloud. The views expressed are those of the authors and not necessarily of Oracle.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store