Search code examples
azureazure-functionsazure-storageazure-blob-storage

Use Azure Function to Export CSV


I was trying to write an azure function that access azure blob storage, and use the generated url. So that once the user put this url, it will download a csv file from azure Blob Storage to the caller's local PC. From the azure function I wrote so far it is able to access the data on the blob storage. Does anyone know how to have it export csv to the calling user?


Solution

  • this is quick conversion that might help for you

    import azure.functions as func
    
    async def main(req: func.HttpRequest) -> func.HttpResponse:
        // access azure blog storage and get the csv read as string
        filebytes= bytes(csv, 'utf-8')
    
        return func.HttpResponse(body=filebytes, status_code=200, mimetype='application/octet-stream')