Deploying An App On IBM Cloud With Cloud Foundry

Ever wondered how to deploy an application to the cloud? Here, I will give you an introduction to the cloud and will show you how to deploy a sample .NET application to the IBM Cloud. Even though I will be demonstrating with a .NET application, you can tweak it to change it according to your needs to suit the applications made in other technologies.

We are using an IBM cloud account to deploy our sample app. You can sign up for their trial version.

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 - Signing up for a trial IBM Cloud account.

You can sign up for a free trial IBM Cloud account as below.

Deploying An App On IBM Cloud With Cloud Foundry 

Once you are done with the registration, you will be taken to the dashboard.

Deploying An App On IBM Cloud With Cloud Foundry 

Click on ‘Create Resource’ here. Since I am deploying an ASP.NET Core app, I will select that as the type of resource that I want to create. You can select the resource as the type of application you want to deploy.

Deploying An App On IBM Cloud With Cloud Foundry 

While creating the resource, you have to enter your app name and other details. Remember the app name and the region that you select. This will be required later.

Deploying An App On IBM Cloud With Cloud Foundry 
 
Deploying An App On IBM Cloud With Cloud Foundry 

Once the app is created, click "Visit App URL". It will look like below.

Deploying An App On IBM Cloud With Cloud Foundry 

Note down the URL of your application, as you would be pushing your new .NET application to this URL.

Step 2 - Downloading the IBM Cloud CLI

Download IBM Cloud CLI from here.

Step 3 - Creating a sample app

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

Deploying An App On IBM Cloud With Cloud Foundry 
 
Deploying An App On IBM Cloud With Cloud Foundry 

Now, run this sample application.

Deploying An App On IBM Cloud With Cloud Foundry 

Now, we need to publish this app before deploying it in the cloud. Right-click on it and select the publish details as below.

Deploying An App On IBM Cloud With Cloud Foundry
 
Deploying An App On IBM Cloud With Cloud Foundry 

Step 4 - Pushing your sample app to the cloud

Now, open your command prompt and type the following command.

Ibmcloud login -u [username]

It will ask for a password. Enter it.

It will then ask for the region where you want to run it. Select the region that you had selected when creating your IBM Cloud account. If you don’t remember, either check the URL of your app or go to your IBM Cloud account to find out the region.

Deploying An App On IBM Cloud With Cloud Foundry 

Type the following command to start using cloud foundry commands.

Ibmcloud target –cf

Deploying An App On IBM Cloud With Cloud Foundry 

You are now set to push your application to the cloud. Navigate to the folder where you have published your code through the command prompt.

Type the following command.

cf push [appName]

The appName will be the one that you had entered while creating the IBM Cloud account.

Deploying An App On IBM Cloud With Cloud Foundry 

Once the push is successful, go to your original URL and you will find that the app has been pushed.

Deploying An App On IBM Cloud With Cloud Foundry 

We have successfully managed to push our app to the cloud.

This article originally appeared on Taagung.


Similar Articles