Quick start: develop & deploy a .NET Core app on Oracle Cloud
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)
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
Move into the newly created app directory — you should see the project contents
cd DotnetCoreOnAppContainerCloud
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
To pull respective dependencies, execute the following
npm install
dotnet restore
And then
- Build the project —
dotnet build
- followed by creating a binary for the Linux platform
dotnet publish -c Release -r linux-x64
— this will create thepublish
directory inbin\Release\netcoreapp2.0\linux-x64
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
.. and you can see it’s details once the deployment completes
Check out your application
Click on the application URL (highlighted above) and it should lead you to the app home page
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.