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 CreateFunction operation. Creates a new Lambda function. The function metadata is created from the request parameters, and the code for the function is provided by a .zip file in the request body. If the function name already exists, the operation will fail. Note that the function name is case-sensitive.

If you are using versioning, you can also publish a version of the Lambda function you are creating using the Publish parameter. For more information about versioning, see AWS Lambda Function Versioning and Aliases.

This operation requires permission for the lambda:CreateFunction action.

Inheritance Hierarchy


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


public class CreateFunctionRequest : AmazonLambdaRequest

The CreateFunctionRequest type exposes the following members


Public Method CreateFunctionRequest()


Public Property Code Amazon.Lambda.Model.FunctionCode

Gets and sets the property Code.

The code for the Lambda function.

Public Property DeadLetterConfig Amazon.Lambda.Model.DeadLetterConfig

Gets and sets the property DeadLetterConfig.

The parent object that contains the target ARN (Amazon Resource Name) of an Amazon SQS queue or Amazon SNS topic. For more information, see dlq.

Public Property Description System.String

Gets and sets the property Description.

A short, user-defined function description. Lambda does not use this value. Assign a meaningful description as you see fit.

Public Property Environment Amazon.Lambda.Model.Environment

Gets and sets the property Environment.

Public Property FunctionName System.String

Gets and sets the property FunctionName.

The name you want to assign to the function you are uploading. The function names appear in the console and are returned in the ListFunctions API. Function names are used to specify functions to other AWS Lambda API operations, such as Invoke. 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 Handler System.String

Gets and sets the property Handler.

The function within your code that Lambda calls to begin execution. For Node.js, it is the module-name.export value in your function. For Java, it can be package.class-name::handler or package.class-name. For more information, see Lambda Function Handler (Java).

Public Property KMSKeyArn System.String

Gets and sets the property KMSKeyArn.

The Amazon Resource Name (ARN) of the KMS key used to encrypt your function's environment variables. If not provided, AWS Lambda will use a default service key.

Public Property MemorySize System.Int32

Gets and sets the property MemorySize.

The amount of memory, in MB, your Lambda function is given. Lambda uses this memory size to infer the amount of CPU and memory allocated to your function. Your function use-case determines your CPU and memory requirements. For example, a database operation might need less memory compared to an image processing function. The default value is 128 MB. The value must be a multiple of 64 MB.

Public Property Publish System.Boolean

Gets and sets the property Publish.

This boolean parameter can be used to request AWS Lambda to create the Lambda function and publish a version as an atomic operation.

Public Property Role System.String

Gets and sets the property Role.

The Amazon Resource Name (ARN) of the IAM role that Lambda assumes when it executes your function to access any other Amazon Web Services (AWS) resources. For more information, see AWS Lambda: How it Works.

Public Property Runtime Amazon.Lambda.Runtime

Gets and sets the property Runtime.

The runtime environment for the Lambda function you are uploading.

To use the Python runtime v3.6, set the value to "python3.6". To use the Python runtime v2.7, set the value to "python2.7". To use the Node.js runtime v6.10, set the value to "nodejs6.10". To use the Node.js runtime v4.3, set the value to "nodejs4.3". To use the .NET Core runtime v1.0, set the value to "dotnetcore1.0". To use the .NET Core runtime v2.0, set the value to "dotnetcore2.0".

Node v0.10.42 is currently marked as deprecated. You must migrate existing functions to the newer Node.js runtime versions available on AWS Lambda (nodejs4.3 or nodejs6.10) as soon as possible. Failure to do so will result in an invalid parameter error being returned. Note that you will have to follow this procedure for each region that contains functions written in the Node v0.10.42 runtime.

Public Property StreamTransferProgress System.EventHandler<Amazon.Runtime.StreamTransferProgressArgs>

Attach a callback that will be called as data is being sent to the AWS Service.

Public Property Tags System.Collections.Generic.Dictionary<System.String, System.String>

Gets and sets the property Tags.

The list of tags (key-value pairs) assigned to the new function. For more information, see Tagging Lambda Functions in the AWS Lambda Developer Guide.

Public Property Timeout System.Int32

Gets and sets the property Timeout.

The function execution time at which Lambda should terminate the function. Because the execution time has cost implications, we recommend you set this value based on your expected execution time. The default is 3 seconds.

Public Property TracingConfig Amazon.Lambda.Model.TracingConfig

Gets and sets the property TracingConfig.

The parent object that contains your function's tracing settings.

Public Property VpcConfig Amazon.Lambda.Model.VpcConfig

Gets and sets the property VpcConfig.

If your Lambda function accesses resources in a VPC, you provide this parameter identifying the list of security group IDs and subnet IDs. These must belong to the same VPC. You must provide at least one security group and one subnet ID.


This example creates a Lambda function.


var response = client.CreateFunction(new CreateFunctionRequest 
    Code = new FunctionCode {  },
    Description = "",
    FunctionName = "MyFunction",
    Handler = "souce_file.handler_name", // is of the form of the name of your source file and then name of your function handler
    MemorySize = 128,
    Publish = true,
    Role = "arn:aws:iam::123456789012:role/service-role/role-name", // replace with the actual arn of the execution role you created
    Runtime = "nodejs4.3",
    Timeout = 15,
    VpcConfig = new VpcConfig {  }

string codeSha256 = response.CodeSha256;
long codeSize = response.CodeSize;
string description = response.Description;
string functionArn = response.FunctionArn;
string functionName = response.FunctionName;
string handler = response.Handler;
string lastModified = response.LastModified;
integer memorySize = response.MemorySize;
string role = response.Role;
string runtime = response.Runtime;
integer timeout = response.Timeout;
string version = response.Version;
VpcConfigDetail vpcConfig = response.VpcConfig;


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

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