I have been working on .NET platform for last 15 years. I started with ASP and graduated to ASP.NET Web Forms during 2001 time frame. That’s the time when .NET 1.0 was out. ASP.NET Web Forms was super fancy web application development framework because you could do Drag & Drop development. It could run only on Windows Environment and IIS was the web server. Fast forward 15 years i.e. current time and i would have never believed in my dreams that we will be running ASP.NET on a non-windows environment. Well you read it right – you can now deploy & run a ASP.NET web application on Linux & OSX.
In this blog post we will look at one of our product offering in Progress Software – what we call as Modulus. Using Modulus you can host ASP.NET Core 1.0 apps in a breeze. Sit back and read through rest of the blog post to know how you host your ASP.NET Core 1.0 apps with minimal steps.
About ASP.NET Core:
Here is what the official docs from Microsoft say about ASP.NET Core 1.0:
ASP.NET Core 1.0 is a new open-source and cross-platform framework for building modern cloud-based Web applications using .NET. We built it from the ground up to provide an optimized development framework for apps that are either deployed to the cloud or run on-premises. It consists of modular components with minimal overhead, so you retain flexibility while constructing your solutions. You can develop and run your ASP.NET Core applications cross-platform on Windows, Mac and Linux. ASP.NET Core is fully open source on GitHub.
As you can see – you can now host & run your ASP.NET applications in Mac & Linux also. That’s pretty interesting if you ask me. As i said earlier i had never thought that this can happen. Well change is always good.
Now let me introduce you to Modulus. Modulus is a product that we have here in Progress. Modulus is a Platform as a Service (PaaS) offering. With Modulus we try to abstract the difficulties of managing infrastructure, environments and run times and allow you to focus on developing your software. The Modulus platform handles everything required to deploy, manage, and monitor your product in a production ready, scalable, and secure environment.
Modulus has a lot of features, but the core of the platform boils down to three major pieces:
1. Deploying – pushing new revisions of your product and getting those into production.
2. Scaling – once a product is deployed, scaling it up to meet any amount of demand.
3. Load balancing – ensure even distribution of traffic across all of your application instances.
Signup for Modulus:
If you want to try out Modulus, you can do so by signing up for an account. You can head over here and create an account for yourself. To start off you get a $15 credit in your account and it is good for 30 days of free usage.
Modulus provides a Command Line Interface or CLI to do most of the tasks on Modulus. To install the Modulus CLI, simply NPM install it globally.
$ npm install -g modulus
Using Modulus CLI is easy. The usage is as follows:
modulus <command> <param1> <param2>
You can run help command at any point of time to get a full list of commands and how to use them.
Login to Modulus:
Once you have your account created and CLI installed, you will need to log in to your account. For this we can use login command and you will be asked to provide your credentials. A login session will be opened so that we can run other commands under our account in future. This session will be closed when we run logout command. Here is the usage:
$ modulus login
Welcome to Modulus
[?] Enter your username or email: spiderman
[?] Enter your password:
[√] Signed in as user spiderman
Create a Project on Modulus:
First step is to create a empty ASP.NET Core project on Modulus platform. For that we can use the following command:
modulus project create “Project Name”
Here is a screenshot from my machine after i ran the create command:
What we have done by the above command is to create a project on Modulus platform, set its runtime to be DNX or Dot Net Execution environment. DNX is the environment which runs ASP.NET Core now. We set the servo size which is defaulted to 512. This command creates a placeholder for my application on Modulus platform. Here is how the portal look like after project creation:
Create ASP.NET Core Project from YEOMAN:
Previous step created the placeholder for us on Modulus platform. Now we create the actual ASP.NET Core project. One of the easiest ways to create a ASP.NET Core project is to use YEOMAN generator and use it to scaffold a ASP.NET Core project. To install YEOMAN, do an NPM install globally yo. Here is the command usage:
npm install -g yo
Then you need to install ASP.NET Generator so that we can scaffold a ASP.NET Core project. Here is the command usage:
npm install -g generator-aspnet
Now we can scaffold a ASP.NET Core Application from command line. First create a directory for your project on your file system. Then change your directory to your newly created folder. Then run the ASP.NET generator for yo
The yeoman generator will display a menu. You can use your Arrow keys to select a template. I have selected Web Application template and hit enter.
Next it will ask you the name of the project and follow the on screen instruction. Yeoman will go ahead and scaffold the ASP.NET Core project. You can CD into your project folder now.
Deploy to Modulus:
In Previous step we created a ASP.NET Core project using Yeoman generator. Now its time to deploy it to Modulus. For deploying just use the following commands on the same command prompt you have logged in to modulus before:
Modulus CLI will restore the DNX packages that is required for the project and upload it to the project we created earlier on Modulus platform. Once CLI finishes the upload, we can then login to portal and see that the app is started now. Here is how my portal looks like now:
That’s it. We have our ASP.NET Core project hosted on Modulus platform and is now running. Notice that the public URL to access the application is provided at the top. If i now browse to that URL, i will see my ASP.NET Core app – the basic template we all are used to – will be served without any problem:
With Modulus you get an option to easily host your ASP.NET application within no time. Modulus does support Scaling, Streaming Logs, Metrics etc. I haven’t spoken about full features of Modulus. But wanted to showcase how you can deploy ASP.NET Core Apps on to Modulus and host your apps.
If you have any feedback/suggestion please do let us know through your comments below.
Till next time – Happy Coding!