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.
Once you are done with the registration, you will be taken to the dashboard.
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.
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.
Once the app is created, click "Visit App URL". It will look like below.
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.
Now, run this sample application.
Now, we need to publish this app before deploying it in the cloud. Right-click on it and select the publish details as below.
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.
Type the following command to start using cloud foundry commands.
Ibmcloud target –cf
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.
Once the push is successful, go to your original URL and you will find that the app has been pushed.
We have successfully managed to push our app to the cloud.
This article originally appeared on Taagung.