Invoking a container asynchronously
Note
This feature is at the Preview stage.
Setting up asynchronous invocation
-
In the management console
, select the folder with your container. -
Select Serverless Containers.
-
Select the container whose revision you want to create.
-
Navigate to the Editor tab.
-
Under Asynchronous invocation:
- Enable asynchronous invocation.
- Specify a service account with the
serverless-containers.containerInvokerrole for asynchronous invocations.
-
Click Create revision.
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.
To set up asynchronous invocation, run the following command:
yc serverless container revision deploy \
--container-name <container_name> \
--image <Docker_image_URL> \
--service-account-id <service_account_ID> \
--async-service-account-id <ID_of_service_account_for_asynchronous_invocations>
Where:
--service-account-id: ID of the service account with theserverless-containers.editorrole or higher.--async-service-account-id: ID of the service account with theserverless-containers.containerInvokerrole for asynchronous invocations.
Result:
done (6s)
id: bba1r76l8f73********
container_id: bbado1g2mtqj********
created_at: "2025-09-08T12:03:32.797Z"
image:
image_url: cr.yandex/crpmfvcgnl26********/ubuntu:hello
image_digest: sha256:96ab2d89a82fcfc63e24b9ef26de8b3b11ed1043cec41d4359a8de8b********
resources:
memory: "134217728"
cores: "1"
core_fraction: "100"
execution_timeout: 3s
concurrency: "1"
service_account_id: ajelprpohp7r********
status: ACTIVE
log_options:
folder_id: b1g681qpemb4********
runtime:
http: {}
async_invocation_config:
service_account_id: ajeaim70pe1u********
With Terraform
Terraform is distributed under the Business Source License
For more information about the provider resources, see the relevant documentation on the Terraform
If you do not have Terraform yet, install it and configure the Yandex Cloud provider.
To set up asynchronous invocation:
-
Open the Terraform configuration file and add the
async_invocationsection to the container description:resource "yandex_serverless_container" "test-container" { name = "<container_name>" memory = "<RAM_size>" execution_timeout = "<execution_timeout>" service_account_id = "<service_account_ID>" image { url = <container_image_path> } async_invocation { service_account_id = "<service_account_ID>" } }Where:
-
async_invocation: Asynchronous invocation parameters:service_account_id: Service account with theserverless-containers.containerInvokerrole.
For more information about
yandex_serverless_containerproperties, see the relevant provider documentation. -
-
Apply the changes:
-
In the terminal, go to the directory where you edited the configuration file.
-
Make sure the configuration file is correct using this command:
terraform validateIf the configuration is correct, you will get this message:
Success! The configuration is valid. -
Run this command:
terraform planYou will see a detailed list of resources. No changes will be made at this step. If the configuration contains any errors, Terraform will show them.
-
Apply the changes:
terraform apply -
Type
yesand press Enter to confirm the changes.
-
You can check the container's update and settings using the management console
yc serverless serverless-container revision get <container_revision_ID>
To configure asynchronous invocation, use the deployRevision REST API method for the Container resource or the ContainerService/DeployRevision gRPC API call.
Invoke the container
When invoking the container over HTTP, specify the X-Ycf-Container-Integration-Type: async header.