A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.aws.amazon.com/sdk-for-net/v4/developer-guide/net-dg-v4.html below:

Migrating to version 4 of the AWS SDK for .NET

Migrating to version 4 of the AWS SDK for .NET

The AWS SDK for .NET version 4 (V4) has a significant number of breaking changes from version 3 (V3) of the SDK. This topic describes the breaking changes in version 4 and possible work that you might need to do to migrate your environment or code from V3. For additional information about other noteworthy changes in the SDK, see the following resources:

.NET Framework

The .NET Framework 3.5 target has been removed from V4 of the AWS SDK for .NET. As a result, the SDK no longer supports .NET Framework 3.5. This version of the SDK is compiled against .NET Framework 4.7.2 and runs in the .NET 4.0 runtime. For more information, see Supported platforms.

Value types

Properties that use value types in classes that are used for making requests and responses have been changed to use nullable value types. Properties with the following types have been changed:

For additional information about this change, see the blog post Preview 1 of AWS SDK for .NET V4.

Collections

Properties that use collections in classes that are used for making requests and responses now default to null. As a result, your code needs to verify that a collection isn't null before trying to use it. For example:

var sqsClient = new AmazonSQSClient();
var listResponse = await sqsClient.ListQueuesAsync(new ListQueuesRequest());
if (listResponse.QueueUrls != null)
{
    foreach (string qUrl in listResponse.QueueUrls)
    {
        // Perform operations on each queue such as displaying all the attributes.
    }
}

The V3 behavior of initializing collections can be restored by setting Amazon.AWSConfigs.InitializeCollections to true. This property also exists in V3 for users who want to try this behavior change before upgrading to V4.

For additional information about this change, see the blog post Preview 1 of AWS SDK for .NET V4.

AWS Security Token Service (STS) Changes related to ClientConfig

The Amazon.Runtime.ClientConfig class is the base class of service client configuration classes like AmazonS3Config. The following changes were made to this base class.

The AWSSDK.Extensions.NETCore.Setup NuGet package

The AWSSDK.Extensions.NETCore.Setup NuGet package has been updated to alleviate issues that were present in V3 of the SDK as well as to make the package safe for Native AOT. These changes are summarized below. For detailed information see PR 3353 in the aws-sdk-net repository on GitHub.

For additional information in this guide about this package, see AWSSDK.Extensions.NETCore.Setup and IConfiguration. The source code for this package is on GitHub at https://github.com/aws/aws-sdk-net/tree/main/extensions/src/AWSSDK.Extensions.NETCore.Setup.

CookieSigner and UrlSigner

The CookieSigner and UrlSigner extensions for Amazon CloudFront have been moved to a separate extension package called AWSSDK.Extensions.CloudFront.Signers. This change is to support OpenSSL 3 and take a dependency on BouncyCastle.Cryptography.

The source code for this package is on GitHub at https://github.com/aws/aws-sdk-net/tree/main/extensions/src/AWSSDK.Extensions.CloudFront.Signers.

DateTime versus UTC DateTime

Some V3 classes have a DateTime property that's marked as "deprecated" or "obsolete", as well as an alternative UTC DateTime property. In these classes, the obsolete DateTime property has been removed, and the name of the UTC DateTime property has been changed to the original name of the DateTime property.

The following are some examples of classes for which this change has been implemented.

This change might lead to offset times if an application is using the original, obsolete DateTime property. A compile time error will occur for code that uses the UTC DateTime property.

DateTime parsing

The DateTimeUnmarshaller class has been updated. This class had been parsing and returning DateTime strings as local time. In some cases, these values were being converted back to UTC due to a prior update, but not always. Now, DateTime strings that are unmarshalled are assumed to be UTC and will be specified and unmarshalled as UTC. This update includes the following behavior changes.

Certain timestamp properties that are based on the DateTime class were being parsed into local times. These included response unmarshallers for timestamps and list timestamps for formats TimestampFormat.ISO8601 and TimestampFormat.RFC822. DateTime parsing has been updated to return UTC times instead.

ConvertFromUnixEpochSeconds and ConvertFromUnixEpochMilliseconds

The ConvertFromUnixEpochSeconds and ConvertFromUnixEpochMilliseconds methods, which convert Unix epoch seconds to a DateTime structure, were returning the Unix Epoch time as a local time instead of a UTC time. These methods now return UTC time.

Logging

The way in which you enable logging in the SDK has been updated for V4. Logging to the console and system diagnostics works the same as V3; that is, by setting the LoggingConfig.LogTo property of the AWSConfigs class to either LoggingOptions.Console or LoggingOptions.SystemDiagnostics. The LoggingOptions option for log4net has been removed along with the SDK's internal logic for using reflection to attach to an in-memory instance of log4net.

To include the SDK's logging into a logging framework, a separate adaptor package is used to connect the SDK with the logging framework. Use the AWSSDK.Extensions.Logging.Log4NetAdaptor package for log4net and the AWSSDK.Extensions.Logging.ILoggerAdaptor package for Microsoft.Extensions.Logging. The following code examples show you how to configure logging in these two cases.

Add the AWSSDK.Extensions.Logging.Log4NetAdaptor NuGet package and call the static ConfigureAWSSDKLogging method from Log4NetAWSExtensions.

using Amazon.DynamoDBv2;
using Amazon.Extensions.Logging.Log4NetAdaptor;
using log4net;

[assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config")]

Log4NetAWSExtensions.ConfigureAWSSDKLogging();
var logger = LogManager.GetLogger(typeof(Program));

Add the AWSSDK.Extensions.Logging.ILoggerAdaptor NuGet package and call the ConfigureAWSSDKLogging extension method from the ILoggerFactory interface.

var builder = WebApplication.CreateBuilder(args);

var app = builder.Build();

app.Services.GetRequiredService<ILoggerFactory>()
    .ConfigureAWSSDKLogging();
Support for HTTP 2

Support for HTTP 2 has been added to enable bi-directional streaming. For more information see Support for HTTP 2.

Single sign-on

The default value of the SupportsGettingNewToken property of the SSOAWSCredentialsOptions class has been changed from true to false. If you have applications that use the SSOAWSCredentials class to obtain SSO credentials, you might need to set the Options.SupportsGettingNewToken property to true. For examples of this configuration, see the code examples in Tutorial for SSO using only .NET applications. For additional information, see PR 3737 in the aws-sdk-net GitHub repository.

Changes specific to DynamoDB

The following changes are specific to Amazon DynamoDB. Many of them are breaking changes.

For additional information about changes to DynamoDB in V4 of the AWS SDK for .NET, see the blog post Preview 4 of AWS SDK for .NET V4.

V4 changes in the SDK for DynamoDB address some issues around testability, but primarily center around the high-level libraries:

For detailed information about these programming modes, see DynamoDB in this guide.

Document Model: Updated exception for mocked IAmazonDynamoDB interface

In the document model prior to V4 of the SDK, if a Table was initialized with a mocked IAmazonDynamoDB interface, it would return NullReferenceException. V4 of the SDK returns InvalidOperationException instead. Async Table methods should work with a mocked client but you might still see exceptions when calling synchronous methods from .NET/Core/Standard.

For more information about this change, see PR 3388 on GitHub.

Document Model: FromJson and ToJson methods

The FromJson and ToJson methods of the Document class now use System.Text.Json instead of LitJson for serialization, and LitJson has been removed from V4 of the SDK. A benefit of using System.Text.Json is that this parser supports using the .NET Decimal type, which supports higher precision for numeric floating point properties.

Object Persistence Model: The DynamoDBOperationConfig class

In the object persistence model, the following changes have been made to the shared DynamoDBOperationConfig class:

Object Persistence Model: Polymorphism

The DynamoDBPolymorphicTypeAttribute class was added to the object persistence model. This class enables support for serialization and deserialization of polymorphic types. For more information, see PR 3643 on GitHub.

Document Model and Object Persistence Model: Mockable operations

New operation-specific interfaces have been added that allow customers to mock DynamoDB operations. The factory methods on the IDynamoDBContext interface have been updated to return the new interfaces.

For more information about this change, see PR 3450 on GitHub.

Document Model and Object Persistence Model: Support for Native AOT

A limitation of Native AOT is support for nested .NET types. In some cases, these nested types might go unnoticed by the trimming component of the .NET compiler. In this case, you might receive an exception such as: "System.InvalidOperationException: Type <type> is unsupported, it cannot be instantiated."

You can work around this limitation by adding the DynamicDependency somewhere in the code path that informs the trimmer about the dependency on the sub-type. The constructor of the top-level .NET type being saved is a likely place. The following code example shows you how to use the DynamicDependency attribute:

[DynamoDBTable("TestTable")]
class TypeWithNestedTypeProperty
{
    [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(SubType))]
    public TypeWithNestedTypeProperty()
    {

    }

    [DynamoDBHashKey]
    public string Id { get; set; }
    public string Name { get; set; }

    public SubType SubType { get; set; }
}

class SubType
{
    public string SubName { get; set; }
}
DynamoDBStreams

DynamoDBStreams has been removed from the AWSSDK.DynamoDB NuGet package and is available in its own package, AWSSDK.DynamoDBStreams, and has its own namespace, Amazon.DynamoDBStreams.

Allow removal of the TableNamePrefix value

You can now remove the value of the TableNamePrefix property in the DynamoDBContextConfig class on the individual operation level. For more information about this change, see PR 3476 on GitHub.

RetrieveDateTimeInUtc property

For the DynamoDBContextConfig class, the default value of the RetrieveDateTimeInUtc property has been changed to true.

DynamoDBContextTableNamePrefix property

Removed the DynamoDBContextTableNamePrefix property from AWSConfigsDynamoDB class. Users should call AWSConfigsDynamoDB.Context.TableNamePrefix instead of

Changes specific to EC2

The following changes are specific to Amazon EC2. Most or all of them are breaking changes.

GetDecryptedPassword

The GetDecryptedPassword extension for Amazon EC2 has been moved to a separate extension package called AWSSDK.Extensions.EC2.DecryptPassword. This change is to support OpenSSL 3 and take a dependency on BouncyCastle.Cryptography.

The source code for this package is on GitHub at https://github.com/aws/aws-sdk-net/tree/main/extensions/src/AWSSDK.Extensions.EC2.DecryptPassword.

Support for Amazon EC2 IMDSv1

Support for Instance Metadata Service Version 1 (IMDSv1) has been removed. V4 of the SDK always uses Instance Metadata Service Version 2 (IMDSv2) when fetching credentials and other metadata from the IMDS. For more information about the IMDS, see Use the IMDS in the Amazon EC2 User Guide.

Programming elements that were changed or removed Changes specific to S3

The following changes are specific to Amazon S3. Most or all of them are breaking changes.

AWS Region us-east-1

Amazon S3 service clients configured for the us-east-1 Region can no longer access buckets in other Regions. Buckets must be accessed with S3 service clients configured for the Region the bucket is in.

For additional information about this change, see the blog post Preview 4 of AWS SDK for .NET V4.

S3 encryption client

The Amazon S3 encryption client, which is defined in the Amazon.S3.Encryption namespace, has been removed from the AWSSDK.S3 package. This client has been moved to its own package called Amazon.Extensions.S3.Encryption, and the documentation for it is at https://aws.github.io/amazon-s3-encryption-client-dotnet/api/Amazon.Extensions.S3.Encryption.html. For information about migration, see Amazon S3 Encryption Client Migration. For more information about S3 encryption, see Supported encryption algorithms in the Amazon S3 Encryption Client Developer Guide.

S3 tagging directive for CopyObject

The TaggingDirective property has been exposed as a public property of the CopyObjectRequest class, which is used by AmazonS3Client.CopyObject methods. This property corresponds to the Amazon S3 x-amz-tagging-directive parameter, as defined in the CopyObject action.

The tagging directive is no longer automatically set to COPY. If a developer doesn't specify a tagging directive, the S3 backend automatically assumes it is COPY, but if a developer explicitly sets the property to null, then the value isn't set at all.

The UseArnRegion property for S3 configuration

The UseArnRegion property of the Amazon.S3.AmazonS3Config class has been updated such that the AWS_S3_USE_ARN_REGION environment variable takes precedence over the s3_use_arn_region setting in the shared AWS config file. For more information about these variables and settings, see Settings reference in the AWS SDKs and Tools Reference Guide.

Leading slashes for the CopyObject and CopyPart methods

Leading slashes will no longer be trimmed for the Amazon S3 CopyObject and CopyPart methods. The DisableTrimmingLeadingSlash property has been removed from the CopyObjectRequest and CopyPartRequest classes.

The DoesS3BucketExist... methods

The obsolete DoesS3BucketExist and DoesS3BucketExistAsync methods have been removed from the AmazonS3Util class, which implements the ICoreAmazonS3 interface. These methods were removed because they always use HTTP. Use DoesS3BucketExistV2 and DoesS3BucketExistV2Async instead.

SDK always uses SigV4

Version 4 of the AWS SDK for .NET always uses AWS Signature Version 4 (SigV4) for signing requests. This change results in the following related changes:

The GetACL and PutACL methods

The GetACL and PutACL methods of the AmazonS3Client class have been marked as obsolete. To access the functionality of these methods, use the following new methods instead: GetBucketACL, PutBucketACL, GetObjectACL, and PutObjectACL.

Obsolete programming elements removed

A number of programming elements of the Amazon S3 implementation were removed from V4 of the SDK, including enumeration values, types, methods, namespaces, etc. These are listed below, if not already covered previously, along with potential steps that you can take to accommodate their removal.

Programming elements that were removed

A number of programming elements were removed from V4 of the SDK, including enumeration values, types, methods, namespaces, etc. These are listed below, if not already covered previously, along with potential steps that you can take to accommodate their removal.

The Amazon.Auth.AccessControlPolicy.ActionIdentifiers namespace

The Amazon.Auth.AccessControlPolicy.ActionIdentifiers namespace has been removed. This includes IAM action identifiers, which were defined in the IdentityandAccessManagementActionIdentifiers class. Code that uses these action identifiers should be changed to use string values of the action name.

For additional information, see Creating IAM managed policies from JSON and Overview of JSON policies in the IAM User Guide.

The ClientConfig class

The Amazon.Runtime.ClientConfig class is the base class of service client configuration classes like AmazonS3Config. The following programming elements have been removed from this class.

The Amazon.Runtime namespace

The Amazon.Runtime namespace was updated as follows:

BouncyCastle

The source copy of BouncyCastle has been removed from V4 of the SDK.

The StoredProfileSAMLCredentials class

The obsolete StoredProfileSAMLCredentials class in the Amazon.SecurityToken.SAML namespace has been removed. Use the FederatedAWSCredentials class in the Amazon.Runtime namespace instead.

The AWSSDKUtils class

The following methods have been removed from the AWSSDKUtils class: ResolveResourcePath, ProtectEncodedSlashUrlEncode, and ConvertToUnixEpochMilliSeconds.

The ProfileManager class

The obsolete ProfileManager class has been removed from the Amazon.Util namespace. Use the NetSDKCredentialsFile or SharedCredentialsFile class from the Amazon.Runtime.CredentialManagement namespace instead.

The AWSConfigs class

The following obsolete properties have been removed from the AWSConfigs class: Logging, ResponseLogging, and LogMetrics. Use the LoggingConfig property instead.

The ConditionFactory class

The method with the following signature has been removed from the ConditionFactory class: NewCondition(ConditionFactory.DateComparisonType, DateTime). Use the NewConditionUtc method instead.

Amazon CloudFront utilities

The obsolete Amazon.CloudFront.Util namespace and AmazonCloudFrontUtil class have been removed.

AWS IoT

In the ListPrincipalThingsResponse class, a legacy customization for a NextToken override has been removed in favor of pagination.

AWS Lambda

The following Invoke... methods of the AmazonLambdaClient class have been removed because the names were confusing.

Amazon SageMaker Runtime

Obsolete constructors for the PayloadPart class have been removed.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4