.NET on Pivotal CF: Connecting and Pushing an App

Raman Yurkin

.NET on Pivotal CF

Release 1.6 of Pivotal CF, a Cloud Foundry distro by Pivotal, introduced native support for .NET apps. Within the same cluster, one can now combine Windows- and Linux-based software. Working with .NET on PCF still requires a bit of additional hoop-jumping, but this tutorial series will get you pushing apps and adding services in no time.

As the first example, I will deliver a simple .NET application to a PCF instance (Pivotal Elastic Runtime 1.6.2) in Altoros’s private cloud. The same steps will also work for a public Pivotal CF account.



Before starting, make sure you have all the necessary prerequisites in place:

  1. First of all, get credentials for the PCF instance. In my case, I simply need to ask our CF administrator for them (thanks, Boris!). If you are using a public Pivotal CF, the credentials are provided during registration. My initial set of input data looks like this:

    Organization name: Altoros
    Space: dev
    Username: {UserName}
    Password: {Password}

  2. We will also need the PCF Command Line Interface tool. Download, unzip, and install the file to run CF commands in PowerShell. If you are using a public PCF instance, you can get the link to the zip file from the Tools page of the Apps Manager (more details here).

  3. Now we can start playing with PCF. Begin by registering the API endpoint:

  4. cf api api.YOUR_DOMAIN --skip-ssl-validation

  5. Then, log in to the Pivotal CF instance:
  6. cf login -u {UserName} -p {Password}

  7. PCF provides .NET application support under Diego, so we also need to check if the Diego CLI plug-in is installed. Run cf plugins to list all the installed plug-ins and all the commands they provide.
  8. cf plugins

    If Diego CLI is not on the list, install it from GitHub:

    cf add-plugin-repo CF-Community
    cf install-plugin Diego-Enabler -r CF-Community


Preparing an app

Now let’s prepare a simple ASP.NET MVC test app to publish on our PaaS. In this example, I will use a standard MVC sample app for .NET Framework 4.5.

  1. Compile and start the app, so that it works locally.
  2. Windows apps on Pivotal CF

  3. Publish the project to the local file system, using default settings and “….\Published” as the target path.
  4. .NET on PCF

  5. The sample app is ready. Now, you can go to this target directory in the Windows PowerShell console and push the app into the Pivotal CF instance.


Pushing a .NET app to PCF

Publishing .NET apps is a bit different from publishing regular Linux apps. There are a couple of things to keep in mind:

  • Since we are pushing an APS.NET application to the Windows stack, which is not the default one for Pivotal CF, we have to specify its name. To see the stack name, check the list of available stacks:

    cf stacks

    Our target stack name is windows2012R2.

  • The start command must be set to “none,” so that you can enable Diego for the application before it is started.

  • We also need to set a null buildpack for the application, because existing buildpacks are not suitable for our purposes. I used a buildpack from this GitHub repository.

Finally, everything is ready. The actual publishing only takes three steps:

  1. Start pushing the app with the final version of the push command, which now looks like this:
  2. cf push SampleWebApp -p .\ -s windows2012R2 --no-start -b

  3. Enable Diego for the app:
  4. cf enable-diego samplewebapp

  5. Start the app:
  6. cf start samplewebapp

In a few seconds, the app instance is up and running.

.NET app on Pivotal Cloud Foundry

In the upcoming posts, I will play with different MVC versions of sample apps and add distributed services, such as MS SQL.


About the author: Raman Yurkin is a Solutions Architect at Altoros. It’s hard to list all the programming languages and technologies he has worked with over the last 20 years, but today his main focus areas are the .NET stack, Microsoft Azure, and PaaS.

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

Get new posts right in your inbox!

  • Gowri LN

    Hi ,

    Thanks for the documentation. I tried the steps but in my pcf account when I try to list stacks , I get only LInuxstack and not windows2012R2 . How do I enable this ?

    • Raman Yurkin

      Hi, Gowri LN,

      It seems Windows stacks are not enabled. See PCF documentation for more info on how to add them You might want to ask your PCF operator to add the stacks for you.

      • Gowri LN

        Hi Raman,
        Thanks for the response. To add windows stack, do we need access to a pivotal CF setup of our own ? I am currently using Pivotal web services account at . Is there a way to enable this in Pivotal web services?

        • Raman Yurkin

          You will need full access to your Pivotal CF deployment to add stacks. We have checked with and it turns out the Windows stack is turned off at the moment until Windows Server 2016 is able to provide sufficient isolation in a .NET environment.

          • Gowri LN

            Thanks a lot for the information. This really helped !

Benchmarks and Research

Subscribe to new posts

Get new posts right in your inbox!