Default AWS Lambda source code for .NET scratch build - aws-lambda

I am trying to find the code for the default .NET AWS Lambda function. It does not appear to be one of the Lambda templates and I can't see it in the repository.
I'm talking about the code deployed when "Author from scratch" is selected - before any code is uploaded to the function.
Does anyone know where that source is made available?
I am specifically requesting the source of the .NET Lambda which returns "Hello from Lambda!" when the root Function URL is requested.

Related

Using JavaScript ESM in Serverless Framework functions

I'm using the modern import/export syntax in my NodeJS functions for the Serverless Framework.
After deployment, when I try and invoke the URL I see HTTP 502 {"message": "Internal server error"} error. The CloudWatch logs say:
require is not defined in ES module scope, you can use import instead
This file is being treated as an ES module because it has a '.js' file extension and '/var/task/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
When I inspect the code through the AWS Console > Lambda, I can see the Serverless Framework has generated a s_getDns.js file for my function, and inside it's using the legacy "require" syntax:
var serverlessSDK = require('./serverless_sdk/index.js');
serverlessSDK = new serverlessSDK({
// ...
});
I'm using v3.23.0 of the Serverless Framework.
I have tried:
Added "type": "module" to the packages.json file
Used the nodejs16.x runtime
(which lead to the error described above)
I have also tried manually editing the s_getDns.js file in the Lambda console to use the new import/export syntax, however I then start getting errors from the serverless_sdk/index.js file (which is minified, so I haven't been able to refactor that one).
This issue comment suggests that both AWS and the Serverless Framework now support ESM out of the box. I'm not sure why it's not working in my case.
What is the issue, or what can I do to troubleshoot this further?
It looks like you're using Serverless Dashboard plugin in your application (you have app and org defined in your config file) and at the moment, ESM modules are not supported by that integration: https://github.com/serverless/serverless/issues/11424#issuecomment-1266584167
You have several options:
Stop using the Serverless Dashboard plugin
Use CJS instead of ESModules
Write a thin wrapper for your handlers in CJS that imports the rest of your code as ESModules

Azure function not showing up in portal

I've written my first Azure Function and I've published it to azure. It said that the publish was successful and it created a new function app, but it's an empty one. I've done a bit of research into why my function wouldn't show up and I've seen that you might need to change the path to the zip deploy but I can't find where I need to change this and into what. Other solutions are always welcome! (I've published it directly from VS2017)
When I send a Postman Request to the url/api/function, it also doesn't work. It doesn't crash or anything, it just gives back nothing after a second.
I need this to work to create a custom connector for Power Automate that way I can use it in my Microsoft Flow.

Unable to find Alexa-skill-kit-sdk-factskill blueprint on aws lamda

I'm quite a beginner to Alexa skill set. Trying to add a node.js skill to Alexa following few nuggets from the internet. I have created skill on amazon developer console and trying to create aws lambda function on aws console. Surprisingly, when I tried creating a lambda function, I could not find any blueprint matching to "Alexa" keyword.
Here are the steps -:
1.Got to aws.amazon.com and log in
2. Search for the Lambda service and go to it
3. Click on Create a function
4. Click on Blueprints
5. Search for “Alexa”
I did some research and it says, changing to North. Virginia region could help but no luck so far.
Any such leads would be really appreciated.
if you are unable to find "alexa-skills-kit-nodejs-factskill" under the section "Use a blueprint",
please look for it under the section "Browse serverless app repository",it doesnt matters whatever the location you choose.
Use cloudformation application templates instead. Though they are still outdated (like the blueprints out there). My advice is that you create an Alexa Hosted Skill instead

how to get the node_modules folder in an aws lambda function

So I am learning how to create alexa skills and I have create two sucessfully following the steps below but for some reason when I follow these steps now I am missing the node_modules folder and the package.json. This is causing the following error when I test my skill:
Unable to import module 'index': Error
The steps I am following are:
- go to the aws console select lambda
- select create new function
- blueprints -> select alexa-skill-kit-sdk-factskill -> configure
- select existing role -> lambda_basic_execution
- create function
It was my understanding that the alexa-skill-kit-sdk-factskill came with these dependencies. Is there a way to add them in manually if so how? I have tried to find a console but I don't see where that is in the lambda workspace.
Here is a screen shots of the project where it did add the folder and json file
Here is on of my current project
I have had this problem, but unfortunately, Lambda console doesn't give us console to install nodejs dependencies.
So, you have to actually deploy your lambda function. There are many ways to do that, but more popular are:
Node Lambda package (for node)
Create ZIP and deploy it in console (Not recommended because of size limitation)
AWS CLI
As you're learning the Alexa Skills, I would suggest you the way Amazon suggests devs to create and organise Alexa Skill and Lambda function.
Use ASK CLI
For creating new Alexa Skill.
This will create a directory, which will have:
Skill's intent Schema
Skill's lambda function
Plus, you can pass a template to create skill for a specific template. Here is list of templates created by Amazon devs.
For eg, command for creating Skill code, for a fact-template skill
ask new [--template [template-name] [--url <url>]]
[-n|--skill-name <name>]
[-p| --profile <profile>] [--lambda-name <lambda-name>]
Using ASK CLI, will give you the advantage of deploying your skill and lambda simultaneously.
I know ASK CLI is a lot to take in so quickly, but once you get the hang of it, it is a very useful tool for Alexa developers.
You can zip the whole directory content locally and upload the zip to
lambda. But yeah you can't edit the code in the console then.
Remember that your handler file name must be mentioned as it is in Handler section.
Like if your file name is app.js then app.handler.

Error while publishing AWS Lambda

We are trying to publish AWS Lambda function using .NET Core Web application and got the following error message
You didn't set your parameters during the publishing.
Open serverless.template file in your project. In "Parameters" section find out 'ShoudCreateBucket' and 'BucketName' items. Then you have to set/add 'Default' value of these items.
Also, you could set these parameters during deployment (click 'Next' instead of 'Publish' on the first deployment screen).
Check out more details in this tutorial Tutorial: Build and Test a Serverless Application with AWS Lambda.

Resources