AWS SDK Version 3 for .NET
API Reference

AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

Invokes a specific Lambda function. For an example, see Create the Lambda Function and Test It Manually.

If you are using the versioning feature, you can invoke the specific function version by providing function version or alias name that is pointing to the function version using the Qualifier parameter in the request. If you don't provide the Qualifier parameter, the $LATEST version of the Lambda function is invoked. Invocations occur at least once in response to an event and functions must be idempotent to handle this. For information about the versioning feature, see AWS Lambda Function Versioning and Aliases.

This operation requires permission for the lambda:InvokeFunction action.

Note:

For PCL and Unity this operation is only available in asynchronous form. Please refer to InvokeAsync.

Namespace: Amazon.Lambda
Assembly: AWSSDK.Lambda.dll
Version: 3.x.y.z

Syntax

C#
public virtual InvokeResponse Invoke(
         InvokeRequest request
)
Parameters
request
Type: Amazon.Lambda.Model.InvokeRequest

Container for the necessary parameters to execute the Invoke service method.

Return Value
The response from the Invoke service method, as returned by Lambda.

Exceptions

ExceptionCondition
EC2AccessDeniedException
EC2ThrottledException AWS Lambda was throttled by Amazon EC2 during Lambda function initialization using the execution role provided for the Lambda function.
EC2UnexpectedException AWS Lambda received an unexpected EC2 client exception while setting up for the Lambda function.
ENILimitReachedException AWS Lambda was not able to create an Elastic Network Interface (ENI) in the VPC, specified as part of Lambda function configuration, because the limit for network interfaces has been reached.
InvalidParameterValueException One of the parameters in the request is invalid. For example, if you provided an IAM role for AWS Lambda to assume in the CreateFunction or the UpdateFunctionConfiguration API, that AWS Lambda is unable to assume you will get this exception. You will also get this exception if you have selected a deprecated runtime, such as Node v0.10.42.
InvalidRequestContentException The request body could not be parsed as JSON.
InvalidRuntimeException The runtime or runtime version specified is not supported.
InvalidSecurityGroupIDException The Security Group ID provided in the Lambda function VPC configuration is invalid.
InvalidSubnetIDException The Subnet ID provided in the Lambda function VPC configuration is invalid.
InvalidZipFileException AWS Lambda could not unzip the function zip file.
KMSAccessDeniedException Lambda was unable to decrypt the environment variables because KMS access was denied. Check the Lambda function's KMS permissions.
KMSDisabledException Lambda was unable to decrypt the environment variables because the KMS key used is disabled. Check the Lambda function's KMS key settings.
KMSInvalidStateException Lambda was unable to decrypt the environment variables because the KMS key used is in an invalid state for Decrypt. Check the function's KMS key settings.
KMSNotFoundException Lambda was unable to decrypt the environment variables because the KMS key was not found. Check the function's KMS key settings.
RequestTooLargeException The request payload exceeded the Invoke request body JSON input limit. For more information, see Limits.
ResourceNotFoundException The resource (for example, a Lambda function or access policy statement) specified in the request does not exist.
ServiceException The AWS Lambda service encountered an internal error.
SubnetIPAddressLimitReachedException AWS Lambda was not able to set up VPC access for the Lambda function because one or more configured subnets has no available IP addresses.
TooManyRequestsException
UnsupportedMediaTypeException The content type of the Invoke request body is not JSON.

Examples

This operation invokes a Lambda function

To invoke a Lambda function


var response = client.Invoke(new InvokeRequest 
{
    FunctionName = "MyFunction",
    InvocationType = "Event",
    LogType = "Tail",
    Qualifier = "1"
});

string functionError = response.FunctionError;
string logResult = response.LogResult;
MemoryStream payload = response.Payload;
integer statusCode = response.StatusCode;

            

Version Information

.NET Framework:
Supported in: 4.5, 4.0, 3.5

Portable Class Library:
Supported in: Windows Store Apps
Supported in: Windows Phone 8.1
Supported in: Xamarin Android
Supported in: Xamarin iOS (Unified)
Supported in: Xamarin.Forms

Unity:
Supported Versions: 4.6 and above
Supported Platforms: Android, iOS, Standalone

See Also