1

I'm creating this azure function in python, getting data from HTTP post and save to azure blob storage.

def main(req: func.HttpRequest, outputblob: func.Out[bytes]) -> func.HttpResponse:
# clientId = req.params.get("clientId")
clientId = os.environ["OS"]
# clientId = "abcdef"

req_body = req.get_json()

outputblob.set(json.dumps(req_body))

here is blob out binding part of function.json

    {
  "name": "outputblob",
  "type": "blob",
  "dataType": "binary",
  "path": "container/{clientId}/{datetime:yyyy}/{datetime:MM}/{datetime:dd}/{rand-guid}.json",
  "connection": "DatalakeConnectionStr",
  "direction": "out"
}

I tried 3 different option for parameter of clientId

  • clientId = req.params.get("clientId") <- from URL parameter, this one works
  • clientId = os.environ["clientId"] <- from configuration, this one not working
  • clientId = "abcdef" <- this one not working

I really like to make os.environ["clientId"] one works. how to make it works.

Thanks, Wes

3
  • 2
    Did you get the issue resolved? Actually, this is because we can not use ClientId in bindings. you can put this param in query or body of req that's why your first method is working fone and not others. Commented Apr 7, 2022 at 18:08
  • thank you, @sakulachi8, now I know for sure this does not works Commented Apr 8, 2022 at 14:48
  • what type of parameter is required for set method? I save a bytes object but the file seems empty. Commented Nov 28, 2022 at 16:35

1 Answer 1

0

Thank You Sakulachi8 for your valuable suggestion and for pointing the OP in the right direction. Posting as an answer to help other community members.

The first method failed because we cannot use ClientID in bindings, but you can use the ClientID in Query Parameters, or the body of the request will work.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.