An Azure service that provides an event-driven serverless compute platform.
Hi everyone, I'm using V2. How can i import a common.py file?
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi
Would like to know how should I import py file in Azure function? I keep getting error code 500 when running the function when I am having my import code in my project
An Azure service that provides an event-driven serverless compute platform.
A cloud computing platform and infrastructure for building, deploying and managing applications and services through a worldwide network of Microsoft-managed datacenters.
Hi everyone, I'm using V2. How can i import a common.py file?
@Po Chia Choon Thanks for reaching out. As per the screenshot you have specified
from ExeGet impart getDN..
but I don't see any python file starting with getDN in your screenshot.
Let' say if your file is CreateDNV.py and the folder is ExeGet then you need to use the below line
from ExeGet import x
Now let's say if you have the method define a test function inside your CreateDNV file you need to use below to call
x.test()
Sample example for your reference: https://stackoverflow.com/a/71999399/13796136
Created a Folder calcfunction and added the add_number function:
def add_number(n1,n2):
sum = n1 + n2;
return sum;
print("The sum of two number is",sum)
Calling this method from Azure Function Python Class:
import logging
import azure.functions as func
from calcfunction import calc
def main(req: func.HttpRequest) -> func.HttpResponse:
logging.info('Python HTTP trigger function processed a request.')
id = req.params.get('id')
if not id:
try:
req_body = req.get_json()
except ValueError:
pass
else:
id = req_body.get('id')
if id:
return func.HttpResponse(f"This is the user entered userId {id} and calc function value {calc.add_number(12,24)}")
else:
return func.HttpResponse(
"This HTTP triggered function executed successfully. Pass a ID in the query string or in the request body for a personalized response.",
status_code=200
)
Folder Structure: