by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Yusuf Kanchwala
    @kanchwala-yusuf

    Hi All,

    I have a lambda function which calls REST APIs. I am getting a '404 Client Error: Not Found for url.

    But, I am able to access the url from my local machine.

    Also, the lambda function can access the internet. I am doing a couple of things which requires internet access.

    Is there anything that I may be missing...?

    Would appreciate any help here?

    Thanks. :)

    Kevin J. Petersen
    @kevinjpetersen
    Is this chat room still active? :D
    Norm Johanson
    @normj
    @kevinjpetersen It hasn't been very active but there is no reason it can't be active again :)
    Christian Kütbach
    @ckuetbach
    Hi there, I have a question about compatibility. I made a template project based on the aws template and I get some kind of warning (NETSDK1071), that templat is based on net-core app 2.1.5. Not I try to remove the warning, but I am confused, if it is ossible at all.
    I am not sure if the <RuntimeFrameworkVersion> within the csproj would be a good approach: d-velop/dvelop-app-template-cs#22
    Norm Johanson
    @normj
    What do you mean by a template project?
    Aniket Braganza
    @aabragan
    @normj I have been trying to get dot net lambda layers working but constantly get errors about it not finding the dlls. I pulled all external dlls except my own into a separate zip to make the layer zip. I have tried a combination of things including putting the dlls in a bin folder, in the lib/<.net version folder> and also the base folder in the zip but it just won't find them and i invariable get cloudwatch logs telling me it can't find the dependency. I made sure the layer was added to my lambda too. Any ideas? I am struggling to see how I can use it right now.
    Norm Johanson
    @normj
    @aabragan Have you taken a look at by layer branch for the Amazon.Lambda.Tools global tools. I'm working on building support into the tooling. https://github.com/aws/aws-extensions-for-dotnet-cli/issues/58#issuecomment-456704842
    Aniket Braganza
    @aabragan
    @normj I have not but I will look at it right away.
    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.