Deploying an ASP.NET Application to GE Predix

by Eugene LahanskyMarch 31, 2016
Use these step-by-step instructions to set up the Predix console, prepare a simple ASP.NET app, and push it to Predix with the Cloud Foundry CLI.

deploying-asp.net-app-to-ge-predix

Predix is a Cloud Foundry–based PaaS for the Industrial Internet from GE. It offers developers a wide choice of programming languages and services. This tutorial guides you through the process of preparing a simple ASP.NET application for Predix and then pushing it to the platform.

 

Prerequisites

To follow the steps of this tutorial, you need:

  • a Predix account
  • Microsoft Visual Studio 2015
  • the Cloud Foundry CLI

 

Setting up the Predix console

To get started, create a new space:

  1. Log in to your Predix account and navigate to Console.
  2. Click Create Space and type a name for your space.

predix-console-create-space

 

Preparing the application for Predix

To make your ASP.NET application ready for deployment to Predix:

  1. Go to Microsoft Visual Studio 2015 and create a new project using a standard ASP.NET 5 template.
  2. Compile and start the application to check if it works locally.
  3. preparing-an-asp.net-app-for-ge-predix

  4. To deploy the application in Predix, modify the project.json file. First, include the Microsoft.AspNet.Server.Kestrel dependency and the kestrel command. Then, make sure your application targets the dnxcode50 framework. These changes help Predix to choose the correct buildpack for the application. The project.json file should look as shown below.
    "dependencies": {
    ...
        "Microsoft.AspNet.Server.Kestrel": "1.0.0-beta8",
    },
    "commands": {
    ...
        "kestrel": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.Kestrel"
    },
    "frameworks": {
        "dnxcore50": { }
    }
    ...
    
  5. Compile and start the application again to check if the configuration is valid.

 

Deploying the application to Predix

After finishing the necessary preparations, you can deploy the application to Predix. With the Cloud Foundry CLI installed, go through these steps:

  1. Open cmd.exe and change to your ASP.NET directory:
  2. cd <folder where project.json is located>
  3. Log in to your Predix account.
    cf login -a <API endpoint> -u <your predix email> -o <your predix organization> -s <your predix space>

    where:

    • -a sets the API endpoint, which can be found in the welcome e-mail that you get during registration for a Predix.io user account.
    • -u sets the username.
    • -o sets the organization.
    • -s sets the space.

    You will be also asked for your password—the one you chose during registration.

  4. After logging in, push the application.

    cf push eugeneaspnet5 -b https://github.com/cloudfoundry-community/asp.net5-buildpack.git

    The cf push command has two parameters:

    • the Predix application name (required)
    • the Cloud Foundry buildpack set in the -b flag (optional)

    We would recommend to define the buildpack parameter either as a command option or in the manifest.yml file.

The result of the cf push command will look as shown below.

0 of 1 instances running, 1 starting
1 of 1 instances running

App started
OK
App eugeneaspnet5 was started using this command `dnx --project . kestrel --server.urls http://0.0.0.0:${PORT}`
Showing health and status for app eugeneaspnet5 in org predix.app.dojo@altoros.com / space dev.net as predix.app.dojo@altoros.com...
OK
requested state: started
instances: 1/1
usage: 1G x 1 instances
urls: eugeneaspnet5.run.aws-usw02-pr.ice.predix.io
last uploaded: Tue Mar 29 13:39:33 UTC 2016
stack: cflinuxfs2
buildpack: https://github.com/cloudfoundry-community/asp.net5-buildpack.git
state     since                    cpu    memory         disk      
running   2016-03-29 04:41:17 PM   0.0%   371.1M of 1G   666.4M of 1G

Now, you can see the result in the browser.

running-asp.net-app-on-ge-predix

Creating the droplet and uploading it to Predix is quite easy and doesn’t require any special settings, except the preparations in the Predix console. In our future articles, we are going to show how to work with different services from our sample Predix application.

 

Further reading


This blog post was written by Eugene Lahansky with assistance from Victoria Fedzkovich
and edited by Alex Khizhniak.