sebkeys
sebkeys

Reputation: 86

AWSSDK.Core requires AWS_ENABLE_ENDPOINT_DISCOVERY environment variable value

After upgrading to .net core 2.2, and upgrading to the latest AWS library versions, I encounter this runtime error during initialization:

[System.InvalidOperationException] The environment variable AWS_ENABLE_ENDPOINT_DISCOVERY was not set with a boolean value.

It looks like Amazon.Runtime.EnvironmentVariableAWSEndpointDiscoveryEnabled.EnvironmentVariableAWSEndpointDiscoveryEnabled() tries to read this Environment variable.

What is strange is that it only occurs when running (in Debug mode) multiple Web API projects at the same time, and not when running a single project by itself.

Additional information:

Upvotes: 1

Views: 1211

Answers (2)

maXer
maXer

Reputation: 196

If it's only you or some of your team members who see this error, check if Exception Settings -> CLR exceptions are turned on in Visual Studio.

If they are, untick the box.

Screenshot of Exception Settings panel in Visual Studio

Upvotes: 0

Emanuel Lima
Emanuel Lima

Reputation: 19

The error says that the variable has not been declared. So declare it. Works for me.

Try this:

Environment.SetEnvironmentVariable("AWS_ENABLE_ENDPOINT_DISCOVERY", "false");

The complete block (in my case):

Environment.SetEnvironmentVariable("AWS_ENABLE_ENDPOINT_DISCOVERY", "false");
var opt = Configuration.GetAWSOptions();
IAmazonS3 client = opt.CreateServiceClient<IAmazonS3>();

Upvotes: 1

Related Questions