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.

Container for the parameters to the Invoke operation. 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.

Inheritance Hierarchy

System.Object
  Amazon.Runtime.AmazonWebServiceRequest
    Amazon.Lambda.AmazonLambdaRequest
      Amazon.Lambda.Model.InvokeRequest

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

Syntax

C#
public class InvokeRequest : AmazonLambdaRequest
         IAmazonWebServiceRequest

The InvokeRequest type exposes the following members

Constructors

NameDescription
Public Method InvokeRequest()

Properties

NameTypeDescription
Public Property ClientContext System.String

Gets and sets the property ClientContext. When this property is set the ClientContextBase64 property is also set with a base64-encoded string containing the contents of ClientContext.

Using the ClientContext you can pass client-specific information to the Lambda function you are invoking. You can then process the client information in your Lambda function as you choose through the context variable. For an example of a ClientContext JSON, go to PutEvents in the Amazon Mobile Analytics API Reference and User Guide.

Public Property ClientContextBase64 System.String

Gets and sets the property ClientContextBase64.

Using the ClientContext you can pass client-specific information to the Lambda function you are invoking. You can then process the client information in your Lambda function as you choose through the context variable. For an example of a ClientContext JSON, see PutEvents in the Amazon Mobile Analytics API Reference and User Guide.

The ClientContext JSON must be base64-encoded.

Public Property FunctionName System.String

Gets and sets the property FunctionName.

The Lambda function name.

You can specify a function name (for example, Thumbnail) or you can specify Amazon Resource Name (ARN) of the function (for example, arn:aws:lambda:us-west-2:account-id:function:ThumbNail). AWS Lambda also allows you to specify a partial ARN (for example, account-id:Thumbnail). Note that the length constraint applies only to the ARN. If you specify only the function name, it is limited to 64 characters in length.

Public Property InvocationType Amazon.Lambda.InvocationType

Gets and sets the property InvocationType.

By default, the Invoke API assumes RequestResponse invocation type. You can optionally request asynchronous execution by specifying Event as the InvocationType. You can also use this parameter to request AWS Lambda to not execute the function but do some verification, such as if the caller is authorized to invoke the function and if the inputs are valid. You request this by specifying DryRun as the InvocationType. This is useful in a cross-account scenario when you want to verify access to a function without running it.

Public Property LogType Amazon.Lambda.LogType

Gets and sets the property LogType.

You can set this optional parameter to Tail in the request only if you specify the InvocationType parameter with value RequestResponse. In this case, AWS Lambda returns the base64-encoded last 4 KB of log data produced by your Lambda function in the x-amz-log-result header.

Public Property Payload System.String

Gets and sets the property Payload. When this property is set the PayloadStream property is also set with a MemoryStream containing the contents of Payload.

JSON that you want to provide to your cloud function as input.

Public Property PayloadStream System.IO.MemoryStream

Gets and sets the property PayloadStream.

JSON that you want to provide to your Lambda function as input.

Public Property Qualifier System.String

Gets and sets the property Qualifier.

You can use this optional parameter to specify a Lambda function version or alias name. If you specify a function version, the API uses the qualified function ARN to invoke a specific Lambda function. If you specify an alias name, the API uses the alias ARN to invoke the Lambda function version to which the alias points.

If you don't provide this parameter, then the API uses unqualified function ARN which results in invocation of the $LATEST version.

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 Standard:
Supported in: 1.3

.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