diff --git a/dotnet/hello-world/.gitignore b/dotnet/hello-world/.gitignore new file mode 100644 index 00000000..2a22c406 --- /dev/null +++ b/dotnet/hello-world/.gitignore @@ -0,0 +1,40 @@ +*.swp +*.*~ +project.lock.json +.DS_Store +*.pyc +nupkg/ + +# Visual Studio Code +.vscode + +# Rider +.idea + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +build/ +bld/ +[Bb]in/ +[Oo]bj/ +[Oo]ut/ +msbuild.log +msbuild.err +msbuild.wrn + +# Visual Studio 2015 +.vs/ + +# Cloud Function Archive +code.tar.gz diff --git a/dotnet/hello-world/HelloWorld.csproj b/dotnet/hello-world/HelloWorld.csproj new file mode 100644 index 00000000..5e8bc0a7 --- /dev/null +++ b/dotnet/hello-world/HelloWorld.csproj @@ -0,0 +1,9 @@ + + + + Exe + net5.0 + HelloWorld + + + diff --git a/dotnet/hello-world/Program.cs b/dotnet/hello-world/Program.cs new file mode 100644 index 00000000..78f580ef --- /dev/null +++ b/dotnet/hello-world/Program.cs @@ -0,0 +1,13 @@ +using System; +using System.Threading.Tasks; + +namespace HelloWorld +{ + class Program + { + static async Task Main(string[] args) + { + Console.WriteLine("Hello World, I'm an Appwrite cloud function written in .NET."); + } + } +} diff --git a/dotnet/hello-world/README.md b/dotnet/hello-world/README.md new file mode 100644 index 00000000..bd999ba1 --- /dev/null +++ b/dotnet/hello-world/README.md @@ -0,0 +1,39 @@ +# 🚮 Clean up files in your storage older than XX days +A sample .NET cloud function to help you create and run Java cloud functions in Appwrite + +## 🚀 Building and Packaging + +To package this example as a cloud function, follow these steps. + +```bash +$ cd demos-for-functions/dotnet/hello-world + +$ dotnet publish --runtime linux-x64 --framework net5.0 --no-self-contained +``` + +* Ensure that your output looks like this +``` + HelloWorld -> ......\demos-for-functions\dotnet\hello-world\bin\Debug\net5.0\linux-x64\HelloWorld.dll + HelloWorld -> ......\demos-for-functions\dotnet\hello-world\bin\Debug\net5.0\linux-x64\publish\ +``` + +* Create a tarfile + +```bash +$ tar -C bin/Debug/net5.0/linux-x64 -zcvf code.tar.gz publish +``` + +* Navigate to the Overview Tab of your Cloud Function > Deploy Tag +* Input the command that will run your function (in this case `dotnet HelloWorld.dll`) as your entrypoint command +* Upload your tarfile +* Click 'Activate' + +## ⏰ Schedule + +Head over to your function in the Appwrite console and under the Settings Tab, enter a reasonable schedule time (cron syntax). + +For example: + +- `*/30 * * * *` every 30 minutes +- `0 * * * *` every hour +- `0 0 * * *` every day