How can I create a file in my azure function?

Jose Joab Romero Humba 41 Reputation points
2021-05-05T01:24:36.477+00:00

I am using azure Function and I need my function create a file when I call it but when i call it, it returns the next error: "Failure Exception: OSError: [Errno 30] Read-only file system: 'audio.wav' ". I would like to know how to resolve it.

this is the code for better explanation:

93754-main.png

93700-funcion.png

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,930 questions
0 comments No comments
{count} votes

Accepted answer
  1. MayankBargali-MSFT 70,941 Reputation points Moderator
    2021-05-05T14:09:27.843+00:00

    Hi @Jose Joab Romero Humba

    Welcome to Microsoft Q&A! Thanks for posting the question.

    Python functions are supported on the Linux OS in azure. The current directory is indeed read-only and if you want to create the temporary file then you need to create it in the temporary folder.

    import logging  
    import azure.functions as func  
    import tempfile  
    from os import listdir  
      
    #---  
       tempFilePath = tempfile.gettempdir()  
       fp = tempfile.NamedTemporaryFile()  
       fp.write(b'Hello world!')  
       filesDirListInTemp = listdir(tempFilePath)  
    
    2 people found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.