Skip to Content
Technical Articles
Author's profile photo Tia Xu

[SAP Cloud Platform on Alibaba Cloud series] Develop Python App with Authentication and Authorization in Cloud Foundry – Part 1

With the landing of SAP Cloud Platform on Alibaba Cloud, more and more stakeholders have need to get onboard or have a try on it. Thus, the main purpose of writing this series of blog posts is to emphasize the minor but important differences when developing on Alibaba Cloud, so that readers can consume it more smoothly.

This topic Develop Python App with Authentication and Authorization in Cloud Foundry will guide you through creating a Python application, setting up authentication checks and authorization checks in Cloud Foundry (for ease of reading “CF).

Since this is a large topic, in order to give you a better reading experience, I would like to divide it into 3 parts:

Part 1: Create and Deploy a Python Application

Part 2: Authentication Checks in Python Application

Part 3: Authorization Checks in Python Application

This blog post is Part 1.

More details can be found here: Developing Python in the Cloud Foundry Environment


Step 1: Create and Deploy a Python Application

1. Log on to Cloud Foundry

Open Cloud Platform Cockpit, navigate to your subaccount, find the corresponding API Endpoint:

Log on to Cloud Foundry with the API Endpoint you got by executing the following command:

cf login -a <api-endpoint>

Enter your Email and Password which are consistent with your Cockpit’s.

Choose your org and space.

Check your target by executing CF command:

2. Create a Python Project

Create a new directory named python-with-xsuaa.

Create a manifest.yml file under the python-with-xsuaa directory with the following content:

- name: myapp
  host: <host>
  path: .
  domain: <custom-domain>
  memory: 128M
  command: python

Replace <host> with a unique name, so it does not clash with all other deployed applications. Replace <custom-domain> with the domain available in your org, you can check it by executing CF command `cf domains`. The URL of your application will be: <host.custom-domain>.

For example:

- name: myapp
  host: myapp-ixxxxxx
  path: .
  memory: 128M
  command: python

Specify the Python runtime version your application by creating a runtime.txt file, for example:


Buildpack only supports the stable Python versions, which are listed in the Python buildpack release notes.

The application will be a web server utilizing the Flask web framework. Specify Flask as an application dependency by creating a requirements.txt file with the following content:


Available Flask versions: Flask Release history.

Create a file, which will contain the following application logic:

import os
from flask import Flask
app = Flask(__name__)

port = int(os.environ.get('PORT', 3000))
def hello():
    return "Hello World"

if __name__ == '__main__':'', port=port)

This is a simple server, which will return a “Hello World” when requested.

3. Vendor dependencies

In case you will get problem of network in China when downloading dependencies during the process of deploying, you’d better deploy applications as self-contained, which means carry all of their dependencies so that the staging process does not require any network calls.

The Python buildpack provides a mechanism for that – applications can vendor their dependencies by creating a vendor folder in their root directory and execute the following command to download dependencies in it:

pip download -d vendor -r requirements.txt --platform manylinux1_x86_64 --only-binary=:all:


4. Deploy the application onto Cloud Foundry

Execute the following CF command in the root of python-with-xsuaa directory:

cf push

cf push is always executed in the same directory, where the manifest.yml is located.

If your app deployment fails, you can troubleshoot by checking its logs:

cf logs myapp --recent

5. Access the application

When the staging and deployment steps are complete, you can check the state and URL of your application through Cockpit or CF command:

cf apps

Open a Firefox Developer Edition browser window and enter the URL of the application, you should see the message Hello World.


This blog post shared how to create and deploy Python app onto SAP Cloud Platform Alibaba Cloud.

Special point for Alibaba Cloud:

The most important point varies from Alibaba Cloud to Public Cloud is application domain. On the SAP Public Cloud, like AWS, Azure, etc, they will provide a public shared domain to developers. However, this kind of shared domain is not supported due to compliance in China, so in order to deploy apps onto Alibaba Cloud, developers should create a custom domain by themselves. More details on how to get your own custom domain can be found here: Use custom domain in SAP Cloud Platform on Alibaba Cloud

The next two parts will be published later, it will not take a long time, let’s stay tuned.

Part 2: Authentication Checks in Python Application

Part 3: Authorization Checks in Python Application

If you would like to get more step-by-step hands-ons on SAP Cloud Platform Alibaba Cloud, please follow me!

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Yogananda Muthaiah
      Yogananda Muthaiah

      Its really cool to do and think out of the box solution.

      I eagerly waiting for Part 2 and 3 🙂

      Author's profile photo Subhadip Mandal
      Subhadip Mandal

      Hi Tia Xu,

      This is really cool.

      I just observed, we can access the deployed apps pretty much from any browser (Chrome, IE, normal Firefox edition), not sure if Firefox developer edition has specific support for AliCloud.

      Awaiting rest of the parts of the series.

      Author's profile photo Arushi Kulkarni
      Arushi Kulkarni

      Thank you so much for sharing all this wonderful info with the how-to's!!!! It is so appreciated!!!” “You always have good humor in your posts. So much fun and easy to read!

      Python training in Nashik