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 CloudFront function.
To create a function, you provide the function code and some configuration information about the function. The response contains an Amazon Resource Name (ARN) that uniquely identifies the function.
When you create a function, it's in the DEVELOPMENT
stage. In this stage, you
can test the function with TestFunction
, and update it with UpdateFunction
.
When you're ready to use your function with a CloudFront distribution, use PublishFunction
to copy the function from the DEVELOPMENT
stage to LIVE
. When it's live,
you can attach the function to a distribution's cache behavior, using the function's
ARN.
Namespace: Amazon.CloudFront.Model
Assembly: AWSSDK.CloudFront.dll
Version: 3.x.y.z
public class CreateFunctionRequest : AmazonCloudFrontRequest IAmazonWebServiceRequest
The CreateFunctionRequest type exposes the following members
Name | Description | |
---|---|---|
CreateFunctionRequest() |
Name | Type | Description | |
---|---|---|---|
FunctionCode | System.IO.MemoryStream |
Gets and sets the property FunctionCode. The function code. For more information about writing a CloudFront function, see Writing function code for CloudFront Functions in the Amazon CloudFront Developer Guide. |
|
FunctionConfig | Amazon.CloudFront.Model.FunctionConfig |
Gets and sets the property FunctionConfig. Configuration information about the function, including an optional comment and the function's runtime. |
|
Name | System.String |
Gets and sets the property Name. A name to identify the function. |
Use the following command to create a function.
var client = new AmazonCloudFrontClient(); var response = client.CreateFunction(new CreateFunctionRequest { FunctionCode = new MemoryStream(function-code.js), FunctionConfig = new FunctionConfig { Comment = "my-function-comment", KeyValueStoreAssociations = new KeyValueStoreAssociations { Items = new List<KeyValueStoreAssociation> { new KeyValueStoreAssociation { KeyValueStoreARN = "arn:aws:cloudfront::123456789012:key-value-store/54947df8-0e9e-4471-a2f9-9af509fb5889" } }, Quantity = 1 }, Runtime = "cloudfront-js-2.0" }, Name = "my-function-name" }); string eTag = response.ETag; FunctionSummary functionSummary = response.FunctionSummary; string location = response.Location;
.NET Core App:
Supported in: 3.1
.NET Standard:
Supported in: 2.0
.NET Framework:
Supported in: 4.5, 4.0, 3.5