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.
Updates a CloudFront function.
You can update a function's code or the comment that describes the function. You cannot update a function's name.
To update a function, you provide the function's name and version (ETag
value)
along with the updated function code. To get the name and version, you can use ListFunctions
and DescribeFunction
.
For .NET Core this operation is only available in asynchronous form. Please refer to UpdateFunctionAsync.
Namespace: Amazon.CloudFront
Assembly: AWSSDK.CloudFront.dll
Version: 3.x.y.z
public abstract UpdateFunctionResponse UpdateFunction( UpdateFunctionRequest request )
Container for the necessary parameters to execute the UpdateFunction service method.
Exception | Condition |
---|---|
FunctionSizeLimitExceededException | The function is too large. For more information, see Quotas (formerly known as limits) in the Amazon CloudFront Developer Guide. |
InvalidArgumentException | An argument is invalid. |
InvalidIfMatchVersionException | The If-Match version is missing or not valid. |
NoSuchFunctionExistsException | The function does not exist. |
PreconditionFailedException | The precondition in one or more of the request fields evaluated to false. |
UnsupportedOperationException | This operation is not supported in this region. |
Use the following command to update a function.
var client = new AmazonCloudFrontClient(); var response = client.UpdateFunction(new UpdateFunctionRequest { FunctionCode = new MemoryStream(function-code-changed.js), FunctionConfig = new FunctionConfig { Comment = "my-changed-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" }, IfMatch = "ETVPDKIKX0DER", Name = "my-function-name" }); string eTag = response.ETag; FunctionSummary functionSummary = response.FunctionSummary;
.NET Framework:
Supported in: 4.5, 4.0, 3.5