Lambda An error occurred while attempting to execute your code - c#

I am using AWS Lambda toolkit for C#. When I am publishing AWS Lambda directly it is working fine on AWS. But when I am trying to make a zip file by using publish and then making the zip of all DLL under bin\Release\netcoreapp1.0. and trying to run.
Then it is giving an error:
{
"errorType": "LambdaException",
"errorMessage": "An error occurred while attempting to execute your code."
}
In configuration Handler name is correct.
What can be the issue?

Have you tried packing the zip using the dotnet cli command?
Try this in your project folder: dotnet lambda package -o .\lambda.zip
It should create a lambda.zip file which you can try to upload.

Related

Can not create xUnit Test Project with dotnet CLI

I'm trying to create a xUnit Test Project with dotnet CLI:
dotnet new xunit -o Tests
And then I get these errors:
Failed to download package 'coverlet.collector.3.1.2' from
'https://api.nuget.org/v3-flatcontainer/coverlet.collector
/3.1.2/coverlet.collector.3.1.2.nupkg'. The download of
'https://api.nuget.org/v3-flatcontainer/coverlet.collector/3.1.2/coverlet.collector.3.1.2.nupkg'
time d out because no data was received for 60000ms.
Exception of type 'System.TimeoutException' was thrown. Failed to download package 'Microsoft.CodeCoverage.17.3.2' from
'https://api.nuget.org/v3-flatcontainer/microsoft.cod
ecoverage/17.3.2/microsoft.codecoverage.17.3.2.nupkg'. The download
of
'https://api.nuget.org/v3-flatcontainer/microsoft.codecoverage/17.3.2/microsoft.codecoverage.17.3.2.n
upkg' timed out because no data was received for 60000ms.
Exception of type 'System.TimeoutException' was thrown. Failed to download package 'xunit.extensibility.core.2.4.2' from
'https://api.nuget.org/v3-flatcontainer/xunit.extens
ibility.core/2.4.2/xunit.extensibility.core.2.4.2.nupkg'. The
download of
'https://api.nuget.org/v3-flatcontainer/xunit.extensibility.core/2.4.2/xunit.extensibility.core.2.4.2
.nupkg' timed out because no data was received for 60000ms.
Exception of type 'System.TimeoutException' was thrown.
My Internet bandwidth is still good. I tried to create it with Visual Studio but still get the same error. What can I do?

The type initializer for 'Amazon.AWSConfigs' threw an exception

I'm trying to log in using AWS Cognito by running the app after building it in Unity.
I couldn't log in properly, and when I tried debugging, I found the phrase "The type initializer for Amazon.AWSConfigs' thread an exception."
This error occurs when executing the following code:
Amazon.CognitoIdentityProvider.AmazonCognitoIdentityProviderClient provider =
new Amazon.CognitoIdentityProvider.AmazonCognitoIdentityProviderClient(new Amazon.Runtime.AnonymousAWSCredentials(), regionTable[REGION]);
The app itself is built normally, but there seems to be a problem with logging in using AWS.
(I found this error in the PC and oculus environment.)
Some of the answers told me to modify the Config file. But I couldn't find the Config file. The location of this file was also unknown.
I found this answer "https://github.com/aws/aws-sdk-net/issues/310" but I couldn't apply this for me.
I found this Document "https://docs.unity3d.com/kr/2021.1/Manual/upm-config.html#upmconfig" but the Config file didn't exist in this path. My environment is Mac.
additionally,
I use AWS SDK called aws-sdk-net45-3.7.193.0.
UnityInitializer.AttachToGameObject(this.gameObject);
Amazon.AWSConfigs.HttpClient = Amazon.AWSConfigs.HttpClientOption.UnityWebRequest;
In this code, my Project Cannot understand UnityInitializer, HttpClient, and HttpClientOption.
What else changes are needed in order to mitigate the above issue.
I solved this problem.
The problem was that I was using IL2CPP as Script backend.
Simply using Script backend as Mono is one way. But my project had to use IL2CPP.
In order to use IL2CPP and use the Unity project using AWS Cognito, it is recommended that you:
Use .NetStandard2.0.
Use AWS SDK that is compatible with .NetStandard 2.0.
I used Unity 2020.3.19f version to use .NetStandard 2.0.
If you are using a URP project and there is an error in URP due to downgrade of Unity version, it is recommended that you act as follows.
Enter the Package folder for that project
Open Manifest.json and Package-lock.json files
Change the Render Pipeline version to 10.8.1 (for 2020.3.19f1 version. I didn't experiment with other versions.)
Reference found to resolve this issue.
https://forum.unity.com/threads/issue-with-system-configuration-configurationmanager-get_appsettings-on-ios.1026877/#post-6656764
https://docs.aws.amazon.com/ko_kr/mobile/sdkforunity/developerguide/aws-unity-sdk.pdf
https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal#10.8/manual/index.html

Access Lambda environment variables from .env file

I am running .net core 3.1 AWS Lambda function but I am unable to access the environment variable from the AWS Lambda Console in c# using:
var envVariable = Environment.GetEnvironmentVariable("myVariableName");
The environment variables are stored in a .env file in the root of my lambda function. Does the .env file need to be copied into the build folder for it to be accessible in the lambda function?. How can I access the AWS Lambda environment variable from the .env file?
Application Structure
cloudformation-template.json refers to .env file.
update: 5/31/2020:
I removed the .env file and added the variables in the cloudformation-template.json directly as individual variables. When I try to push the same to aws using amplify publish command, I get a
Resource is not in the state stackUpdateComplete
An error occured during the push operation: Resource is not in the state stackUpdateComplete error
I am able to solve this issue by adding environment variables directly to the cloudformation-template.json and running the amplify publish command to push to aws.
"Environment": {
"Variables": {
"VUE_APP_STRIPE_PUBLISHABLE_KEY": "<someRandomString>",
"VUE_APP_STRIPE_SECRET_KEY": "<someRandomString>"
}
},

"System Cannot Find the Path Specified." Error in Executing Antlr4 Program Using Antlr 4 Code Generator in Command Line

I'm following this tutorial and it asks to download the Antlr 4 Code Generator which I downloaded from here and decompressed it.
According to the tutorial, I should then execute the following command:
/tools/antlr4-csharp-4.6.1-SNAPSHOT-complete.jar -package <NAMESPACE-OF-YOUR-PROGRAM> -o <OUTPUT_DIR> -Dlanguage=CSharp_v4_5 <PATH-TO-GRAMMAR>
Accordingly, I executed the following command:
/tools/antlr4-csharp-4.6.6-SNAPSHOT-complete.jar -package myTest -o /output -Dlanguage=CSharp_v4_5 Hello.g4
I have an "output" directory in the de-compressed folder, and a Hello.g4 file in the directory itself. However, when I tried to execute this command I get the below error:
The system cannot find the path specified.
What should be the correct path specification for this?

Xamarin Component throws System.NotSupportedException while creating a .xam package

I am trying to upload a Xamarin Component by using xamarin-component.exe tool as written in this guide. While it is building the .xam package file, the command console is throwing the following error:
What is the problem? I am running it on windows. Is this related to machine permission?
I've found the reason for the error message.The file paths format I've given for build,libraries,samples in the component.yaml file was not in the specified format. Also the spaces between the build,libraries,samples's keys and their respective values should be maintained as per the component submission guide.Like this, build:
- src/samplecomponent.sln
libraries:
ios-unified: ../src/samplecomponent/bin/release/Awesome.dll

Categories