Skip to content
This repository has been archived by the owner on Oct 14, 2023. It is now read-only.

Commit

Permalink
Added Blog Trggier function sample - Zipped file
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoichi Kawasaki committed Jul 30, 2018
1 parent 99ce42b commit 1d5155f
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
Binary file added blob-trigger-blob-in-out-bindings/clear.zip
Binary file not shown.
19 changes: 19 additions & 0 deletions blob-trigger-blob-in-out-bindings/function_zip/function.json
@@ -0,0 +1,19 @@
{
"bindings": [
{
"name": "blobTriggerTest",
"type": "blobTrigger",
"direction": "in",
"path": "inputcontainer4funcs/{blobname}.zip",
"connection": "yourstorageaccount_STORAGE"
},
{
"type": "blob",
"name": "inputBlob",
"path": "inputcontainer4funcs/{blobname}.zip",
"direction": "in",
"connection": "yourstorageaccount_STORAGE"
}
],
"disabled": false
}
23 changes: 23 additions & 0 deletions blob-trigger-blob-in-out-bindings/function_zip/run.py
@@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-

"""
Azure Functions Blob Trigger Python Sample
- Reading Zip archived files from Azure Blob Storage
"""

import os
import zipfile

# Read Input Zip file given from ENV variable named 'inputBlob'
zippath=os.environ['inputBlob']
print("Zip File Path: {}".format(zipfilepath))

# Read text files in the given zip file assuming that the files are clear text
with zipfile.ZipFile(zippath) as z:
for filename in z.namelist():
print("filename:{} in zipfile:{}".format(filename, zippath))
if not os.path.isdir(filename):
# Reading the file in Zipfile
with z.open(filename) as f:
for line in f:
print(line)

0 comments on commit 1d5155f

Please sign in to comment.