Over a million developers have joined DZone.
Platinum Partner

The World Is Your Oyster: Installing and Using Cloud Foundry on Windows

· Cloud Zone

The Cloud Zone is brought to you in partnership with Iron.io. Discover how Microservices have transformed the way developers are building and deploying applications in the era of modern cloud infrastructure.

Cloud Foundry is an incredibly cool way to build and deploy cloud apps to any target cloud using very simple commands.

The basic api has just three commands:
  1. vmc target cloud.url //targets a cloud
  2. vmc login // login to cloud
  3. vmc push // run your app in the cloud
Three commands and the (cloud) world is your oyster! Very cool.

This may be just me but I found it difficult to follow the install guide for Cloud Foundry on my windows machine. For those of us trapped behind corporate firewalls and proxy servers, things got even more complicated.

After scurrying around the cloud foundry forums and stackoverflow, here are my slightly revised notes for getting Cloud Foundry running on a Windows machine using a proxy server:

1. Apply for a Cloud Foundry account at www.cloudfoundry.com you will be notified by email when your account is activated

2. Install Ruby from www.rubyinstaller.org. The Cloud Foundry cloud controller command line is built in Ruby so this is required. As the installer runs, make sure to check the boxes to add the ruby directory to your command path

3. Start the Windows command line client on windows by typing "run cmd" in start menu

4. Install the Cloud Controller software. Type:
gem install vmc

If you are behind a firewall, you will get a nasty error message:

ERROR: Could not find a valid gem 'vmc' (>=0) in any repository

5. Install vmc gem through a proxy server, type:

gem install --http-proxy http://proxy.vmware.com:3128 vmc

Congratulations! The Cloud Foundry Cloud Controller is now installed. From here on, you can type Cloud Foundry commands into the Windows command window.

6. Tell Cloud Foundry which cloud you want to connect to. Type:

vmc target api.cloudfoundry.com

Again, if you are benhind a firewall, you will get the error message

Host is not valid: 'http://api.cloudfoundry.com

7. To communicate with Cloud Foundry through a proxy server, set the environment variable "http_proxy". In the command window, type

set http_proxy=http://proxy.vmware.com:3128
vmc target api.cloudfoundry.com

8. Login to Cloud Foundry

vmc login

Enter your email address and password

9. Create a simple Ruby application.

cd \
mkdir hello
cd hello

The above commands create a "C:\hello" directory. Using a text editor type the following and save the file as "hello.rb"

require 'sinatra'
get '/' do
"Hello from Cloud Foundry +VMware and may I add you look dashing today?"

11. Publish the application to the cloud. Type:

vmc push

The following prompts will appear :

Would you like to deploy from the current directory? [Yn]
Assuming that you are in the hello directory hit enter (this answers Yes)

Application Name: hello_username
NOTE: use a unique name for your application best to concat your user name and "hello"

Application Deployed URL: ‘hello_username.cloudfoundry.com’?
Press enter to accept default

Detected a Sinatra Application, is this correct? [Yn]
Press enter to accept default

Memory Reservation [Default:128M] (64M, 128M, 256M, 512M, 1G or 2G)
Press enter to accept default (128MB)

Creating Application: OK...
Would you like to bind any services to ‘hello’ [yN]:
Press enter, you don’t want to bind any services for this example

12. Launch a web browser and go to your Application Deployment URL.

Now wasn't that easy?

The Cloud Zone is brought to you in partnership with Iron.io. Learn how to build and test their Go programs inside Docker containers.


Published at DZone with permission of Chris Keene , DZone MVB .

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}