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
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
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
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
References:
https://pivotal.io/platform/pcf-tutorials/getting-started-with-pivotal-cloud-foundry/deploy-the-sample-app
https://pivotal.io/platform