How-tos

Getting started with ASP.NET 5 – A tutorial

Share this post:

Last fall, IBM & Microsoft announced a partnership agreement which includes bringing .NET to IBM Bluemix and we’re happy to share that it’s here! As the next step in this partnership, we’ve just released ASP.NET 5 as an experimental runtime in the Bluemix Labs Catalog, extending the Bluemix vision to the .NET community. In addition, we have also open sourced our ASP.NET 5 buildpack and made it available on GitHub. For all you .NET developers, this means building apps with Watson, Cloudant and more is right at your fingertips.

Wanna see what we’ve got?

Watch the video (https://www.youtube.com/watch?v=9lXowDQ1FEY)

Contents:

Stage 0: Bluemix Basics

In a nutshell, Bluemix is an implementation of IBM’s Open Cloud Architecture based on Cloud Foundry, an open source Platform as a service (PaaS). Developers can rapidly build, deploy, and manage cloud applications, while tapping into a rich portfolio of available services and runtime frameworks.

If this is your first look at Bluemix, check out these resources to learn more:

Now sign up for a free trial and log into Bluemix so we can get started!

Stage 1: “Hello World” with ASP.NET 5

  • Log into Bluemix (if you haven’t already). Upon signing in, you’ll be presented with the Bluemix Dashboard. The Dashboard shows an overview of the active Bluemix space for your organization.
  • From the Bluemix Dashboard, click CREATE AN APP and select WEB
    create
  • Select ASP.NET 5 and click CONTINUE
  • Name your application and click FINISH

 

Behind the Scenes

Now your application is staging – Mono, the .NET Version Manager, and the .NET Execution Environment are being installed in your application’s container. Then packages required by the application are downloaded from NuGet.

The technology stack for the initial release is ASP.NET 5 using Mono as the Windows emulation layer. We will shift from Mono to the official Microsoft .NET Core for Linux once the technology is ready.

  • The application’s Overview page is where you can get APP HEALTH, ACTIVITY LOG information, and mange your application. Once the status says”Your application is running”, click the Routes URL to see your application:
  • Now you should see … well, okay … so it’s just “Hello World” (but it gets better, I promise)

Stage 2: Continuous Delivery with DevOps Services & Git

Now that your app is running, you can see and modify its code by using IBM DevOps Services.

What is DevOps Services?

IBM® Bluemix DevOps Services is software as a service (SaaS) on the cloud that supports continuous delivery. With IBM Bluemix DevOps Services, you can develop, track, plan, and deploy software in one place. From your projects, you can access everything that you need to build all types of apps. To simplify team work, use the collaboration tools. After you build an app, you can deploy it to the IBM Bluemix cloud platform. You can go from source code to a running app in minutes.

IBM Bluemix DevOps Services provides these capabilities:

  • Agile planning, through the Track & Plan service
  • A Web IDE for editing and managing source control
  • Source control management (SCM), through Git, Jazz SCM, or GitHub
  • Automated builds and deployments, through the Delivery Pipeline service

Let’s get started!

  • On the Application Overview page, click Click ADD GIT

 

Behind the Scenes

This will create an IBM DevOps Services (IDS) project, a Git repository containing the application code, and a delivery pipeline that will, by default, automatically re-deploy the application on a “git push”.

NOTE: If this is your first time using IBM DevOps Services, you’ll see a registration prompt. Use the same IBM id, and create an alias.

  • Make sure “Populate the repository with the starter application package and enable Delivery Pipeline (Build & Deploy)” is checked and click CONTINUE
  • Click EDIT CODE to see the contents of your new IDS project (ADD GIT should be replaced with EDIT CODE)

Stage 3a: Update Your Application with Visual Studio

  • Copy the Git URL so you can clone it on your local workstation
  • Clone the project in Visual Studio 2015
  • Open the project in Visual Studio using the solution file
  • Modify the application (we took the lazy route and just changed the “Hello World” message in Index.cshtml)
  • Commit and push your change
  • Switch back to DevOps Services

 

Behind the Scenes

IBM DevOps Services delivery pipeline automatically kicked off a build and re-deploy upon your git commit and push. The IDS BUILD & DEPLOY tab allows you to keep tabs on what’s going on. When the deploy stage finishes, your change will be updated in Bluemix.

  • And voila! “Hello Universe” (.NET Style)

Stage 3b: Update Your Application with <insert favorite tool>

Cloud Foundry command line interface + your favorite editor

  • From the Bluemix Dashboard, click START CODING on the left navigation menu
  • Click the CF Command Line Interface icon. This tab walks you through steps to use the Cloud Foundry cf commands to update your application and provides nice context-sensitive commands tailored to your username, application, etc. Basically, it’s the “download the code, use favorite editor, and cf push” approach.

DevOps Service Web Integrated Development Environment (WebIDE)

The integrated Web IDE is based on the Eclipse Orion open-source project.

  • Click OVERVIEW to return to the Application Overview page
  • Click EDIT CODE

This will launch the IBM DevOps and your project will open up in the WebIDE. From here, you can edit files with syntax coloring support, push changes to Git using the IDS integrated Git support, and as we did above, kick off a Build & Deploy pipeline.

Stage 4: Beyond “Hello World” (i.e. the cool stuff)

Now comes the real power Bluemix brings to .NET.

Take a stroll around the Bluemix Catalog tab … from your ASP.NET 5 applications, you can connect to a whole array of cool services. No need to install anything, no need to configure anything. It’s all just there. Ready and waiting for you to come play.

You heard me mention Watson & Cloudant right at your fingertips?

Scroll to the bottom of the Bluemix Catalog tab and you’ll see the Bluemix Labs Catalog

We’ve added two new boilerplates that show how to get started using these with just 1 click. You can use these to get started and build from there, or just take a peek and see how to use services.

ASP.NET 5 + Watson QA Starter App

The ASP.NET 5 Watson QA starter app illustrates how to communicate with the Watson Question Answer service to ask Watson travel-related questions.

ASP.NET 5 + Cloudant Starter App

The ASP.NET 5 Cloudant starter app creates a sample To-Do list app which demonstrates how .NET can connect to a Cloudant NoSQL database and perform the CRUD operations.

Again, just 1-click (OK, plus you have to give it a name)

Stage 5: Beyond Bluemix – Connecting to the outside world (Hybrid Cloud)

So, how can your Bluemix app “phone home” – to your data center, to another cloud, and maybe someday to another universe? The beauty of running on Bluemix is that we have services. For everything. OK, maybe not EVERYTHING, but almost.

Anyway, the Bluemix Secure Gateway service facilitates hybrid cloud scenarios by creating a secure connection from Bluemix to the outside world – be it your enterprise data center or another cloud like Microsoft Azure or IBM Softlayer. It establishes a tunnel between your Bluemix organization and the remote location that you want to connect to.

What about SQL Server? Or Sharepoint you may ask? Most people already have data residing in their existing system of record like Microsoft SQL Server. A great use case would be to create your new, engaging, next-gen app in Bluemix and be able to access data in SQL Server wherever it’s running today.

If you want to connect to a system outside of Bluemix, check out the resources below:

OK … now it’s your turn. Try it out for yourself. I dare you. (and let us know how it goes)

Sign up for Bluemix. It’s free!

Additional information:

More stories
May 1, 2019

Two Tutorials: Plan, Create, and Update Deployment Environments with Terraform

Multiple environments are pretty common in a project when building a solution. They support the different phases of the development cycle and the slight differences between the environments, like capacity, networking, credentials, and log verbosity. These two tutorials will show you how to manage the environments with Terraform.

Continue reading

April 29, 2019

Transforming Customer Experiences with AI Services (Part 1)

This is an experience from a recent customer engagement on transcribing customer conversations using IBM Watson AI services.

Continue reading

April 26, 2019

Analyze Logs and Monitor the Health of a Kubernetes Application with LogDNA and Sysdig

This post is an excerpt from a tutorial that shows how the IBM Log Analysis with LogDNA service can be used to configure and access logs of a Kubernetes application that is deployed on IBM Cloud.

Continue reading