An Azure service that provides an event-driven serverless compute platform.
How to run and deploy a simple Python code using Azure Functions from VS Code?
I have a simple Python script that moves data using a csv file inside Azure File Share.
My understanding is that Azure Functions could run a Python script.
I created a Azure Functions using Azure Portal, and deployed a Function (chose "HTTP_Trigger") using VS Code.
I am having difficulty tying (attaching logic) my Python script into the default py file (function_app.py).
I have a simple Python code that basically creates a csv file inside Azure.
And I have a Azure Logic App that is supposed to run this Azure Functions.
I am also not sure whether choosing "HTTP Trigger" was a right choice.
Please let me know if other option (besides "HTTP Trigger") is better.
What is simplest way to run a Python code within Azure if Azure Functions is not the answer?
Azure Functions
-
Krishna Chowdary Paricharla • 2,915 Reputation points • Microsoft External Staff • Moderator
2025-09-10T22:05:57.57+00:00 Hello Justin Doh,
Yes, Azure Functions can definitely run Python code, but there are a few important points to set it up correctly:
Function type (trigger)
- An HTTP trigger is fine if you want your Logic App (or anything else) to call your function via an endpoint.
- If you want the function to run on a schedule (for example, process a CSV every night), you could use a Timer trigger.
- Other triggers (Blob/File Share/Queue) are useful if you want the function to run automatically when new files land in storage.
Where to put your Python code
- The entry point is the generated
function_app.py(for v2 isolated) or__init__.py(for in-process model). - You can import your own Python module into this file. For example:
import logging import azure.functions as func from my_script import process_csv # your custom script app = func.FunctionApp() @app.function_name(name="HttpExample") @app.route(route="run-script") def main(req: func.HttpRequest) -> func.HttpResponse: result = process_csv() return func.HttpResponse(f"Function finished: {result}")In this case,
my_script.pywould contain your existing CSV logic.Running in VS Code locally
- Use the Azure Functions extension in VS Code.
- Run
func startlocally and test withcurlor Postman.
Deploying to Azure
- Once tested, deploy directly from VS Code with Azure Functions: Deploy to Function App.
-
Justin Doh • 1,000 Reputation points
2025-09-10T22:27:32.69+00:00 Thank you so much for your help.
I am still not clear how to add the logic of my Python code.
I guess maybe because I could not distinguish your comment between code or comment.
Here are my questions:
- Do we modify the "function_app.py" and add the logic there?
- Or do we call my Python code from "function_app.py"?
- What is purpose of "function_app.py"?
Thank you.
-
Krishna Chowdary Paricharla • 2,915 Reputation points • Microsoft External Staff • Moderator
2025-09-10T22:34:08.03+00:00 Hello Justin Doh,
Do we modify the
function_app.pyand add the logic there?You don’t need to put all of your logic inside
function_app.py. Instead, you should keep your Python script logic in a separate file (e.g.,my_script.py) and then call it fromfunction_app.py. This keeps the Function entry file clean.Or do we call my Python code from
function_app.py?Yes — the recommended way is to call your Python code from
function_app.py. For example:import azure.functions as func from my_script import process_csv # import your logic app = func.FunctionApp() @app.function_name(name="RunCsvFunction") @app.route(route="run-csv") def main(req: func.HttpRequest) -> func.HttpResponse: result = process_csv() return func.HttpResponse(f"Done: {result}")What is the purpose of
function_app.py?This file is the entry point that Azure Functions runtime looks at. Its job is to:
- Define the trigger (HTTP, Timer, Blob, etc.).
- Receive the event or request.
- Call your own Python logic (which lives in another file).
function_app.pyconnects Azure Functions runtime to your script, but your actual business logic should remain in your own Python file(s). -
Justin Doh • 1,000 Reputation points
2025-09-11T00:37:13.4066667+00:00 @Krishna Chowdary Paricharla Thank you so much.
I think I understood what you are saying and I tested and it worked (in a local environment, not in Azure).
Can I ask you two questions?
I am having difficulty deploying the code.
Initially, I had the "http_trigger" created under Function like below (this is not the screenshot of current status), but when I tried to deploy again, this gets wiped out.
I am not sure whether I am doing it correctly.
- What is procedure of re-deploying code (after modifications) from VS Code?
My understanding is like: Press F1 --> Azure Functions: Deploy to Azure -->choose Subscription --> select Function App, isn't it?
But how do I select a folder or certain objects to deploy?
- Also, how do I go about deploying the other Python code (that has the logic)?
-
Krishna Chowdary Paricharla • 2,915 Reputation points • Microsoft External Staff • Moderator
2025-09-11T03:56:43.4366667+00:00 Hello Justin Doh,
How to re-deploy code after modifications from VS Code?
Yes, your understanding is correct:
- In VS Code, press F1 → “Azure Functions: Deploy to Function App” → choose your subscription → select your Function App.
- This publishes the entire local project folder (not just a single file). That’s why the generated triggers (like
http_trigger) may look “different” after deployment — the cloud version always reflects your current local project.
So, if you make changes locally (e.g., modify
function_app.pyormy_script.py), you just redeploy the whole folder. You don’t deploy file by file.Why did old HTTP trigger disappear?
When you re-deploy, Azure overwrites the Function App contents with what’s in your local folder.
- If the old trigger isn’t in your local project anymore, it won’t exist in Azure after deployment.
- To fix this: always keep the function you want (like your
http_trigger) in your local codebase and redeploy.
How to deploy your other Python code (with logic)?
- Just place your script (e.g.,
my_script.py) inside the same project folder (alongsidefunction_app.py). - Since it’s part of the folder, when you deploy, VS Code pushes it along with everything else.
- Azure Functions runtime will find and use it because
function_app.pyimports it.
Recommended folder structure
For example, your project might look like this:
MyFunctionApp/ ├── function_app.py # entry point with trigger ├── my_script.py # your business logic ├── requirements.txt ├── host.json └── local.settings.jsonWhen you deploy, all of this is pushed to Azure.
-
Justin Doh • 1,000 Reputation points
2025-09-11T20:12:06.84+00:00 @Krishna Chowdary Paricharla Thank you so much again!
I tried deploying by first go to "Explorer" in (VS Code), and did F1 --> Azure Functions: Deploy to Azure --> (selected subscription) --> (selected function app) ,but nothing got deployed.
When I looked at the details, it says "No HTTP triggers found."
Then, I try again by going to "Azure" in (VS Code), and did F1, and did the same procedure, but, nothing got deployed again.
When I looked at the details, it says "No HTTP triggers found."
I am not sure at which point, "http_trigger" gets created.
-
Krishna Chowdary Paricharla • 2,915 Reputation points • Microsoft External Staff • Moderator
2025-09-11T20:17:35.0233333+00:00 Hello Justin Doh,
The reason you’re seeing “No HTTP triggers found” is that your current project does not define any HTTP-triggered functions that the Azure Functions runtime can detect.
When does the
http_triggerget created?- The
http_triggerfunction isn’t created automatically on deploy. - It is generated only when you create a new Function (with HTTP trigger template) locally using VS Code.
- For Python (isolated model), this adds code in
function_app.pywith something like:import azure.functions as func app = func.FunctionApp() @app.function_name(name="HttpExample") @app.route(route="http_example") def main(req: func.HttpRequest) -> func.HttpResponse: return func.HttpResponse("Hello from Azure Function!")
Without this, the runtime has no route to expose → hence the message “No HTTP triggers found
Why your current deployment shows nothing
Looking at your folder in VS Code (
function_app.py,convert.py, etc.), it seems:-
function_app.pymay not actually contain a valid trigger decorated with@app.route(). -
convert.pyis your business logic, but Azure won’t pick it up unless it’s called from a trigger function infunction_app.py.
How to fix it
- In VS Code, create a new function inside your Function App project:
- F1 → Azure Functions: Create Function → HTTP Trigger → Python → provide a name.
- This will add the correct trigger definition in
function_app.py. - Then, modify that function to call your code in
convert.py. For example:
import azure.functions as func from convert import process_csv # your own script app = func.FunctionApp() @app.function_name(name="RunCsvFunction") @app.route(route="run-csv") def main(req: func.HttpRequest) -> func.HttpResponse: result = process_csv() return func.HttpResponse(f"Done: {result}")Deployment process reminder
- Always deploy from the project root (the folder that contains
function_app.py,host.json,requirements.txt). - VS Code pushes the entire folder. If the trigger exists locally and runs with
func start, it will show up in Azure after deploying.
The
http_triggeronly exists if you create it in your code (@app.route). Right now, Azure doesn’t see any HTTP function infunction_app.py, so deployment shows “No HTTP triggers found.” Add (or re-create) an HTTP trigger locally, then deploy again — your Logic App will then be able to call it. - The
-
Justin Doh • 1,000 Reputation points
2025-09-11T20:55:33.4+00:00 Do I need other Python code besides bottom code inside "function_app.py" in order to create "http_trigger"?
import azure.functions as func from convert import process_csv # import your logic app = func.FunctionApp() @app.function_name(name="RunCsvFunction") @app.route(route="run-csv") def main(req: func.HttpRequest) -> func.HttpResponse: result = process_csv() return func.HttpResponse(f"Done: {result}") -
Krishna Chowdary Paricharla • 2,915 Reputation points • Microsoft External Staff • Moderator
2025-09-11T21:09:02.12+00:00 No extra Python code is needed. The snippet you posted is already a valid HTTP trigger. Just make sure your project has the correct folder structure and required files (
host.json,requirements.txt) so the runtime can recognize it. -
Justin Doh • 1,000 Reputation points
2025-09-11T23:33:53.7833333+00:00 Thank you!
So, I tried different things.
I created a new Function App, and this one appears to be more stable ("HTTP_Trigger" gets created in Azure Function App when I use the original Python code) than previous Function App that I was using for last few days.
I was able to go to step by "Create new project" each time, and this process seem to make it work to at least to publish all files.
But "HTTP_Trigger" that I had earlier got disappeared (when I refreshed it).
It disappeared when I tried with the new Python code.
Do you think there is something missing from the Python code at "function_app.py"?
This is error message after I refreshed it and disappeared:
Bottom is my code. Thank you!
import azure.functions as func from convert import process_csv # import your logic app = func.FunctionApp() @app.function_name(name="http_trigger") @app.route(route="run-csv") def main(req: func.HttpRequest) -> func.HttpResponse: result = process_csv() return func.HttpResponse(f"Done: {result}") -
Krishna Chowdary Paricharla • 2,915 Reputation points • Microsoft External Staff • Moderator
2025-09-13T01:39:15.7566667+00:00 Hello Justin Doh,
Your
function_app.pycode is already correct — nothing is missing for the HTTP trigger.The reason the function disappears after refresh is not the code, but usually one of these:
convert.pynot deployed (make sure it’s in the same project folder asfunction_app.py).Missing dependencies (add any libraries used in
convert.pytorequirements.txt).Deployed from the wrong folder (you must deploy the folder that contains
function_app.py,host.json, andrequirements.txt).Run
func startlocally — if you don’t see the HTTP trigger locally, Azure also won’t load it. -
Keisanki Dentaku • 30 Reputation points2025-09-13T10:01:32.47+00:00 When you redeploy from VS Code, Azure Functions always pushes the entire local project folder, not individual files. That means if a function (like your old
http_trigger) isn’t present in your local codebase at deployment time, it won’t exist in Azure afterward.To make sure everything works as expected:
Keep both your trigger (
function_app.py) and your logic file (e.g.,my_script.py) inside the same project folder.Import your script from
function_app.pyso Azure Functions runtime can call it.Use the folder structure like this:
MyFunctionApp/ ├── function_app.py ├── my_script.py ├── requirements.txt ├── host.json └── local.settings.jsonWhen you modify your code, just redeploy the full project folder using: F1 → Azure Functions: Deploy to Function App → select subscription → select your Function App.
This way your custom Python script will be deployed alongside the trigger definition.
As a side tip — when handling CSV data or verifying output, I sometimes double-check results with quick tools like this scientific calculator. It’s handy for quick math or calculation checks while debugging Python functions. In fact, tools like that can be really useful when you need to validate transformations on numbers in your CSVs or just confirm that your logic is producing the expected outputs. I’ve found it saves time compared to writing extra debug code just to verify.
-
Justin Doh • 1,000 Reputation points
2025-09-15T18:21:10.95+00:00 @Krishna Chowdary Paricharla Thank you.
I am trying to make sure I have necessary lines inside "requirelments.txt".
Currently my logic file "convert.py" has following codes on the top (where "import(s)" are):
from azure.storage.fileshare import ShareServiceClient import pandas as pd import ioDo I have to indicate as below inside "requirements.txt"?
Also, I am not sure what you meant by "Run
func startlocally — if you don’t see the HTTP trigger locally, Azure also won’t load it."BTW, when I run the code "function_app.py" from my local machine, it works (result get done as expected).
Thanks.
-
Justin Doh • 1,000 Reputation points
2025-09-15T18:33:25.65+00:00 @Keisanki Dentaku Thank you for your feedback.
I have replied to Krishna's comment on the top.
I will wait for her response, but I have a question for you.
When you mentioned ".. if a function (like your old
http_trigger) isn’t present in your local codebase at deployment time" , currently, I am using code below and deploy (replacing the original "http_trigger" code that was provided:import azure.functions as func from convert import process_csv # import your logic app = func.FunctionApp() @app.function_name(name="http_trigger") @app.route(route="run-csv") def main(req: func.HttpRequest) -> func.HttpResponse: result = process_csv() return func.HttpResponse(f"Done: {result}")It should work, correct?
Thanks. -
Praveen Kumar Gudipudi • 2,295 Reputation points • Microsoft External Staff • Moderator
2025-09-24T15:02:52.0633333+00:00 Hello Justin Doh,
Could you please try zip deployment is a method.
Because With zip deployment, the structure of your app, including all files like function_app.py, convert.py, and any required dependencies (like requirements.txt), is bundled together in a single .zip file. This can prevent issues where the Azure Functions app can't locate your files correctly after deploying them in a non-zipped form.
By using zip deployment, you should eliminate any potential issues related to the missing files, and ensure your function app is loaded correctly.
Let me know if you need further assistance!
-
Praveen Kumar Gudipudi • 2,295 Reputation points • Microsoft External Staff • Moderator
2025-09-29T12:34:12.9166667+00:00 Hello Justin Doh,
We haven’t heard from you on the last response and was just checking back to see if you have a resolution yet. In case if you have any resolution please do share that same with the community as it can be helpful to others. Otherwise, will respond with more details and we will try to help.
-
Justin Doh • 1,000 Reputation points
2025-09-29T20:22:50.35+00:00 @Praveen Kumar Gudipudi Thank you for your suggestions. I thought zip method only applies to Azure Logic App. Do you have any reference URL for this by chance? I am just not understanding how zip method would work in Azure Function. Thanks.
-
Praveen Kumar Gudipudi • 2,295 Reputation points • Microsoft External Staff • Moderator
2025-09-29T20:43:29.56+00:00 Hello Justin Doh,
- ZIP deployment is valid and supported for Azure Functions.
- It helps ensure that all files and dependencies are deployed correctly.
Zip deployment for Azure Functions
Please check above documents and let me know with an update.
-
Praveen Kumar Gudipudi • 2,295 Reputation points • Microsoft External Staff • Moderator
2025-10-06T12:21:43.24+00:00 Hello Justin Doh,
We haven’t heard from you on the last response and was just checking back to see if you have a resolution yet. In case if you have any resolution please do share that same with the community as it can be helpful to others. Otherwise, will respond with more details and we will try to help.
-
Justin Doh • 1,000 Reputation points
2025-10-06T17:57:09.8666667+00:00 @Praveen Kumar Gudipudi Thank you for following up.
At this moment, I decided to go with other route (running Python file from VM using Task Scheduler) as using zip appears to be little bit overwhelming to get it done. I am still in touch with Azure Support engineer to find out the root cause of issue though. Thanks.
Sign in to comment