title: How do I cache files within a function app?
body: <p>I am trying to temporarily store files within a function app. The function is triggered by an http request which contains a file name. I first check if the file is within the function app storage and if not, I write it into the storage.</p>
  <p><strong>Like this:</strong></p>
  <pre><code>    if local_path.exists():
          file = json.loads(local_path.read_text('utf-8'))
      else:
          s = AzureStorageBlob(account_name=account_name, container=container, 
                            file_path=file_path, blob_contents_only=True, 
                            mi_client_id=mi_client_id, account_key=account_key)
          local_path.write_bytes(s.read_azure_blob())
          file = json.loads((s.read_azure_blob()).decode('utf-8'))
  </code></pre>
  <p><strong>This is how I get the local path</strong></p>
  <pre><code>    root = pathlib.Path(__file__).parent.absolute()
      
      file_name = pathlib.Path(file_path).name
      local_path = root.joinpath('file_directory').joinpath(file_name)
  </code></pre>
  <p>If I upload the files when deploying the function app everything works as expected and I read the files from the function app storage. But if I try to save or cache a file, it breaks and gives me this error <code>Error: [Errno 30] Read-only file system:</code></p>
  <p>Any help is greatly appreciated</p>