Skip to main content

Aliyun FunctionCompute SDK

Project description

Aliyun FunctionCompute Python SDK

.. image::
.. image::
.. image::


The SDK of this version is dependent on the third-party HTTP library `requests <>`_.

Running environment

Python 2.7, Python 3.6


Install the official release version through PIP (taking Linux as an example):

.. code-block:: bash

$ pip install aliyun-fc

You can also install the unzipped installer package directly:

.. code-block:: bash

$ sudo python install

Getting started

.. code-block:: python

# -*- coding: utf-8 -*-

import fc

# To know the endpoint and access key id/secret info, please refer to:
client = fc.Client(
endpoint='<Your Endpoint>',
accessKeyID='<Your AccessKeyID>',
accessKeySecret='<Your AccessKeySecret>')

# Create service.

# Create function.
# the current directory has a file ( which has a function of myhandler)
client.create_function('service_name', 'function_name', 'main.my_handler', codeZipFile = '')

# Invoke function synchronously.
client.invoke_function('service_name', 'function_name')

# Invoke a function with a input parameter.
client.invoke_function('service_name', 'function_name', payload=bytes('hello_world'))

# Read a image and invoke a function with the file data as input parameter.
src = open('src_image_file_path', 'rb') # Note: please open it as binary.
r = client.invoke_function('service_name', 'function_name', payload=src)
# save the result as the output image.
dst = open('dst_image_file_path', 'wb')

# Invoke function asynchronously.
client.async_invoke_function('service_name', 'function_name')

# List services.

# List functions with prefix and limit.
client.list_functions('service_name', prefix='the_prefix', limit=10)

# Delete service.

# Delete function.
client.delete_function('service_name', 'function_name')


To run the tests, please set the access key id/secret, endpoint as environment variables.
Take the Linux system for example:

.. code-block:: bash

$ export ENDPOINT=<endpoint>
$ export ACCESS_KEY_ID=<AccessKeyId>
$ export ACCESS_KEY_SECRET=<AccessKeySecret>
$ export STS_TOKEN=<roleARN>

Run the test in the following method:

.. code-block:: bash

$ nosetests # First install nose

More resources
- `Aliyun FunctionCompute docs <>`_

Contacting us
- `Links <>`_

- `MIT <>`_

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aliyun-fc-0.6.tar.gz (9.2 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page