Skip to content

System.IO.IOException at Amazon.Util.Internal.SettingsManager.GetSettings CreateDirectory #3801

Open
@ductranit

Description

@ductranit

Describe the bug

I'm using AWS sdk on my azure function and got error System.IO.IOException handled at Amazon.Util.Internal.SettingsManager.GetSettings when trying to use AWS services in Azure Function.
The error is occurring in the AWS SDK while trying to access or create credential files on the file system, but azure function file system is read only.

Expected Behavior

SDK shouldn't read file/write system file if key/secret is provided.

Current Behavior

Got error

PublicKeyToken=31bf3856ad364e35: D:\a\_work\1\s\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs:306)
Inner exception System.TypeInitializationException handled at Amazon.Runtime.ClientConfig.get_RetryMode:
   at Amazon.Util.Internal.SettingsManager.GetSettings (AWSSDK.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=885c28607f98e604)
   at Amazon.Util.Internal.SettingsManager.TryGetObjectByProperty (AWSSDK.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=885c28607f98e604)
   at Amazon.Runtime.CredentialManagement.NetSDKCredentialsFile.TryGetProfile (AWSSDK.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=885c28607f98e604)
   at Amazon.Runtime.CredentialManagement.CredentialProfileStoreChain.TryGetProfile (AWSSDK.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=885c28607f98e604)
   at Amazon.Runtime.Internal.ProfileInternalConfiguration.Setup (AWSSDK.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=885c28607f98e604)
   at Amazon.Runtime.Internal.ProfileInternalConfiguration..ctor (AWSSDK.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=885c28607f98e604)
   at Amazon.Runtime.Internal.FallbackInternalConfigurationFactory.Reset (AWSSDK.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=885c28607f98e604)
   at Amazon.Runtime.Internal.FallbackInternalConfigurationFactory..cctor (AWSSDK.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=885c28607f98e604)
Inner exception System.IO.IOException handled at Amazon.Util.Internal.SettingsManager.GetSettings:
   at System.IO.FileSystem.CreateDirectory (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.IO.Directory.CreateDirectory (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Amazon.Runtime.Internal.Settings.PersistenceManager..cctor (AWSSDK.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=885c28607f98e604)

Reproduction Steps

Init SDK with this code

// Explicitly set credentials
                var awsCredentials = new BasicAWSCredentials(key, secret);

                // Configure AWS SDK to avoid file system access
                var cognitoConfig = new AmazonCognitoIdentityProviderConfig
                {
                    RegionEndpoint = RegionEndpoint.GetBySystemName(region),
                    IgnoreConfiguredEndpointUrls = true
                };

                var s3Config = new AmazonS3Config
                {
                    RegionEndpoint = RegionEndpoint.GetBySystemName(region),
                    IgnoreConfiguredEndpointUrls = true,
                };

                // Initialize clients with explicit credentials and config
                var provider = new AmazonCognitoIdentityProviderClient(awsCredentials, cognitoConfig);
                var amazonS3Client = new AmazonS3Client(awsCredentials, s3Config);

Possible Solution

Disable read/write on SettingsManager.GetSettings

AWS .NET SDK and/or Package version used

AWSSDK.S3 4.0.0.1
AWSSDK.CognitoIdentityProvider 4.0.0.1

Targeted .NET Platform

.NET 6.0

Operating System and version

windows 10

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions