-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
first darft of indexer java function
- Loading branch information
1 parent
87f5fb6
commit bd63b26
Showing
9 changed files
with
245 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"recommendations": [ | ||
"ms-azuretools.vscode-azurefunctions", | ||
"vscjava.vscode-java-debug" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Attach to Java Functions", | ||
"type": "java", | ||
"request": "attach", | ||
"hostName": "127.0.0.1", | ||
"port": 5005, | ||
"preLaunchTask": "func: host start" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"azureFunctions.javaBuildTool": "maven", | ||
"azureFunctions.deploySubpath": "app/indexer/functions/target/azure-functions/indexer-blob-processor", | ||
"azureFunctions.projectLanguage": "Java", | ||
"azureFunctions.projectRuntime": "~4", | ||
"debug.internalConsoleOptions": "neverOpen", | ||
"azureFunctions.projectSubpath": "app/indexer/functions", | ||
"azureFunctions.preDeployTask": "package (functions)" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,43 @@ | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "Start App ", | ||
"type": "shell", | ||
"command": "${workspaceFolder}/app/start.sh", | ||
"windows": { | ||
"command": "pwsh ${workspaceFolder}/app/start.ps1" | ||
}, | ||
"presentation": { | ||
"reveal": "always" | ||
}, | ||
"options": { | ||
"cwd": "${workspaceFolder}/app" | ||
}, | ||
"problemMatcher": [] | ||
} | ||
] | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "Start App ", | ||
"type": "shell", | ||
"command": "${workspaceFolder}/app/start.sh", | ||
"windows": { | ||
"command": "pwsh ${workspaceFolder}/app/start.ps1" | ||
}, | ||
"presentation": { | ||
"reveal": "always" | ||
}, | ||
"options": { | ||
"cwd": "${workspaceFolder}/app" | ||
}, | ||
"problemMatcher": [] | ||
}, | ||
{ | ||
"type": "func", | ||
"label": "func: host start", | ||
"command": "host start", | ||
"problemMatcher": "$func-java-watch", | ||
"isBackground": true, | ||
"options": { | ||
"cwd": "${workspaceFolder}/app/indexer/functions/target/azure-functions/indexer-blob-processor" | ||
}, | ||
"dependsOn": "package (functions)" | ||
}, | ||
{ | ||
"label": "package (functions)", | ||
"command": "mvn clean package", | ||
"type": "shell", | ||
"group": { | ||
"kind": "build", | ||
"isDefault": true | ||
}, | ||
"options": { | ||
"cwd": "${workspaceFolder}/app/indexer/functions" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Build output | ||
target/ | ||
*.class | ||
|
||
# Log file | ||
*.log | ||
|
||
# BlueJ files | ||
*.ctxt | ||
|
||
# Mobile Tools for Java (J2ME) | ||
.mtj.tmp/ | ||
|
||
# Package Files # | ||
*.jar | ||
*.war | ||
*.ear | ||
*.zip | ||
*.tar.gz | ||
*.rar | ||
|
||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | ||
hs_err_pid* | ||
|
||
# IDE | ||
.idea/ | ||
*.iml | ||
.settings/ | ||
.project | ||
.classpath | ||
.vscode/ | ||
|
||
# macOS | ||
.DS_Store | ||
|
||
# Azure Functions | ||
local.settings.json | ||
bin/ | ||
obj/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"version": "2.0", | ||
"extensionBundle": { | ||
"id": "Microsoft.Azure.Functions.ExtensionBundle", | ||
"version": "[4.0.0, 5.0.0)" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<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"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
|
||
<parent> | ||
<groupId>com.microsoft.openai.samples</groupId> | ||
<artifactId>indexer-parent</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
|
||
<artifactId>indexer-functions</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<java.version>17</java.version> | ||
<azure.functions.maven.plugin.version>1.29.0</azure.functions.maven.plugin.version> | ||
<azure.functions.java.library.version>3.0.0</azure.functions.java.library.version> | ||
<functionAppName>indexer-blob-processor</functionAppName> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.microsoft.azure.functions</groupId> | ||
<artifactId>azure-functions-java-library</artifactId> | ||
<version>${azure.functions.java.library.version}</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.8.1</version> | ||
<configuration> | ||
<source>${java.version}</source> | ||
<target>${java.version}</target> | ||
<encoding>${project.build.sourceEncoding}</encoding> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>com.microsoft.azure</groupId> | ||
<artifactId>azure-functions-maven-plugin</artifactId> | ||
<version>${azure.functions.maven.plugin.version}</version> | ||
<configuration> | ||
<!-- function app name --> | ||
<appName>${functionAppName}</appName> | ||
<!-- function app resource group --> | ||
<resourceGroup>java-functions-group</resourceGroup> | ||
<!-- function app service plan name --> | ||
<appServicePlanName>java-functions-app-service-plan</appServicePlanName> | ||
<!-- function app region--> | ||
<!-- refers https://github.com/microsoft/azure-maven-plugins/wiki/Azure-Functions:-Configuration-Details#supported-regions for all valid values --> | ||
<region>westus</region> | ||
<!-- function pricingTier, default to be consumption if not specified --> | ||
<!-- refers https://github.com/microsoft/azure-maven-plugins/wiki/Azure-Functions:-Configuration-Details#supported-pricing-tiers for all valid values --> | ||
<!-- <pricingTier></pricingTier> --> | ||
<!-- Whether to disable application insights, default is false --> | ||
<!-- refers https://github.com/microsoft/azure-maven-plugins/wiki/Azure-Functions:-Configuration-Details for all valid configurations for application insights--> | ||
<!-- <disableAppInsights></disableAppInsights> --> | ||
<runtime> | ||
<!-- runtime os, could be windows, linux or docker--> | ||
<os>linux</os> | ||
<javaVersion>17</javaVersion> | ||
</runtime> | ||
<appSettings> | ||
<property> | ||
<name>FUNCTIONS_EXTENSION_VERSION</name> | ||
<value>~4</value> | ||
</property> | ||
</appSettings> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<id>package-functions</id> | ||
<goals> | ||
<goal>package</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<!--Remove obj folder generated by .NET SDK in maven clean--> | ||
<plugin> | ||
<artifactId>maven-clean-plugin</artifactId> | ||
<version>3.1.0</version> | ||
<configuration> | ||
<filesets> | ||
<fileset> | ||
<directory>obj</directory> | ||
</fileset> | ||
</filesets> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
28 changes: 28 additions & 0 deletions
28
...s/src/main/java/com/microsoft/openai/samples/indexer/functions/BlobProcessorFunction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.microsoft.openai.samples.indexer.functions; | ||
|
||
import com.microsoft.azure.functions.ExecutionContext; | ||
import com.microsoft.azure.functions.HttpMethod; | ||
import com.microsoft.azure.functions.HttpRequestMessage; | ||
import com.microsoft.azure.functions.HttpResponseMessage; | ||
import com.microsoft.azure.functions.HttpStatus; | ||
import com.microsoft.azure.functions.annotation.*; | ||
|
||
import java.util.Optional; | ||
|
||
/** | ||
* Azure Functions with Blob Trigger. | ||
*/ | ||
public class BlobProcessorFunction { | ||
@FunctionName("BlobEventGridProcessor") | ||
/** | ||
* 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. | ||
*/ | ||
@StorageAccount("AzureWebJobsStorage") | ||
public void run( | ||
@BlobTrigger(name = "content", path = "content/{filename}", dataType = "binary", source = "EventGrid" ) byte[] content, | ||
@BindingName("filename") String filename, | ||
final ExecutionContext context | ||
) { | ||
context.getLogger().info("Java Blob trigger function processed a blob. Name: " + filename + "\n Size: " + content.length + " Bytes"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters