Skip to content

Commit bd63b26

Browse files
committed
first darft of indexer java function
1 parent 87f5fb6 commit bd63b26

File tree

9 files changed

+245
-18
lines changed

9 files changed

+245
-18
lines changed

.vscode/extensions.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"recommendations": [
3+
"ms-azuretools.vscode-azurefunctions",
4+
"vscjava.vscode-java-debug"
5+
]
6+
}

.vscode/launch.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Attach to Java Functions",
6+
"type": "java",
7+
"request": "attach",
8+
"hostName": "127.0.0.1",
9+
"port": 5005,
10+
"preLaunchTask": "func: host start"
11+
}
12+
]
13+
}

.vscode/settings.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"azureFunctions.javaBuildTool": "maven",
3+
"azureFunctions.deploySubpath": "app/indexer/functions/target/azure-functions/indexer-blob-processor",
4+
"azureFunctions.projectLanguage": "Java",
5+
"azureFunctions.projectRuntime": "~4",
6+
"debug.internalConsoleOptions": "neverOpen",
7+
"azureFunctions.projectSubpath": "app/indexer/functions",
8+
"azureFunctions.preDeployTask": "package (functions)"
9+
}

.vscode/tasks.json

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,43 @@
11
{
2-
"version": "2.0.0",
3-
"tasks": [
4-
{
5-
"label": "Start App ",
6-
"type": "shell",
7-
"command": "${workspaceFolder}/app/start.sh",
8-
"windows": {
9-
"command": "pwsh ${workspaceFolder}/app/start.ps1"
10-
},
11-
"presentation": {
12-
"reveal": "always"
13-
},
14-
"options": {
15-
"cwd": "${workspaceFolder}/app"
16-
},
17-
"problemMatcher": []
18-
}
19-
]
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "Start App ",
6+
"type": "shell",
7+
"command": "${workspaceFolder}/app/start.sh",
8+
"windows": {
9+
"command": "pwsh ${workspaceFolder}/app/start.ps1"
10+
},
11+
"presentation": {
12+
"reveal": "always"
13+
},
14+
"options": {
15+
"cwd": "${workspaceFolder}/app"
16+
},
17+
"problemMatcher": []
18+
},
19+
{
20+
"type": "func",
21+
"label": "func: host start",
22+
"command": "host start",
23+
"problemMatcher": "$func-java-watch",
24+
"isBackground": true,
25+
"options": {
26+
"cwd": "${workspaceFolder}/app/indexer/functions/target/azure-functions/indexer-blob-processor"
27+
},
28+
"dependsOn": "package (functions)"
29+
},
30+
{
31+
"label": "package (functions)",
32+
"command": "mvn clean package",
33+
"type": "shell",
34+
"group": {
35+
"kind": "build",
36+
"isDefault": true
37+
},
38+
"options": {
39+
"cwd": "${workspaceFolder}/app/indexer/functions"
40+
}
41+
}
42+
]
2043
}

app/indexer/functions/.gitignore

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Build output
2+
target/
3+
*.class
4+
5+
# Log file
6+
*.log
7+
8+
# BlueJ files
9+
*.ctxt
10+
11+
# Mobile Tools for Java (J2ME)
12+
.mtj.tmp/
13+
14+
# Package Files #
15+
*.jar
16+
*.war
17+
*.ear
18+
*.zip
19+
*.tar.gz
20+
*.rar
21+
22+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
23+
hs_err_pid*
24+
25+
# IDE
26+
.idea/
27+
*.iml
28+
.settings/
29+
.project
30+
.classpath
31+
.vscode/
32+
33+
# macOS
34+
.DS_Store
35+
36+
# Azure Functions
37+
local.settings.json
38+
bin/
39+
obj/

app/indexer/functions/host.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"version": "2.0",
3+
"extensionBundle": {
4+
"id": "Microsoft.Azure.Functions.ExtensionBundle",
5+
"version": "[4.0.0, 5.0.0)"
6+
}
7+
}

app/indexer/functions/pom.xml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
6+
<parent>
7+
<groupId>com.microsoft.openai.samples</groupId>
8+
<artifactId>indexer-parent</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
<relativePath>../pom.xml</relativePath>
11+
</parent>
12+
13+
14+
<artifactId>indexer-functions</artifactId>
15+
<version>1.0-SNAPSHOT</version>
16+
17+
18+
<properties>
19+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
20+
<java.version>17</java.version>
21+
<azure.functions.maven.plugin.version>1.29.0</azure.functions.maven.plugin.version>
22+
<azure.functions.java.library.version>3.0.0</azure.functions.java.library.version>
23+
<functionAppName>indexer-blob-processor</functionAppName>
24+
</properties>
25+
26+
<dependencies>
27+
<dependency>
28+
<groupId>com.microsoft.azure.functions</groupId>
29+
<artifactId>azure-functions-java-library</artifactId>
30+
<version>${azure.functions.java.library.version}</version>
31+
</dependency>
32+
</dependencies>
33+
34+
<build>
35+
<plugins>
36+
<plugin>
37+
<groupId>org.apache.maven.plugins</groupId>
38+
<artifactId>maven-compiler-plugin</artifactId>
39+
<version>3.8.1</version>
40+
<configuration>
41+
<source>${java.version}</source>
42+
<target>${java.version}</target>
43+
<encoding>${project.build.sourceEncoding}</encoding>
44+
</configuration>
45+
</plugin>
46+
<plugin>
47+
<groupId>com.microsoft.azure</groupId>
48+
<artifactId>azure-functions-maven-plugin</artifactId>
49+
<version>${azure.functions.maven.plugin.version}</version>
50+
<configuration>
51+
<!-- function app name -->
52+
<appName>${functionAppName}</appName>
53+
<!-- function app resource group -->
54+
<resourceGroup>java-functions-group</resourceGroup>
55+
<!-- function app service plan name -->
56+
<appServicePlanName>java-functions-app-service-plan</appServicePlanName>
57+
<!-- function app region-->
58+
<!-- refers https://github.com/microsoft/azure-maven-plugins/wiki/Azure-Functions:-Configuration-Details#supported-regions for all valid values -->
59+
<region>westus</region>
60+
<!-- function pricingTier, default to be consumption if not specified -->
61+
<!-- refers https://github.com/microsoft/azure-maven-plugins/wiki/Azure-Functions:-Configuration-Details#supported-pricing-tiers for all valid values -->
62+
<!-- <pricingTier></pricingTier> -->
63+
<!-- Whether to disable application insights, default is false -->
64+
<!-- refers https://github.com/microsoft/azure-maven-plugins/wiki/Azure-Functions:-Configuration-Details for all valid configurations for application insights-->
65+
<!-- <disableAppInsights></disableAppInsights> -->
66+
<runtime>
67+
<!-- runtime os, could be windows, linux or docker-->
68+
<os>linux</os>
69+
<javaVersion>17</javaVersion>
70+
</runtime>
71+
<appSettings>
72+
<property>
73+
<name>FUNCTIONS_EXTENSION_VERSION</name>
74+
<value>~4</value>
75+
</property>
76+
</appSettings>
77+
</configuration>
78+
<executions>
79+
<execution>
80+
<id>package-functions</id>
81+
<goals>
82+
<goal>package</goal>
83+
</goals>
84+
</execution>
85+
</executions>
86+
</plugin>
87+
<!--Remove obj folder generated by .NET SDK in maven clean-->
88+
<plugin>
89+
<artifactId>maven-clean-plugin</artifactId>
90+
<version>3.1.0</version>
91+
<configuration>
92+
<filesets>
93+
<fileset>
94+
<directory>obj</directory>
95+
</fileset>
96+
</filesets>
97+
</configuration>
98+
</plugin>
99+
</plugins>
100+
</build>
101+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.microsoft.openai.samples.indexer.functions;
2+
3+
import com.microsoft.azure.functions.ExecutionContext;
4+
import com.microsoft.azure.functions.HttpMethod;
5+
import com.microsoft.azure.functions.HttpRequestMessage;
6+
import com.microsoft.azure.functions.HttpResponseMessage;
7+
import com.microsoft.azure.functions.HttpStatus;
8+
import com.microsoft.azure.functions.annotation.*;
9+
10+
import java.util.Optional;
11+
12+
/**
13+
* Azure Functions with Blob Trigger.
14+
*/
15+
public class BlobProcessorFunction {
16+
@FunctionName("BlobEventGridProcessor")
17+
/**
18+
* This function will be invoked when a new or updated blob is detected at the specified path. The blob contents are provided as input to this function.
19+
*/
20+
@StorageAccount("AzureWebJobsStorage")
21+
public void run(
22+
@BlobTrigger(name = "content", path = "content/{filename}", dataType = "binary", source = "EventGrid" ) byte[] content,
23+
@BindingName("filename") String filename,
24+
final ExecutionContext context
25+
) {
26+
context.getLogger().info("Java Blob trigger function processed a blob. Name: " + filename + "\n Size: " + content.length + " Bytes");
27+
}
28+
}

app/indexer/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
<modules>
2525
<module>core</module>
2626
<module>cli</module>
27+
<module>functions</module>
2728
</modules>
2829

2930
<dependencyManagement>

0 commit comments

Comments
 (0)