Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blob binding inout direction does not seem to be supported #2104

Closed
AharonDror opened this issue Nov 6, 2017 · 6 comments
Closed

Blob binding inout direction does not seem to be supported #2104

AharonDror opened this issue Nov 6, 2017 · 6 comments

Comments

@AharonDror
Copy link

I've been using azure function with a binding:
{ "name": "someName", "type": "blob", "direction": "out", "path": "some/path.json", "connection": "<storage>" }
This worked just fine, until recently I needed to use the same blob that was written in the function's last execution as an input for my function. I changed the direction of the binding to "inout" as stated in the docs: https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-blob

This did not work. The function throws an error:

Cannot bind blob to Stream using FileAccess ReadWrite

When I opened the 'Integrate' tab of the function I couldn't see the input/out for that binding.
The workaround of defining 2 bindings, one with an out direction and one with an in direction with different names but the same path + connection worked for me, but is obviously less convenient and not consistent with the docs.

@Paqi
Copy link

Paqi commented Nov 17, 2017

I've encountered this problem with a Powershell script Azure Function, but had no problem with a C# Azure Function.

@paulbatum paulbatum added this to the Active Questions milestone Nov 22, 2017
@paulbatum
Copy link
Member

@AharonDror can you give us your function signature?

@pankajarm
Copy link

pankajarm commented Dec 5, 2017

@paulbatum I have this same issue with python azure function. I am pretty sure, i am missing right docs on this but couldn't find anything related in existing docs, https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-blob)
Workaround of defining two bindings, one with an out and another in direction connection worked, however as @AharonDror reported, this is obviously not convenient and for me could lead to a bad design scenarios.
Here is the function signature, I am using.
{
"bindings": [
{
"authLevel": "function",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": [
"post"
]
},
{
"type": "http",
"direction": "out",
"name": "res"
},
{
"type": "blob",
"name": "appendoutput",
"path": "blob_name/file.txt",
"direction": "inout",
"connection": "azure_STORAGE"
}
],
"disabled": false
}

Any advise, would be appreciated.

@paulbatum
Copy link
Member

By function signature, I meant the method signature. e.g. the definition of the function including return type and params.

@pankajarm
Copy link

Ohh.. Sure, Here is complete function, nothing fancy...

import os
import json
import logging


logging.basicConfig(filename='custom.log',level=logging.DEBUG)

postreqdata = json.loads(open(os.environ['req']).read())
response = open(os.environ['res'], 'w')

new_row = "some data string"

try:
    response.write("Event Added => " + new_row)
    response.close()
except Exception as e:
    logging.warning(e)

# Read inputfile given from ENV variable named 'readinput'
try:
    input_file = open(os.environ['readinput'], 'r')
    read_text = input_file.read()
    input_file.close()
except Exception as e:
    logging.warning(e)

# appended_text
if read_text:
    appended_text = read_text + '\n'+ new_row
else:
    appended_text = new_row

# Encrypt text with ROT13 encryption
encrypted_text= appended_text.decode('rot13')

# Write new row to existing input file given from ENV variable named 'appendoutput'
try:
    output_file = open(os.environ['appendoutput'], 'a')
    output_file.write(encrypted_text)
    output_file.close()
except Exception as e:
    logging.warning(e)

# Run Ends here

@paulbatum
Copy link
Member

paulbatum commented Dec 7, 2017

Ahh of course, I somehow missed that you were talking about python and did not make the connection. Short version - its not supported yet. This is tracked by: #49

Closing this one as a duplicate.

@ghost ghost locked as resolved and limited conversation to collaborators Jan 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants