Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
MyAzureFunctionsDemo
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abdullah Danish
MyAzureFunctionsDemo
Commits
b255fb4f
Commit
b255fb4f
authored
Sep 14, 2022
by
Abdullah Danish
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
AFP-000: adds file reading logic
parent
adda896c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
2 deletions
+24
-2
BlobTriggerFunction.java
.../java/com/nisum/demo/blobStorage/BlobTriggerFunction.java
+22
-2
application.properties
src/main/resources/application.properties
+1
-0
blobFile.csv
src/main/resources/files/blobFile.csv
+1
-0
No files found.
src/main/java/com/nisum/demo/blobStorage/BlobTriggerFunction.java
View file @
b255fb4f
...
@@ -2,6 +2,14 @@ package com.nisum.demo.blobStorage;
...
@@ -2,6 +2,14 @@ package com.nisum.demo.blobStorage;
import
com.microsoft.azure.functions.annotation.*
;
import
com.microsoft.azure.functions.annotation.*
;
import
com.microsoft.azure.functions.*
;
import
com.microsoft.azure.functions.*
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.nio.file.Files
;
import
java.nio.file.Paths
;
import
java.util.PropertyResourceBundle
;
import
java.util.ResourceBundle
;
import
java.util.regex.Pattern
;
/**
/**
* Azure Functions with Azure Blob trigger.
* Azure Functions with Azure Blob trigger.
...
@@ -12,10 +20,22 @@ public class BlobTriggerFunction {
...
@@ -12,10 +20,22 @@ public class BlobTriggerFunction {
*/
*/
@FunctionName
(
"BlobTriggerFunc"
)
@FunctionName
(
"BlobTriggerFunc"
)
public
void
run
(
public
void
run
(
@BlobTrigger
(
name
=
"file"
,
path
=
"test/{name}"
,
dataType
=
"binary"
,
connection
=
"
MyStorageConnectionAppSetting
"
)
byte
[]
content
,
@BlobTrigger
(
name
=
"file"
,
path
=
"test/{name}"
,
dataType
=
"binary"
,
connection
=
"
AzureWebJobsStorage
"
)
byte
[]
content
,
@BindingName
(
"name"
)
String
name
,
@BindingName
(
"name"
)
String
name
,
final
ExecutionContext
context
final
ExecutionContext
context
)
{
)
throws
IOException
{
ResourceBundle
resourceBundle
=
new
PropertyResourceBundle
(
new
FileInputStream
(
"/Users/adanish/Documents/azure-function-blob-storage-examples/src/main/resources/application.properties"
));
if
(
Pattern
.
matches
(
"[a-z|A-Z]*.csv"
,
name
))
{
String
directoryPath
=
resourceBundle
.
getString
(
"files.directory.path"
)+
name
;
if
(!
Files
.
exists
(
Paths
.
get
(
directoryPath
)))
{
Files
.
createFile
(
Paths
.
get
(
directoryPath
));
}
try
(
FileOutputStream
fileOutputStream
=
new
FileOutputStream
(
directoryPath
,
true
))
{
fileOutputStream
.
write
(
content
);
}
}
context
.
getLogger
().
info
(
"Java Blob trigger function processed a blob. Name: "
+
name
+
"\n Size: "
+
content
.
length
+
" Bytes"
);
context
.
getLogger
().
info
(
"Java Blob trigger function processed a blob. Name: "
+
name
+
"\n Size: "
+
content
.
length
+
" Bytes"
);
}
}
}
}
src/main/resources/application.properties
0 → 100644
View file @
b255fb4f
files.directory.path
=
/Users/adanish/Documents/azure-function-blob-storage-examples/src/main/resources/files/
\ No newline at end of file
src/main/resources/files/blobFile.csv
0 → 100644
View file @
b255fb4f
hey there blob trigger function.hey there blob trigger function.hey there blob trigger function.
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment