An Azure service that provides an event-driven serverless compute platform.
Hi Insitely
Thank you for reaching out to Microsoft Q&A
__init__.py is no longer required as Functions V2 is being used now.
If you want to deploy multiple Function triggers, they should be part of function_app.py file like below:
My Folder Structure:
function_app.py:
Add your trigger bindings in the same file with :
@app.route(route="http_trigger")
@app.blob_trigger(arg_name="myblob", path="mycontainer"
import azure.functions as func
import logging
app = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS)
@app.route(route="http_trigger")
def http_trigger(req: func.HttpRequest) -> func.HttpResponse:
logging.info('Python HTTP trigger function processed a request.')
name = req.params.get('name')
if not name:
try:
req_body = req.get_json()
except ValueError:
pass
else:
name = req_body.get('name')
if name:
return func.HttpResponse(f"Hello, {name}. This HTTP triggered function executed successfully.")
else:
return func.HttpResponse(
"This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.",
status_code=200
)
@app.blob_trigger(arg_name="myblob", path="mycontainer",
connection="siliconstorage09_STORAGE")
def BlobTrigger(myblob: func.InputStream):
logging.info(f"Python blob trigger function processed blob"
f"Name: {myblob.name}"
f"Blob Size: {myblob.length} bytes")
host.json:
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
},
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[4.*, 5.0.0)"
}
}
local.settings.json:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "",
"FUNCTIONS_WORKER_RUNTIME": "python",
"siliconstorage09_STORAGE": "DefaultEndpointsProtocol=https;AccountName=silxxxxx;AccountKey=xxxxxxxxxpQLzg==;EndpointSuffix=core.windows.net"
}
}
requirements.txt:
azure-functions
After you have changed your folder structure and files to above, you can deploy your function code in the Flex consumption-based Function app by referring to this MS Doc: https://learn.microsoft.com/en-us/azure/azure-functions/flex-consumption-how-to?tabs=azure-cli%2Cazure-cli-publish&pivots=programming-language-python