Skip to content

juunas11/code-sandbox

Repository files navigation

C# code sandbox with Azure Durable Functions + Container Instances

The idea of this small app is to take a C# file as input, and start a container instance to run that file. The logs from that container are then given as the result. Something like what .NET Fiddle does.

The flow at high level:

  1. HTTP POST request to the HTTP triggered function (C# file in body)
  2. Function uploads the file to Azure Storage, generates a SAS token
  3. Durable Function orchestration is started
  4. Container instance started with the file SAS URL as input
  5. Container script runs, file downloaded as Program.cs next to a csproj file already in the container
  6. Container runs dotnet build and dotnet run
  7. Orchestrator monitors the progress and waits for the container to terminate
  8. Logs from the container are downloaded after the container has terminated or the process has taken too long
  9. The container instance is deleted and the C# file in Storage is deleted
  10. The logs are set as the orchestrator result

This process takes around 1 minute for a hello world C# file, so it isn't quite at .NET Fiddle's level :D

This app was made for fun and does not include e.g. the validations I might put into a production app.

About

C# code sandbox with Azure Durable Functions + Container Instances

Topics

Resources

License

Stars

Watchers

Forks

Languages