Thursday, April 20, 2017

Steps require to host your application into the Pivotal Cloud Foundry

Host your application into the Pivotal Cloud Foundry PCF

Register in Pivotal and go to “Pivotal Web Services”, you will get free trial upto 2 GB

 If you already have an account in PCF then Login using 
https://login.run.pivotal.io/login With User Id: Email Id and Pwd: Password

You will need a workspace where app can be hosted, for that you need to create Organization and then Workspace
Go to Given/Created Org >> Click Add Space >> create new space for you

For CF push to work, you will need manifest.yml file to be a part of your app’s output folder.
Sample manifest.yml file content

.NET Framework aAps, yml file 

---
applications:
- name: RiteshWebAPI
  memory: 512m
  disk_quota: 512m  
  buildpack: binary_buildpack
  stack: windows2012R2
 env:
    ConnectionString: @SQLConnectionString@
    App_Log: @AppLogConnection@
 services:
   - syslog-drain
routes:
   - route: @route@
instances: @instances@


.NET Core Apps,  buildpack and stack will be changed , run > cf buildpacks or > cf stacks to see available buildpack and stack in PCF environment.
        buildpack: dotnet_core_buildpack
        stack: cflinuxfs2

Build your App, WebAPI, WebApp etc. Following things needs to be taken care while code, Code need to follow 12 factor app https://12factor.net/
Best Practices for ASP.Net application Application Types: MVC, WebForm, WebAPI, WCF

  • Avoid Integrated Windows Authentication
  • Avoid the Global Access Cache (GAC)
  • Avoid custom IIS handlers
  • Avoid anything that uses the Windows registry
  • Avoid using local disk for storing application state. Any data that needs to persist needs to be stored in backing service. Ex.  Database (SQL Server,Mongo DB)
  • Avoid in process session state.
  • For ASP.NET override MachineKey in web.config and on ASP.NET Core
  • Avoid persisting keyring to filesystem
  • On ASP.NET avoid environment specific configuration in web.config      
  • Avoid using any Windows specific or disk based logging
  • Avoid any 32-bit specific libraries or libraries that cannot be bin deployable.
Once your App is ready you can publish it in some folder let’s say “C:\Ritesh\WebAPIPublish\”
  
First steps to start your deployment into the PCF, you need Common Language Interface (CLI) Download CLI from below

Now, Open Command Prompt (cmd), type following commands to login
Login By Browser URL: https://login.run.pivotal.io/login
Login By CLI URL: https://api.run.pivotal.io/

Start Login by command prompt, Go to the directory where you have published your source code (make sure this folder has all required files to run the app, including “.yml” file

C:\Ritesh\ WebAPIPublish> cf login -a https://api.run.pivotal.io/
Email> UserId
Password> Password
Space> 1        // if multiple space available, you need to choose desire space

Now you are ready to start the deployment
C:\Ritesh\WebAPIPublish> cf push

If error pops up go and see the log
C:\Ritesh\WebAPIPublish> cf log   - recent

If log shows that health check fail than turn off health check up
C:\Ritesh\WebAPIPublish> cf push --health-check-type=none

Let’s wait till you see application started message
1 of 1 instance running
OK

After successfully deployed you can login online and get the URL and you can use it to access your app like: https://riteshwebapi.cfapps.io

References:
https://pivotal.io/platform/pcf-tutorials/getting-started-with-pivotal-cloud-foundry/deploy-the-sample-app
https://pivotal.io/platform

7 comments:

sheela rajesh said...

Thanks for your interesting ideas.the information's in this blog is very much useful for me to improve my knowledge.
iOS Training in Chennai
iOS Training in Velachery
JAVA Training in Chennai
Python Training in Chennai
Big data training in chennai
Selenium Training in Chennai
IOS Training in Chennai
ios training institute in chennai

Anbarasan14 said...

Had a great time reading your blog. Thanks for sharing this post to our vision.

Spoken English Classes in Medavakkam
Spoken English Class in Pallavaram
Spoken English Class in Perungudi
Spoken English Classes in Ambattur OT
Spoken English Classes in Chennai
Spoken English in Chennai
English Speaking Classes in Mumbai
IELTS Chennai
IELTS Mumbai

Manipriyan said...

Had a great time reading your blog. Thanks for sharing this post to our vision.




Python Training | Java Course in Chennai

Azure DevOps said...

Informative blog. Thank you for sharing this with us.
Cloud Foundry Online Training

Priya said...

Great Work. Amazing way of writing things. Thanks for Posting.
Cloud Foundry Developer Online Training in Hyderabad
Cloud Foundry Online Training
Best Cloud Foundry Training Institute

latchu kannan said...

You are doing an amazing job . keep sharing on.

AngularJS training in chennai | AngularJS training in anna nagar | AngularJS training in omr | AngularJS training in porur | AngularJS training in tambaram | AngularJS training in velachery

Devi said...

Really it was an awesome article… very interesting to read…. oracle training in chennai