none
Azure Function in Python that is on a time trigger get zip file from a url, unzip, then output file to blob container in Azure storage RRS feed

  • Question

  • Here is my function.json:

    {
      "scriptFile": "__init__.py",
      "bindings": [
        {
          "name": "mytimer",
          "type": "timerTrigger",
          "direction": "in",
          "schedule": "0 30 7 * * *"
        },
       
        {
          "type": "blob",
          "direction": "out",
          "name": "outputBlob",
          "path": "jarvisetl/nppesraw",
          "connection": "AzureWebJobsStorage"
        }
      ]
    }

    Here is my corresponding Python Script

    import datetime
    import logging
    import azure.functions as func
    import urllib.request
    from io import BytesIO
    from urllib.request import urlopen
    from zipfile import ZipFile
    
    def main(mytimer: func.TimerRequest) -> str:
        utc_timestamp = datetime.datetime.utcnow().replace(
            tzinfo=datetime.timezone.utc).isoformat()
    
        if mytimer.past_due:
            logging.info('The timer is past due!')
    
        logging.info('Python timer trigger function ran at %s', utc_timestamp)
    
        zipurl = 'https://download.file.com'
        with urlopen(zipurl) as zipresp:
            with ZipFile(BytesIO(zipresp.read())) as zfile:
                zfile.extractall(outputblob)

    My biggest issue is I am getting an error that "outputblob" is declared in the function.json but not apparent in the python script. I am not sure where "outputblob" is truly suppose to go in the Python script.

    Monday, September 14, 2020 10:00 PM