Blog

Deploying an ASP.NET Application to GE Predix

Eugene Lahansky

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

For getting 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.

    preparing-an-asp.net-app-for-ge-predix

  3. For deploying 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. Here is how the project.json file should look like:

    "dependencies": {
    ...
        "Microsoft.AspNet.Server.Kestrel": "1.0.0-beta8",
    },
    "commands": {
    ...
        "kestrel": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.Kestrel"
    },
    "frameworks": {
        "dnxcore50": { }
    }
    ...
    
  4. 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 command line interface installed, go through these steps:

  1. Open cmd.exe and change to your ASP.NET directory:

    cd <folder where project.json is located>
  2. 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. The endpoint can be found in the welcome email 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 while registering.

  3. 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)

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

Here is the result of the cf push command:

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
 

Conclusion

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 my future posts, I am going to show how to work with different services from our sample Predix application.


Related reading:


About the author: Eugene Lahansky is a Solutions Architect at Altoros. With his extensive experience in .NET programming, he designs and develops web-based software for Windows platforms. Eugene also works with the UNIX stack of technologies, including NGINX, Docker, and Node.js.


For the next parts of this series, subscribe to our blog or follow @altoros.

Get new posts right in your inbox!

17 Comments
  • NAGAMANIKANDAN KANNAPPAN

    Your build pack works great, but doesn’t support this dependency
    “NETStandard.Library”: “1.0.0-rc2-23811”
    Do you know the reason? If so please help me

  • naga.1990

    Your build pack works great, but doesn’t support this dependency

    “NETStandard.Library”: “1.0.0-rc2-23811”

    Do you know the reason? If so please help me

    • Eugene

      Hello! Could you share on github or somewhere else the demo project?

      • naga.1990

        I am trying sample dot net core . the code from .net core samples. Git hub link is , https://github.com/dotnet/core/tree/master/samples/helloworld

        • Eugene

          Hi again,
          In the tutorial we have covered how a website or web application (ASP.NET5) works with Predix.
          Your code from GitHub (https://github.com/dotnet/core/tree/master/samples/helloworld) is actually not an ASP.NET app, it’s a desktop application.
          In the future we may write an article about .Net desktop applications on Predix.

          • naga.1990

            Ok…If we use dependency “NETStandard.Library”: “1.0.0-rc2-23704” (or) “NETStandard.Library”: “1.0.0-rc2-23811” , in the ASP.Net app also, it doesnt work

          • Eugene

            I believe you are getting the kind of error as on the screenshot attached. If so, then just add a new file (nuget.config) and put it next to project.json
            Then, make sure that your new nuget.config file looks like the following:

            The reason is that NETStandard.Library is not on official nuget, only on http://www.myget.org
            Hope this helps.

  • Idaband

    any special magic with webapi? created a basic app that would be my rest api… i can xxxx.predix.io/api/values but as soon as i do xxx.predix.io/api/values/5 the server (predix) hangs i see the request come through on the logs. Wondering if i need to target an older asp.net 🙁

    • Eugene

      Hi @idaband:disqus,
      Do you use this project as a template (https://github.com/IBM-Bluemix/aspnet-core-helloworld)? If so, please share some test project on github (or somewhere else), so we could look into your issue.

  • Narsing Kadam

    ASP.net application with .Net core RC2 is not working on predix

    • Eugene

      Hi Narsing Kadam,
      That has happened because of huge changes been made to .Net Core recently. As a result, asp.net5-buildpack.git has been also updated (see https://github.com/cloudfoundry-community/dotnet-core-buildpack#legacy-dnx-support-used-for-rc1-apps). Due to that fact, please use this asp.net core application https://github.com/IBM-Bluemix/aspnet-core-helloworld as a template for your website. It works perfectly on Predix.

  • Eugene

    Important note: from now you can only access your deployed application on Predix using HTTPS.

  • Hugo

    Hi Eugene,

    thanx for your predix posts. One thing is not clear for me: where is the reverse proxy in this architecture?

    If I understand it correctly, the buildpack starts the asp.net core dll in kestrel, binds it to an external port and that’s all – what I’m missing?

    Thank you,
    George

    • Eugene

      Hi George,

      With Predix you don’t need to worry about reverse proxy. You only think about your application as a regular .Net app, without any specific settings for Predix.

      • Hugo

        Thank you! And can I have a question – why?:) I mean why I do not need to worry about reverse proxy?

        • Eugene

          Predix as any other Cloud Foundry hosting gives you only endpoint to your application.
          Internally, CF has such called GoRouter which parses the request url and maps it to your application. That’s why you don’t need to think about reverse proxy, you only work with endpoint/Url to you app, and CF does all the rest )

          • Hugo

            Thanks!

Benchmarks and Research

Subscribe to new posts

Get new posts right in your inbox!