Skip to content
This repository has been archived by the owner on Jul 16, 2022. It is now read-only.

Commit

Permalink
Merge pull request #71 from Miksier/feat-47-translate-hello-world-fun…
Browse files Browse the repository at this point in the history
…ction-to-dotnet

feat: Add hello world function for .NET
  • Loading branch information
TorstenDittmann authored Jul 12, 2021
2 parents 97c4909 + 7e57fcf commit 9328f6c
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 0 deletions.
40 changes: 40 additions & 0 deletions dotnet/hello-world/.gitignore
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions dotnet/hello-world/HelloWorld.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<RootNamespace>HelloWorld</RootNamespace>
</PropertyGroup>

</Project>
13 changes: 13 additions & 0 deletions dotnet/hello-world/Program.cs
Original file line number Diff line number Diff line change
@@ -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.");
}
}
}
39 changes: 39 additions & 0 deletions dotnet/hello-world/README.md
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 9328f6c

Please sign in to comment.