App Configuration with Cloud Foundry
This tutorial takes you through setting up a .NET Core application that retrieves environment variable values from Cloud Foundry.
First, create a .NET Core WebAPI that retrieves (configuration) environment variables from Cloud Foundry.
- Create a new ASP.NET Core WebAPI app with the Steeltoe Initializr
- Name the project "CloudFoundryExample"
- Add the "Cloud Foundry" dependency
- Click Generate Project to download a zip containing the new project
Run the application.
Publish the application locally using the .NET cli. The following command will create a publish folder automatically
dotnet publish -o .\publish <PATH_TO>\CloudFoundryExample.csproj
Create manifest.yml in the same folder as CloudFoundryExample.csproj
--- applications: - name: Cloud_Foundry_Example buildpacks: - dotnet_core_buildpack stack: cflinuxfs3
With yaml files indention and line endings matter. Use an IDE like VS Code to confirm spacing and that line endings are set to
LF(not the Windows default
Push the app to Cloud Foundry
cf push -f <PATH_TO>\manifest.yml -p .\publish
Navigate to the application endpoint
If all things go well you should see an output of configuration values provided by the Cloud Foundry platform