Cloud Computing: Deploy an ASP.NET Core App to PCF?

Tuba Mansoor
Latest posts by Tuba Mansoor (see all)

Here we will be deploying an ASP.NET Core app on PCF (Pivotal Cloud Foundry). Though I am using ASP.NET Core project, but the following steps apply for an application created in other technologies too.

Prerequisites:

ASP.NET Core (By default Visual Studio 2017 will have ASP.NET Core installed. With Visual Studio 2015 you may need extra plugins for the same.)

Step 1 : Creating an account with Pivotal Cloud Foundry

Create an account on Pivotal Web Services account as below:

Creating PCF account.
Creating PCF account

Step 2 : Install Cloud Foundry CLI

Install Cloud Foundry CLI.

 Once you are done installing cloud foundry, open command prompt and type:

cf help

Type cf help in command prompt to check if Cloud Foundry CLI has installed properly.
Type cf help in command prompt to check if Cloud Foundry CLI has installed properly.

If it gives you the details it means your cloud foundry cli has been successfully installed.

See also  Kafka Certification One Shot

Step 3 : Create a sample app.

Now let’s create a new a sample app to deploy. Let’s open visual Studio 2017, and select a new ‘ASP.NET Core Web Application’ as follows:

Creating a sample app
Creating a sample app
Creating a sample app
Creating a sample app

Now run this sample application. It will look as below:

Your sample app is ready!
Your sample app is ready!

Now we need to publish this app, before deploying it on cloud. Right click on it and select publish details as follows:

Publishing your app
Publishing your app
Publishing your app
Publishing your app

Step 4 : Pushing app to cloud

Now lets go to the command prompt and navigate to the folder where the published app is kept. Lets type the following command in the command prompt and press enter:

cf login -a https://api.run.pivotal.io

It will ask for the email and the password that you had used when creating your PCF account.

Type commands in command prompt as above
Type commands in command prompt as above

Then use the following command to push the application to cloud:

cf push [appname that you wanna use]

Type commands in command prompt as above

Type commands in command prompt as above

The url mentioned in the routes is your app url.

Type commands in command prompt as above

Type commands in command prompt as above

Once the app is published as above, navigate to the url mentioned in the routes (refer above screenshot). For this app, the url is ‘taagung.cfapps.io’.

Your app is deployed on PCF!
Your app is deployed on PCF!

Congratulations! Our app now live on cloud and you successfully deployed an ASP.NET Core app on Pivotal Cloud Foundry!