aws / aws/aws-lambda-dotnet

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

Offen
#1,146 15 Kommentare 4 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
doc-readme documentation module/custom-runtime p1 queued
Vorherrschende Sprache
C#
Sterne
1.7k
Forks
503
Ø Merge
1 T. 18 Std.
Gemergte PRs (30 T.)
21

Beschreibung

### 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

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginnen Sie mit der im Issue verlinkten README.md des Repositorys und vergleichen Sie deren Hinweise zum Runtime Interface Client mit dem Abschnitt Usage in der README des Python-Clients. Dokumentieren Sie, wie der .NET-Client in einem benutzerdefinierten Dockerfile bezogen und aufgerufen wird, einschließlich des im Issue beschriebenen Falls eines executable-assembly-Handlers. Die Aufgabe ist abgeschlossen, wenn ein Neuling ein benutzerdefiniertes Image erstellen und die korrekte Handler-Konfiguration erkennen kann, ohne auf undokumentierte Laufzeitdetails angewiesen zu sein.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
aws, csharp, docker
Bereich
cloud, documentation
Issue-Typ
Dokumentation
Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
38/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.