Search code examples
azureflaskazure-blob-storageweb-hosting

Accessing Files created by Webapp hosted by Azure


New to cloud hosting in Azure, recently created a flask webapp that will open, if not generate a txt file(with root directory), but i dont think if there is any way to access that file? i have not created or subscribed to any storage services provided by azure yet. Will i be charged since the file is technically stored somewhere but i cant access it?


Solution

  • I have created a flask app which creates a text.txt file and deployed it to web app in Azure using VS code.

    you can get the created file inside the file output.tar.gz.

    app.py:

    from flask import Flask
    
    app=Flask(__name__)
    
    @app.route('/')
    def Hello():
        text ='hello, File created using flask app'
        with open('text.txt', 'w') as file:
            file.write(text)
        return "this is a Flask app"
    
    
    if __name__=="__main__":
        app.run()
    

    deployment: enter image description here

    OUTPUT:

    enter image description here

    • Open kudu for linux app using this url https://yourwebappname.scm.azurewebsites.net/newui.
    • Go to File Manager, go to directory site/wwwroot and download the output.tar.gz file.
    • text.txt file will be available inside the file. as shown below.

    enter image description here

    enter image description here

    enter image description here