Closed dxkaufman closed 5 years ago
Your import error is not because of the extension but due to how Azure Functions works and how you specified your import. Basically you either need to change it to from __app__.SharedCode import FunctionApp
or from .SharedCode import FunctionApp
. See https://github.com/Azure/azure-functions-python-worker/issues/469 on details.
@brettcannon, thanks for the response. I tried from .SharedCode import FunctionApp
and got this error: Attempted relative import beyond top-level package
.
Is this because of a recent change?
I will try moving all of my code into an app directory and maybe the from __app__.SharedCode import FunctionApp
option will work.
Unfortunately, now with my DataPipeline and SharedCode directories under the __app__
directory, I get this error message:
No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).
I am trying to use the pvscbot code mentioned in the issue you linked to figure out what's wrong, but I'm not seeing it. I now have the following:
Data Pipeline
| - __app__
| | - DataPipeline
| | | - etl.py
| | | - function.json
| | - SharedCode
| | | - APIs.py
| | | - FunctionApp.py
| | - host.json
| | - local.settings.json
| - .vscode (dir)
| - env (dir)
| - host.json
| - local.settings.json
I can't see what in pvscbot is telling it that the function is at __app__/github/function.json
.
@dxkaufman Unfortunately at this point you will need to reach out to the Azure Functions team for help.
Thanks, @brettcannon; what would you say is the best way to do that? Via one of the Azure Functions python packages in github?
@dxkaufman You can try the repo I linked to earlier and see where they redirect you
@brettcannon, yeah, that's what I'm about to do. Thanks.
Environment data
"python.jediEnabled"
set to; more info #3977): python.jediEnabled not presentOther extensions: Azure Account 0.8.7 Azure App Service 0.16.1 Azure Functions 0.20.0 Azure Storage 0.7.2 Azure Storage Explorer 0.1.2 Git History 0.4.6 SQL Server (mssql) 1.7.0
pip freeze output at the very end of the ticket.
Expected behaviour
Code should execute while Azure attached. I also filed this in Stack Overflow yesterday, as well as a ticket with Azure support - I'm stuck in the water and can't finalize my testing and upload to my production services. https://stackoverflow.com/questions/58842695/vscode-running-python-azure-function-locally-fails-with-modulenotfounderror I apologize if this isn't the right place for this post...
Actual behaviour
On timer trigger or https trigger, while Azure attached, I receive this error message:
Steps to reproduce:
Relevant directory structure:
function.json contains the following:
etl.py includes the following imports:
import datetime import logging import azure.functions as func import pandas as pd import sqlalchemy from SharedCode import FunctionApp from SharedCode import APIs
etl.py also contains a variable & two functions that start with the same line:
Note that function main includes a lot of other code not shown here; Test only includes the two lines above.
Function main is called when executed while Azure attached and as soon as the timer fires, it generates the ModuleNotFoundError for the first "from SharedCode" import. I created function Test to be able to test for the same problem from the command line, which works:
Other than upgrading to VSC 1.40.0 and, I think, applying an azure core tools update, nothing has changed since I was last able to execute this properly while Azure attached.
Logs
Output for
Python
in theOutput
panel (View
→Output
, change the drop-down the upper-right of theOutput
panel toPython
)Complete output in Terminal for Task - host start:
Output from
Console
under theDeveloper Tools
panel (toggle Developer Tools on underHelp
; turn on source maps to make any tracebacks be useful by runningEnable source map support for extension debugging
)pip freeze (after I upgraded some of the azure stuff):