This exercise will cover the following:
- Building a simple web service with ASP.Net (.NET Framework)
- Deploying the service to TAS
- Using Steeltoe to bind to a redis cloud instance
- Doing a blue/green deployment with TAS
- This demo requires a Windows workstation
- Install either Visual Studio IDE from this URL: https://visualstudio.microsoft.com/
- Install the Cloud Foundry CLI from this URL: https://docs.cloudfoundry.org/cf-cli/install-go-cli.html
- Verify the install by opening a terminal or command window and typing
cf --version. You should see a version string to match the version you installed
If you are using a private installation of TAS, then obtain credentials and API enpoint information from your TAS platform team. If you are using Pivotal Web Services (the public PCF instance hosted by Pivotal), then go to https://run.pivotal.io/ and register for a free account.
Once you have credentials, login with the CLI...
- Open a terminal or command window and login to PCF with the command
cf login -a api.run.pivotal.io(or whatever API endpoint you are using if not Pivotal Web Services) - Enter the email you registered and the password you set
- Open VisualStudio
- Take the option to "Create a New Project"
- Select the template "ASP.NET Web Application (.NET Framework)
- Name the project "MicroserviceWorkshop", press "Next"
- Select the "Web API" template, press "Create"
- Run the new web service by pressing F5 in Visual Studio, a browser window should open with a default home page
- Navigate to {base URL}/api/values - you should see an XML document with "value1" and "value2"
- Stop the service with
Shift-F5(or press the stop button in Visual Studio)
-
Create a file
manifest.ymlin the project root directory (not the solution root directory - the project is typically a subdirectory of the solution). Set its contents to the following:applications: - name: MicroserviceWorkshop random-route: true stack: windows buildpacks: - hwc_buildpack
-
Open developer powershell and make sure you are in the project root directory
-
cf push
During the push process, TAS will create a route for the app. Make note of the route - you can access the application at this URL once the application has started.
Once the application has started, you can access the application at the route created in TAS (something like https://microserviceworkshop-grumpy-elephant.cfapps.io)