aws / aws/aws-lambda-dotnet

Can't find an example of how to create a dockerfile using the dotnet Lambda Runtime Interface Client

Open
#1,146 15 comments 4 reactions 0 assignees View on GitHub
doc-readme documentation module/custom-runtime p1 queued
Dominant language
C#
Stars
1.7k
Forks
503
Avg merge
1d 5h
Merged PRs (30d)
18

Description

### Describe the issue

The page [Deploy .NET Lambda functions with container images](https://docs.aws.amazon.com/lambda/latest/dg/csharp-image.html) provides a [link](https://github.com/aws/aws-lambda-dotnet/blob/master/README.md) to "downloading" the Runtime Interface Client for dotnet, but there are no instructions on how to construct a custom Dockerfile with the client nor is there anything to "download" that I can see.

How can I write a Dockerfile with a custom base and in a straightforward way install or "download" the runtime interface client? The only documentation I have found is about [using the Amazon.Lambda.RuntimeSupport as class library](https://github.com/aws/aws-lambda-dotnet/tree/master/Libraries/src/Amazon.Lambda.RuntimeSupport) which does not seem like something I want to do if I can avoid it, and also it's not clear how that is meant to be used alongside my actual function code (examples don't feel complete).

Btw, I'm trying to write a Dockerfile that like the official `public.ecr.aws/lambda/dotnet:6` allows for specifying executable assembles as the Lambda Handler.

I tried hacking together something like this:
```Dockerfile
FROM mcr.microsoft.com/playwright/dotnet:v1.21.0-focal
ENV LAMBDA_TASK_ROOT=/var/task
COPY --from=public.ecr.aws/lambda/dotnet:6 /var/runtime /var/runtime
COPY --from=build /app/publish/* /var/task
RUN mkdir -p /var/lang/bin
RUN ln -s /usr/bin/dotnet /var/lang/bin/dotnet
ENTRYPOINT [ "/var/runtime/Amazon.Lambda.RuntimeSupport" ]
WORKDIR /var/task
CMD ["HttpApi"] # HttpApi is a .NET 6 Minimal API (Executable Assembly)
```
but that results in the following error:
```bash
2022-04-17T23:11:46.773Z fail Amazon.Lambda.RuntimeSupport.ExceptionHandling.LambdaValidationException: Invalid lambda function handler: '/bin/bash'. The valid format is 'ASSEMBLY::TYPE::METHOD'.
```

Ideally this should all feel as straightforward as it does for python:
The [Deploy Python Lambda functions with container images](https://docs.aws.amazon.com/lambda/latest/dg/python-image.html) has the section:
![image](https://user-images.githubusercontent.com/702922/163735752-2e50f1b8-057d-47db-918f-cdfae24374a7.png)
Which provides a direct link to to a [README](https://github.com/aws/aws-lambda-python-runtime-interface-client/blob/main/README.md) such as the one in this dotnet repo, and they have a [Usage](https://github.com/aws/aws-lambda-python-runtime-interface-client/blob/main/README.md#usage) section with clear instructions of how to construct a Dockerfile:

![image](https://user-images.githubusercontent.com/702922/163736100-3241b72a-c913-48ef-a415-baaacae8c418.png)

### Links

https://docs.aws.amazon.com/lambda/latest/dg/csharp-image.html
https://github.com/aws/aws-lambda-dotnet/blob/master/README.md

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.