Skip to content

Commit 623bf7b

Browse files
authored
Add sample code Java and Rust (#2)
* Add sample code Java * Add sample for Rust
1 parent fbd1c9d commit 623bf7b

File tree

24 files changed

+1163
-0
lines changed

24 files changed

+1163
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,3 +349,4 @@ MigrationBackup/
349349
# Ionide (cross platform F# VS Code tools) working folder
350350
.ionide/
351351
/go/*.exe
352+
/Java/com.java/target/*

Java/BlobTrigger/function.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"bindings" : [ {
3+
"type" : "blobTrigger",
4+
"direction" : "in",
5+
"name" : "triggerBlob",
6+
"path" : "test-triggerinput-httpworker/{name}",
7+
"dataType" : "binary",
8+
"connection" : "AzureWebJobsStorage"
9+
},
10+
{
11+
"type" : "blob",
12+
"direction" : "out",
13+
"name" : "$return",
14+
"path" : "test-output-httpworker/{name}",
15+
"dataType" : "binary",
16+
"connection" : "AzureWebJobsStorage"
17+
} ]
18+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"bindings": [
3+
{
4+
"authLevel": "anonymous",
5+
"type": "httpTrigger",
6+
"direction": "in",
7+
"name": "req",
8+
"methods": [
9+
"get",
10+
"post"
11+
]
12+
},
13+
{
14+
"type": "http",
15+
"direction": "out",
16+
"name": "res"
17+
},
18+
{
19+
"name": "$return",
20+
"type": "queue",
21+
"direction": "out",
22+
"queueName": "test-output-node",
23+
"connection": "AzureWebJobsStorage"
24+
}
25+
]
26+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"bindings": [
3+
{
4+
"authLevel": "anonymous",
5+
"type": "httpTrigger",
6+
"direction": "in",
7+
"name": "req",
8+
"methods": [
9+
"get",
10+
"post"
11+
]
12+
},
13+
{
14+
"type": "http",
15+
"direction": "out",
16+
"name": "res"
17+
},
18+
{
19+
"name": "$return",
20+
"type": "queue",
21+
"direction": "out",
22+
"queueName": "test-output-node",
23+
"connection": "AzureWebJobsStorage"
24+
}
25+
]
26+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"bindings": [
3+
{
4+
"authLevel": "anonymous",
5+
"type": "httpTrigger",
6+
"direction": "in",
7+
"name": "req",
8+
"methods": [
9+
"get",
10+
"post"
11+
]
12+
},
13+
{
14+
"type": "http",
15+
"direction": "out",
16+
"name": "res"
17+
},
18+
{
19+
"name": "$return",
20+
"type": "queue",
21+
"direction": "out",
22+
"queueName": "test-output-node",
23+
"connection": "AzureWebJobsStorage"
24+
}
25+
]
26+
}

Java/QueueTrigger/function.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"bindings": [
3+
{
4+
"name": "myQueueItem",
5+
"type": "queueTrigger",
6+
"direction": "in",
7+
"queueName": "test-input-node",
8+
"connection": "AzureWebJobsStorage"
9+
},
10+
{
11+
"name": "$return",
12+
"type": "queue",
13+
"direction": "out",
14+
"queueName": "test-output-node",
15+
"connection": "AzureWebJobsStorage"
16+
}
17+
]
18+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"bindings": [
3+
{
4+
"name": "myQueueItem",
5+
"type": "queueTrigger",
6+
"direction": "in",
7+
"queueName": "test-inputmultiout-node",
8+
"connection": "AzureWebJobsStorage"
9+
},
10+
{
11+
"name": "$return",
12+
"type": "queue",
13+
"direction": "out",
14+
"queueName": "test-output-node",
15+
"connection": "AzureWebJobsStorage"
16+
},
17+
{
18+
"name": "output1",
19+
"type": "queue",
20+
"direction": "out",
21+
"queueName": "test-output1-node",
22+
"connection": "AzureWebJobsStorage"
23+
}
24+
]
25+
}

Java/README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Azure Functions Http Worker - Java API Sample
2+
3+
## Pre-reqs
4+
- Java 8
5+
- Maven (for packaging)
6+
7+
## Build + Run the Java API standalone
8+
- Use the following configuration in your `launch.json` to run the Java API:
9+
```json
10+
"configurations": [
11+
{
12+
"type": "java",
13+
"name": "Debug (Launch)",
14+
"request": "launch",
15+
"mainClass": "",
16+
"env": {
17+
"FUNCTIONS_HTTPWORKER_PORT": 5000
18+
}
19+
},
20+
```
21+
- Hit the endpoints at `http://localhost:5000/SimpleHttpTrigger`
22+
23+
## Run with Functions
24+
- Package the Java api into a jar file:
25+
```bash
26+
mvn package -f "java/com.java/pom.xml"
27+
```
28+
- In a terminal, `cd` to the `functions` directory and run:
29+
```bash
30+
func start
31+
```
32+
> All being well you should see the Spring ascii logo, where the functions runtime has started the proces.
33+
34+
- Hit the endpoints at `http://localhost:7071/api/SimpleHttpTrigger`
35+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"bindings": [
3+
{
4+
"authLevel": "anonymous",
5+
"type": "httpTrigger",
6+
"direction": "in",
7+
"name": "req",
8+
"methods": [
9+
"get",
10+
"post"
11+
]
12+
},
13+
{
14+
"type": "http",
15+
"direction": "out",
16+
"name": "res"
17+
}
18+
]
19+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"bindings": [{
3+
"type": "httpTrigger",
4+
"authLevel": "anonymous",
5+
"direction": "in",
6+
"methods": ["GET",
7+
"POST"],
8+
"name": "req"
9+
},
10+
{
11+
"type": "http",
12+
"direction": "out",
13+
"name": "$return"
14+
}]
15+
}

0 commit comments

Comments
 (0)