_The _ function allows you to put your code in Yandex.Cloud and run it on request or trigger.
Once created, a function only contains its own metadata, including its name, description, and unique ID. To start using the function, you need to create a function version. You can execute functions using the HTTP API or CLI.
Before writing your functions, review the programming model.
Versions contain the function code, run parameters, and all necessary dependencies. You can work with different versions of the same function during different stages of development (for example, a version under development or alpha and beta versions). When making changes, new versions are always created with a tag (by default,
$latest). It doesn't matter if you uploaded a completely new code or made only minor changes.
Code upload format
To create a version, you can use the code editor or upload your code and its dependencies in one of the formats described in the table below. After you create a function, you no longer need the object with the code. You can delete it from storage.
|Format||Management console||YC CLI|
|ZIP archive from your PC|
|ZIP archive from S3, specifying the bucket and object|
For more information about how to create versions, see Creating a function version.
Tags are used for calling a particular version of a function. Each tag must be unique within the function. One version may have multiple tags.
When creating a new version, it's assigned the
$latest tag by default.
Cloud Functions supports different programming languages. Regardless of the language you choose, you should write your code based on the programming model accepted in the service. It contains elements that the user needs to implement as well as mechanisms that are already implemented on the service side and can be used when necessary.
To enable a function call, describe a handler in it. It's defined when writing code and handles the data received by calling the necessary functions and methods in the code. The handler should accept the data that comes with function requests and the context passed by Cloud Functions.
Context lets your function code interact with Cloud Functions. For example, the function can use it to find how much time is left before Cloud Functions completes its execution.
Incoming requests are processed by the function one at a time. If the function is called faster than one instance can process the request, the service scales the function by running additional function instances. This ensures concurrent request processing.
To let your function process multiple requests simultaneously, use asynchronous code execution provided by the runtime environment.
To report a function execution error to the service, handle errors using exceptions.
The service logs the execution of functions. However, if necessary, you can implement additional logging in your function code.