private static async Task GetCallingIP()

in dotnet6/hello-pt/{{cookiecutter.project_name}}/src/HelloWorld/Function.cs [38:62]


        private static async Task<string> GetCallingIP()
        {
            try
            {
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Add("User-Agent", "AWS Lambda .Net Client");

                var msg = await client.GetStringAsync("http://checkip.amazonaws.com/").ConfigureAwait(continueOnCapturedContext:false);

                {%- if cookiecutter["Powertools for AWS Lambda (.NET) Metrics"] == "enabled"%}
                // Custom Metric
                // https://awslabs.github.io/aws-lambda-powertools-dotnet/core/metrics/
                Metrics.AddMetric("ApiRequestCount", 1, MetricUnit.Count);
                {%- endif %}

                return msg.Replace("\n","");
            }
            catch (Exception ex)
            {
                {%- if cookiecutter["Powertools for AWS Lambda (.NET) Logging"] == "enabled" %}
                Logger.LogError(ex);
                {%- endif %}
                throw;
            }
        }