Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Aniket Braganza
    @aabragan
    @normj we are not using serverless. we use azure devops for the pipeline in combination with terraform. I assume that should not be an issue since you are bolting it into lambda tools right?
    Norm Johanson
    @normj
    @aabragan As long as you use Amazon.Lambda.Tools to create your package bundle you should be good once it is released. Although you are welcome to build it locally and try it out. I think the branch is feature complete, I need to update the docs and get everything reviewed.
    Aniket Braganza
    @aabragan
    @normj so the new lambda tools with support for layers is out in nuget? If so I will pull it down and give it a shot. Thanks for the update!
    Aniket Braganza
    @aabragan
    Would it be possible to enhance the AWS Lambda Json Serializer such that we could specify custom serialization settings? I know the serializer is loaded through reflection. Is the only way to accomplish this, to build my own serializer and set this up in there?
    e.g.
            private readonly JsonSerializerSettings _serializerSettings = new JsonSerializerSettings
            {
                NullValueHandling = NullValueHandling.Ignore,
                Formatting = Formatting.None,
                MissingMemberHandling = MissingMemberHandling.Ignore,
                DefaultValueHandling = DefaultValueHandling.Ignore
            };
    Norm Johanson
    @normj
    @aabragan The layer support isn't released to NuGet yet. I have the PR out now so hopefully soon.
    Norm Johanson
    @normj

    @aabragan We could do like we did for passing in custom converters https://github.com/aws/aws-lambda-dotnet/blob/07ce8b4f06c12e96f357c1647575a63b66d206af/Libraries/test/TestFunctionFSharp/FSharpJsonSerializer/FSharpJsonSerializer.cs

    Have a constructor that takes in a JsonSettings. Then you could extend the the serializer and pass your JsonSettings to the base constructor. Then use your serializer in the Lambda serializer attribute.

    Aniket Braganza
    @aabragan
    @normj I thought about basically building my own serializer that wraps the Amazon one. I could have defined the serializer settings in that and modified the base one but that newtonsoft serializer is not exposed. Additionally, there is no way to pass parameters into the constructor via the assembly attribute, but that's not as important. I ended deciding to build my own serializer (that is essentially a clone of the Amazon one with some additional bits on it) which I am currently testing out. It may be useful to make the newtonsoft serializer protected or have a constructor that allows one to pass the settings in along with the converters. Thoughts? Would it be possible to branch the repo and PR that change for you to review?
    Aniket Braganza
    @aabragan
    Maybe something like this:
            /// <summary>
            /// Constructs instance of serializer.
            /// </summary>
            public JsonSerializer() : this(null, null)
            {
            }
    
            /// <summary>
            /// Constructs instance of serializer using custom converters.
            /// </summary>
            public JsonSerializer(IEnumerable<JsonConverter> converters)
                    : this(converters, null)
            {
            }
    
            /// <summary>
            /// Constructs instance of serializer using custom converters and custom serialization settings.
            /// </summary>
            public JsonSerializer(IEnumerable<JsonConverter> converters, JsonSerializerSettings settings)
            {
                if (settings == null)
                    settings = new JsonSerializerSettings();
    
                settings.ContractResolver = new AwsResolver();
                serializer = Newtonsoft.Json.JsonSerializer.Create(settings);
    
                if (string.Equals(Environment.GetEnvironmentVariable(DEBUG_ENVIRONMENT_VARIABLE_NAME), "true", StringComparison.OrdinalIgnoreCase))
                {
                    this.debug = true;
                }
    
                if (converters != null)
                {
                    foreach (var c in converters)
                    {
                        serializer.Converters.Add(c);
                    }
                }
    
            }
    Aniket Braganza
    @aabragan
    then I could do something like this:
        /// <summary>
        /// Custom Json Serializer based on Amazon's implementation
        /// </summary>
        public class CustomJsonSerializer : JsonSerializer
        {
            private static readonly JsonSerializerSettings SerializerSettings = new JsonSerializerSettings
            {
                NullValueHandling = NullValueHandling.Ignore,
                Formatting = Formatting.None,
                MissingMemberHandling = MissingMemberHandling.Ignore,
                DefaultValueHandling = DefaultValueHandling.Ignore
            };
    
            /// <summary>
            /// Constructs instance of serializer using custom serialization settings.
            /// </summary>
            public CustomJsonSerializer() : base(null, SerializerSettings)
            {
    
            }
        }
    Andrew Shaw Care
    @andrewshawcare
    I'm using EFCore in an AWS lambda function and it looks like it's taking up to 30 seconds to initialize the context... is there an example Lambda function that integrates with EFCore?
    hounddog22030
    @hounddog22030
    We use EF CORE and do nothing special. What memory size is your function? What DB are you connecting to? What the “instance type” of the DB server?
    Aniket Braganza
    @aabragan
    @andrewshawcare We used to run into load time issue with EFCore too. We actually switch to use SqlKata (https://sqlkata.com) for our data access and use a dedicated lambda to do data access. It uses Dapper under the covers I believe.
    Christian Kütbach
    @ckuetbach

    Hi there... I use a URL Rewrite to make use a Lambda behind a reverse proxy. (/acme/abc should execute <lambda>/prod/acme/abc). This works fine, but within my code I create an Url with the UrlHelper. Running on my local maschine everything seems to be fine (The link is created as /acme/xyz) but when running within Lamba it ist created as /prod/acme/xyz.

    Any Ideas?

    https://github.com/d-velop/dvelop-app-template-cs/commit/b4be5bfc5d71801124850906b998d9468677fe53#diff-b070eb406f87f97d9900f275b4c9a67bR113

    Christian Kütbach
    @ckuetbach
    OK, I am a step further ... it works, but I'd like to know, why the PathBase is set: [Debug] Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFunction: ASP.NET Core Request PathBase: /prod, Path: /acme-apptemplatecs/
    I guess it is because the /prod of API Gateway should be omitted. In this case resetting the PathBase to / the solution, because my Reverse-Proxy adds /prod to the requests.
    Piotr
    @karpikpl
    Hi,
    the code of conduct mentions "Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation." but I don't see a build on the PR.
    Is there something I'm missing?
    Thiago Delgado
    @thiagodelgado111
    Hi folks, quick question, is there a recommended way to deploy a set of lambdas and a gateway api using the lambda tool? (custom runtime, netcore 2.2)
    Erik O'Leary
    @onionhammer
    So now netcore 3 is out, when is official runtime support coming?
    tobymiller1
    @tobymiller1
    @onionhammer I'm trying to get dotnet core 3 working in lambda too, but I don't think they'll do an official runtime release as 3.1 (scheduled for November) will be the LTS release, not 3.0
    I'm wondering if anyone's built a custom layer with a runtime for dotnet core 3.0 that mimics the official runtimes by parsing the handler and loading the appropriate class and method?
    FordyceGarfield
    @FordyceGarfield

    Are there any tricks to get the LambdaLogger to log the request id with every message? The closest I've gotten is by using scopes. This gives me a consistent ID for every message within a request, but this is not the actual requestid that AWS generates (see below). I've tried turning on EventIDs, but this doesn't appear to do anything useful. I'm on Amazon.Lambda.Logging.AspNetCore 2.3.0.
    Example:

    START RequestId: 0398a3a7-a36f-47c4-acf8-62baf867b25c Version: $LATEST [Information] RequestId:0HLQ7DJ3PSAU1...

    I'm looking to have both of RequestIDs to be the GUID assigned by AWS.

    hounddog22030
    @hounddog22030
    Anyone have any thoughts on this: aws/aws-aspnet-cognito-identity-provider#131
    James Bright
    @jbright
    @FordyceGarfield I wrote my own simple logger to do this. It's not elegant, but basically a very simple class that you can initialize with the request id and each of my services will use that to log their messages. I could not find any of the existing logging solutions that did this out of the box. (I also set up a log level that was bound to an environment variable so that I could control what level of detail to log, since we do millions of lambda executions per day and that can get expensive if you log too much information.)
    FordyceGarfield
    @FordyceGarfield
    @jbright Thanks for the feedback! I guess we'll bark up that tree.
    benbward
    @benbward
    @FordyceGarfield I'm using scopes, but I'm using the ILambdaContext.AwsRequestId property on the context object that is passed into the function. Will that work?
    hounddog22030
    @hounddog22030
    If there's anything I can do to help speed up support for .net core 3.1 (about 1 month out).... please let me know.... https://dotnet.microsoft.com/download/dotnet-core/3.1
    Christopher Johnston
    @chrisj-au
    Quick Q. When building a web api, is there any advantage to write it as a standard application (simple handler) over a web api with controllers etc? I find that it's a bit of work getting DI working on a standard application when trying to add systemsmanager (or i'm not smart enough :))
    ssureshraja
    @ssureshraja
    @Edu115 Could you please help me as I'm hitting the same issue. Added all libraries but still get the GDI type initializer exception
    jdavis-leasehawk
    @jdavis-leasehawk
    I see commit activity is still ongoing trying to get .NET 3.1 support up and going. Thank you @normj for your hard work, waiting in anticipation
    not that we as a company are going crazy in need for it .. we're not .. just have in our backlog a story "update to .net core 3.1" all of our projects, which are .net core 2.2, with one project sitting in lambda and .net core 2.1 that is holding everything up .. lol ..
    Christian Kütbach
    @ckuetbach

    Hi ... I get an error, while starting my application within the lambda testtool:

    System.MissingMethodException: Method not found: 'Microsoft.AspNetCore.Hosting.IWebHostBuilder Microsoft.AspNetCore.Hosting.IWebHostBuilder.ConfigureAppConfiguration(System.Action`2<Microsoft.AspNetCore.Hosting.WebHostBuilderContext,Microsoft.Extensions.Configuration.IConfigurationBuilder>)'.

    Am I missing a nuget package?
    Ohh and thanks for the 3.1 support
    kevinsunsh
    @kevinsunsh
    Is there a document or sample code to show how C# lambda function can work with a native library?
    Tushti Ahuja
    @Tushti02
    Hi,
    Can anyone guide in -
    When is it best to use WebApi template over Empty Lambda template for serverless applications?
    What are the best recommendations for choosing a template basis busniess scenarios/costs/package size/Start Time etc?
    hounddog22030
    @hounddog22030
    @Tushti02 I think your question is too broad. What are you trying to do specially?
    Tushti Ahuja
    @Tushti02

    I have implemented a serverless lambda function which is to be invoked by API Gateway, but I am asked to use WebApi template. I don't understand how would choosing this template would be better. The api gateway SAM configuration any way takes care of hitting that lambda function. Besides, that lamda is simply responsible to insert data into a table.

    Kindly enlighten me on questions above and the above scenario considering the best practices.

    hounddog22030
    @hounddog22030
    @Tushti02 - So you question is which "Blueprint" to use in Visual Studio for your scenario after selecting a "Serverless" project?
    hounddog22030
    @hounddog22030

    @normj - what's your thoughts on the following statements?

    This page titled "Using Amazon Logging Frameworks with AWS Lambda" describes AWS Lambda logging patterns: https://docs.aws.amazon.com/toolkit-for-visual-studio/latest/user-guide/cw-log-frameworks.html

    But, when you goto any of the links in the last line, "The AWS .NET logging plugins are a new open source project on GitHub. All of the plugins are there, including samples and instructions on how to configure CloudWatch Logs for each of the supported .NET logging frameworks.", they lead you to a project with a readme.md that reads "When using Lambda it is recommended to use either the ILambdaContext.Logger.LogLine or the Amazon.Lambda.Logging.AspNetCore package."

    In other words, it seems the bulk of the page "https://docs.aws.amazon.com/toolkit-for-visual-studio/latest/user-guide/cw-log-frameworks.html" is bad advice, because it is demonstrating a pattern which is not recommended.

    I feel as though I have wasted a couple of days because of this because I missed this callout in the readme.md not to use them with AWS Lambda. BTW, wasted days because I couldn't not figure out why the log events were not being written. Ironically, they do seem to get flushed with the next call to the lambda function, so the last set of entries is always missing.

    @normj - BTW, what I want to do is create a single CloudWatch Log for a stack and have all functions write to it. So it looks like I'll use the Amazon.Lambda.Logging.AspNetCore, but it isn't clear to me how to create a specific CloudWatch Log Group in order to achieve that goal.
    Richard Silveira
    @RichardSilveira

    Hi,
    Can anyone help me on
    -- Custom Header not being added at final HTTP response - APIGatewayHttpApiV2ProxyResponse class from AWS .NET Lambda SDK

    https://stackoverflow.com/questions/63744500/custom-header-not-being-added-at-final-http-response-apigatewayhttpapiv2proxyr

    hounddog22030
    @hounddog22030
    @RichardSilveira - posted some ???s on your thread
    Zhiwei
    @ChihweiLHBird
    I am a beginner, and I am setting up a test REST API for lambda. I created an empty Lambda function project in Visual Studio 2019, but I don't know why I cannot do using Amazon.Lambda.APIGatewayEvents;
    Severity Code Description Project File Line Suppression State Tool Error CS0234 The type or namespace name 'APIGatewayEvents' does not exist in the namespace 'Amazon.Lambda' (are you missing an assembly reference?) TableReadyAWSRestaurantsInfoLambda C:\Users\zhiwe\source\repos\TableReadyAWSRestaurantsInfoLambda\TableReadyAWSRestaurantsInfoLambda\Function.cs 7 Active Compiler
    Anyone know what was going wrong?
    hounddog22030
    @hounddog22030
    @ChihweiLHBird - Sounds like you're missing a package reference. Did you use a template/blueprint or are you starting from scratch?
    Zhiwei
    @ChihweiLHBird
    @hounddog22030 Thank you very much. After installing the NuGet packages, it works! Have a great weekend.
    Alberto Corrales Garcia
    @albertocorrales
    Hi guys, I'm trying to run lambda power tool for my dotnet core lambda web api. For that I need to get the Request that is coming to the lambda, so I can send the same body in lambda power tool. Do you know what is the best way to get that resquest for dotnet lambda web api? Looking at the implementation, I think I need the object APIGatewayProxyRequest that is used by class APIGatewayProxyFunction. Is that OK? Thanks in advance
    2 replies
    hounddog22030
    @hounddog22030