aws / aws/aws-lambda-dotnet

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

Aperta
#1,146 15 commenti 4 reazioni 0 assegnatari Vedi su GitHub
doc-readme documentation module/custom-runtime p1 queued
Lingua principale
C#
Stelle
1.7k
Fork
503
Merge medio
1g 18h
PR unite (30g)
21

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia dal README.md del repository collegato nell’issue e confronta le indicazioni su Runtime Interface Client con la sezione Usage del README del client Python. Documenta come ottenere e invocare il client .NET in un Dockerfile personalizzato, incluso il caso dell’handler executable-assembly descritto nell’issue. Il lavoro è completo quando un nuovo contributore può creare un’immagine personalizzata e identificare la configurazione corretta dell’handler senza fare affidamento su dettagli del runtime non documentati.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
aws, csharp, docker
Ambito
cloud, documentation
Tipo di issue
Documentazione
Difficoltà
2/5
Tempo stimato
1-3 ore
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
38/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.