In this blogpost, we will take a look at how to run one of my favorite technologies namely ASP.NET Core on IBM Bluemix cloud.
The New ASP.NET Core:
ASP.NET Core is a brand new Server Side technology for building web apps that has been written from scratch by Microsoft. It is cross platform solution which means that code developed in ASP.NET Core can be deployed on Windows or Linux or Mac operating systems. You are no more bound by Windows only tag – you can run the workload on the environment you are comfortable with. ASP.NET Core is written keeping in mind and is highly performant. Some of the benchmarks tests conducted showcase that ASP.NET Core can serve to the tune of over 100K requests per second. Whats more – ASP.NET Core is an Open Source framework. So with ASP.NET Core as a solution, you can build modern, cloud-based web applications. Some of the things you can do with ASP.NET Core are:
- Build Web Apps, Web APIs, IoT apps and mobile backends
- Use your favorite development tools on Windows/Linux/Mac
- Deploy to Cloud or on premises
- Run ASP.NET Core on .NET Core or .NET Framework
For more information on ASP.NET Core head over to official documentation found here: https://docs.microsoft.com/en-us/aspnet/core/
Running ASP.NET Core on IBM Bluemix:
Let’s look at how to run my favorite technology namely ASP.NET Core on IBM Bluemix cloud. ASP.NET Core, as said earlier is a brand-new technology from Microsoft and it can run on Windows/Linux/Mac operating systems. So, you are now not bounded by Windows only deployment rather you pick your choice of environment for deployment. So, let’s go ahead and take a lap around the different ways in which ASP.NET Core can be deployed on Bluemix.
Ways to Deploy ASP.NET Core:
Bluemix provides PaaS environment for deploying ASP.NET Core Applications. What this means is, you just bring in your ASP.NET Core application and Bluemix will manage the infrastructure for you. You can just focus on your business needs without worrying about the underlying infrastructure required to run your ASP.NET Core application.
There are 3 ways in which we can bring our ASP.NET Core workload to Bluemix. They are as follows:
- ASP.NET Core Boilerplate Option
- ASP.NET Core Cloud Foundry Apps
- Bluemix CLI
Lets look at the options one by one.
ASP.NET Core Boilerplate option:
We can create a new ASP.NET Core Application using the Boilerplate options provided in Bluemix Console. Below steps are involved with this option:
Login to your Bluemix account
Click on Add button to add a new item. Refresh the page and you will see that the data is persisted.
In this option, we saw that a pre defined template is provided to us to deploy ASP.NET Core Web Application. It also creates a Cloudant NoSQL database and the web app connects to Cloudant NoSQL database to persist the data.
ASP.NET Core Cloud Foundry App:
Bluemix provides another simple starter option for creating ASP.NET Core apps on its platform. Lets take a look at how this is done.
Login to your Bluemix account
In the Create screen, provide App name & Host name and leave the rest as default. Click Create button.
As you can see, we have our ASP.NET Core Web application deployed in seconds. This creates a very basic, simple and minimal application.
If you are command line guy, fear not. Bluemix comes with its own Command Line Interface or CLI as we call it. You can do pretty much everything you saw in previous sections using the CLI. But first you will need to download and install the CLI. You can download it from here: https://clis.ng.bluemix.net/ui/home.html. CLI is available for Mac, Windows and Linux. Download the appropriate installer.
Also you will need to have .NET Core SDK installed on your machine. You can follow the instruction provided here: https://www.microsoft.com/net/download/core. .NET Core is available on Mac/Linux/Windows, so install the appropriate SDK. Follow the below steps to deploy ASP.NET Core application to Bluemix using the CLI:
Clone the sample app. A sample app is available in IBM Bluemix Git repo. Here is the repo: https://github.com/IBM-Bluemix/get-started-aspnet-core. Change to the directory where you have cloned the sample code
git clone https://github.com/IBM-Bluemix/get-started-aspnet-core
Run the app locally. Open a command prompt and navigate to the directory where you cloned the sample code. Run the following commands
Open a browser and navigate to http://localhost:5000
- To deploy the app, execute the following command
bx app push
The app push command makes use of the manifest and creates the ASP.NET Core app on Bluemix
- After deploy has finished, you can go to your dashboard and check the newly created app.
- If you open a browser and navigate to the route for your app, you can see ASP.NET Core live in action.
In this blog post, we looked at the Bluemix support for Microsoft newest web technology called ASP.NET Core. We saw various options available for you i.e. the developer to host ASP.NET Core on Blurmix. There are 2 starter kits provided as part of the Bluemix catalog and lastly the CLI support for app deployment. Hope this provides you a perspective of ASP.NET Core & Bluemix and how they play together.
Till next time – Happy Coding. Code with Passion, Decode with Patience.