Reputation: 161
I am following these steps https://docs.aws.amazon.com/lambda/latest/dg/csharp-image.html#csharp-image-clients to create a custom image that I want to run in a Lambda Container. I created this docker image
# You can also pull these images from DockerHub amazon/aws-lambda-dotnet:8
FROM mcr.microsoft.com/dotnet/sdk:8.0
# Set the image's internal work directory
WORKDIR /var/task
RUN dotnet tool install --global dotnet-ef
ENV PATH="${PATH}:/root/.dotnet/tools"
# Copy function code to Lambda-defined environment variable
COPY "bin/Release/net8.0/linux-x64" .
# Set the entrypoint to the bootstrap
ENTRYPOINT ["/usr/bin/dotnet", "exec", "/var/task/bootstrap.dll"]
As you can see, I want to use dotnet ef commands in my container in AWS Lambda, therefore I install it globally. Then, I have the following function handler in which I want to run dotnet ef commands
public class Function
{
/// <summary>
/// The main entry point for the custom runtime.
/// </summary>
/// <param name="args">Command line arguments.</param>
private static async Task Main(string[] args)
{
var handler = FunctionHandler;
await LambdaBootstrapBuilder.Create(handler, new DefaultLambdaJsonSerializer())
.Build()
.RunAsync();
}
/// <summary>
/// A simple function that takes a string and does a ToUpper
///
/// To use this handler to respond to an AWS event, reference the appropriate package from
/// https://github.com/aws/aws-lambda-dotnet#events
/// and change the string input parameter to the desired event type.
/// </summary>
/// <param name="input">The input to the Lambda function handler.</param>
/// <param name="context">The ILambdaContext that provides methods for logging and describing the Lambda environment.</param>
/// <returns></returns>
public static async Task<string> FunctionHandler(string input, ILambdaContext context)
{
// How To use dotnet ef command here?
return input;
}
}
but somehow dotnet ef is not installed. Is that even possible?
Upvotes: 0
Views: 80